Context bar: defer OSC7 cwd update out of render phase (was dropped)
The OSC 7 handler runs synchronously inside term.write() as PTY data is processed, which can coincide with React's render phase — calling the parent setState there warned 'cannot update while rendering' and the liveCwd update was dropped, so claude panes never registered their cwd and the bar never showed (backend data + match were fine). Defer the onCwd call via queueMicrotask. Plus a TEMP per-pane match-decision log. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bbe827af22
commit
a1d7919537
2 changed files with 21 additions and 1 deletions
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue