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:
megaproxy 2026-05-28 23:19:25 +01:00
parent bbe827af22
commit a1d7919537
2 changed files with 21 additions and 1 deletions

View file

@ -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;
});