diff --git a/src/components/XtermPane.tsx b/src/components/XtermPane.tsx index 3ebb2a9..a2d3e07 100644 --- a/src/components/XtermPane.tsx +++ b/src/components/XtermPane.tsx @@ -224,7 +224,12 @@ export default function XtermPane({ } catch { /* leave raw if it isn't valid percent-encoding */ } - onCwdRef.current?.(path); + // Defer out of term.write()'s synchronous path: OSC handlers run while + // xterm processes PTY data, which can coincide with React's render + // phase — calling the parent's setState directly there triggers a + // "cannot update while rendering" warning and the update gets dropped. + const reported = path; + queueMicrotask(() => onCwdRef.current?.(reported)); } return true; }); diff --git a/src/lib/layout/LeafPane.tsx b/src/lib/layout/LeafPane.tsx index 010ae3e..25be577 100644 --- a/src/lib/layout/LeafPane.tsx +++ b/src/lib/layout/LeafPane.tsx @@ -199,6 +199,21 @@ export default function LeafPane({ leaf }: { leaf: LeafNode }) { }), [], ); + // TEMP diagnostic — logs the per-pane match decision on change. + useEffect(() => { + if (leaf.shellKind !== "wsl") return; + const c = liveCwd ?? leaf.cwd; + const hit = c ? orch.paneContext.get(c) : undefined; + console.log( + "[ctx] MATCH", + leaf.label ?? leaf.distro, + "cwd=", + c, + hit + ? `→ ${hit.contextTokens}tok ${Math.round((Date.now() - hit.lastActiveMs) / 1000)}s ago` + : "→ no match", + ); + }, [liveCwd, leaf.cwd, leaf.shellKind, leaf.label, leaf.distro, orch.paneContext]); // ---- broadcast --------------------------------------------------------- const onTerminalInput = useCallback(