fix: local PowerShell garbled output + resize not propagating
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 4m10s

Two issues:
1. convertEol was false for PTY sessions, but Windows ConPTY sends
   bare \n without \r. Now enabled on Windows PTY sessions (checked
   via navigator.platform). Unix PTY still false (driver handles it).

2. LocalTerminalView had no ResizeObserver, so the terminal never
   reflowed when the container size changed. Added ResizeObserver
   matching the SSH TerminalView pattern. Also added proper cleanup
   on unmount.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-26 13:38:24 -04:00
parent 3638745436
commit d39c0d38ed
2 changed files with 22 additions and 3 deletions

View File

@ -9,7 +9,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { ref, onMounted, onBeforeUnmount, watch } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { useTerminal } from "@/composables/useTerminal";
import "@/assets/css/terminal.css";
@ -20,11 +20,20 @@ const props = defineProps<{
}>();
const containerRef = ref<HTMLElement | null>(null);
const { terminal, mount, fit } = useTerminal(props.sessionId, "pty");
const { terminal, mount, fit, destroy } = useTerminal(props.sessionId, "pty");
let resizeObserver: ResizeObserver | null = null;
onMounted(() => {
if (containerRef.value) {
mount(containerRef.value);
// Watch container size changes and refit terminal
resizeObserver = new ResizeObserver(() => {
if (props.isActive) {
fit();
}
});
resizeObserver.observe(containerRef.value);
}
setTimeout(() => {
fit();
@ -48,4 +57,12 @@ watch(
}
},
);
onBeforeUnmount(() => {
if (resizeObserver) {
resizeObserver.disconnect();
resizeObserver = null;
}
destroy();
});
</script>

View File

@ -70,7 +70,9 @@ export function useTerminal(sessionId: string, backend: 'ssh' | 'pty' = 'ssh'):
cursorStyle: "block",
scrollback: 10000,
allowProposedApi: true,
convertEol: backend === 'ssh',
// SSH always needs EOL conversion. PTY needs it on Windows (ConPTY sends bare \n)
// but not on Unix (PTY driver handles LF→CRLF). navigator.platform is the simplest check.
convertEol: backend === 'ssh' || navigator.platform.startsWith('Win'),
rightClickSelectsWord: false,
});