Repository navigation
fix(dashboard): give the agent preview terminal a real pane's keyboard - #11015
Conversation
The dashboard's preview terminal is a bare xterm, not a pane, so it never ran `resolveTerminalShortcutAction` — its only custom key handler covered copy/paste and IME. Ctrl+Backspace therefore fell through to xterm's default `\x08`, which readline binds to backward-delete-char: one character instead of a word. Route the preview's keys through the pane's own shortcut policy, so word and line kills, Option chords, modified Enter, and scrollback chords encode identically. Pane-scoped verdicts (splits, search, focus) are swallowed rather than passed to xterm, which would send e.g. Ctrl+Shift+D as a bare Ctrl+D. The policy needs three things the preview could not see: - kitty-protocol flags — mirrored locally from the same PTY output stream - the PTY's execution host — bytes follow the host, not the client OS, so a new `DashboardCard.terminalInput` profile is derived in the main renderer (the only one holding the store) and relayed to the pop-out - host terminal options — the ConPTY backend and the kitty withhold now apply Also brings the emulator itself up to a pane's: Orca's Unicode 11 width shim (replayed CJK/emoji/ZWJ laid out wrong without it), Windows Ctrl+Alt chord repair, user font/cursor/line-height/word-separator/sensitivity settings, ligatures, the TUI wheel multiplier, lazy Arabic shaping, clickable links, and the IME candidate anchor — extracted from pane-lifecycle so both surfaces share one implementation. The in-window drawer built its snapshot from a slice subset, which would have degraded the new profile to client-OS defaults there; it now reads the full store non-reactively.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds host-specific terminal input metadata to dashboard cards, including platform, ConPTY, Shift+Enter encoding, OS release, and kitty keyboard state. Dashboard previews now use this metadata for terminal options, shortcut routing, paste handling, compatibility integrations, links, ligatures, keyboard negotiation, and IME bridging. Preview lifecycle cleanup and tests are expanded. Snapshot validation and refresh tracking now cover the new data, while pane IME anchoring and local ConPTY option construction are extracted into reusable helpers. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The switch-exhaustiveness gate rejects a `default` over the shortcut-action union — it would let a newly added action be swallowed silently instead of forcing a decision at the preview's boundary.
…t-dashboard-ctrl # Conflicts: # src/renderer/src/components/dashboard/build-dashboard-snapshot.ts # src/shared/dashboard-snapshot.ts
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx (1)
265-298: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value
replaceExistingkeeps the original host-compatibility options.The reset path resizes and resets but never re-derives
hostCompatibility(vtExtensions.kittyKeyboard, ConPTY options) fromterminalInputRef.current. If the card's terminal input facts changed between snapshots, the emulator keeps the stale advertisement while the shortcut policy reads the fresh one. Cheap to re-apply viaObject.assign(terminal.options, …)next to the tracker reset.src/renderer/src/components/dashboard-popout/preview-terminal-compatibility.ts (1)
42-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep
installTerminalImeCandidateAnchorand caller cleanup in sync.
installTerminalImeCandidateAnchorstill returns the handler and internally removescompose*events, butpreview-terminal-compatibility.tsalso hand-removes them here. That duplicates cleanup; if the helper later adds a third event, this stopper can become stale. Remove the caller-sideremoveEventListenerblock and rely on the helper’s returned handler/cleanup contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 159f61e7-8acf-41f5-ac9b-92ed3038d07a
📒 Files selected for processing (25)
src/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/renderer/src/components/dashboard-popout/AgentTerminalDialog.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.test.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsxsrc/renderer/src/components/dashboard-popout/preview-clipboard-shortcuts.tssrc/renderer/src/components/dashboard-popout/preview-terminal-compatibility.tssrc/renderer/src/components/dashboard-popout/preview-terminal-ime-bridge.tssrc/renderer/src/components/dashboard-popout/preview-terminal-key-handler.tssrc/renderer/src/components/dashboard-popout/preview-terminal-ligatures.tssrc/renderer/src/components/dashboard-popout/preview-terminal-links.tssrc/renderer/src/components/dashboard-popout/preview-terminal-options.test.tssrc/renderer/src/components/dashboard-popout/preview-terminal-options.tssrc/renderer/src/components/dashboard-popout/preview-terminal-paste.tssrc/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.test.tssrc/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.tssrc/renderer/src/components/dashboard/dashboard-card-terminal-input.test.tssrc/renderer/src/components/dashboard/dashboard-card-terminal-input.tssrc/renderer/src/components/dashboard/useDashboardPopoutBridge.tssrc/renderer/src/components/dashboard/useLiveDashboardSnapshot.tssrc/renderer/src/lib/pane-manager/pane-lifecycle.tssrc/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.tssrc/renderer/src/lib/pane-manager/windows-pty-compatibility.tssrc/shared/dashboard-snapshot.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/dashboard-popout/preview-clipboard-shortcuts.ts
| }, [ptyId, terminalTheme, terminalMode]) | ||
|
|
||
| // Why: appearance settings must land on the open terminal, and the OS input | ||
| // source can flip Option-as-Alt with no settings change at all. A remount | ||
| // would reconnect the pty and repaint the agent's screen from a new snapshot. | ||
| useEffect(() => { | ||
| const terminal = terminalRef.current | ||
| if (!terminal) { | ||
| return | ||
| } | ||
| Object.assign( | ||
| terminal.options, | ||
| buildPreviewAppearanceOptions(settings, macOptionAsAlt === 'true') | ||
| ) | ||
| syncPreviewTerminalLigatures(terminal, settings) | ||
| }, [settings, macOptionAsAlt]) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
The new appearance effect can't prevent remounts while the main effect still depends on the theme.
terminalTheme/terminalMode are recomputed by the useMemo on Lines 71-81 whenever settings changes — a new object identity on any settings edit (font size, cursor style, …). That re-runs the setup effect, disposing the terminal and reconnecting the pty, which is exactly what Lines 418-420 say must not happen. Consider dropping the theme from the dep list (read it from a ref at creation) and applying theme/minimumContrastRatio in the appearance effect alongside the other options.
| const onWindowBlur = (): void => { | ||
| optionKeyLocation = 0 | ||
| nativeOnlyShortcutTracker.clear() | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clear consumedClipboardKeys on blur too.
Entries are only removed on keyup. If the window loses focus between the copy/paste keydown and its keyup (common when a chord triggers an OS-level dialog or app switch), the identity stays latched and the next paste chord hits the !consumedClipboardKeys.has(...) guard on Line 125 and silently does nothing.
🛠️ Proposed fix
const onWindowBlur = (): void => {
optionKeyLocation = 0
+ consumedClipboardKeys.clear()
nativeOnlyShortcutTracker.clear()
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const onWindowBlur = (): void => { | |
| optionKeyLocation = 0 | |
| nativeOnlyShortcutTracker.clear() | |
| } | |
| const onWindowBlur = (): void => { | |
| optionKeyLocation = 0 | |
| consumedClipboardKeys.clear() | |
| nativeOnlyShortcutTracker.clear() | |
| } |
| const platform = getShortcutPlatform() | ||
| const plan = await planTerminalPasteWithYield({ | ||
| text, | ||
| source, | ||
| target: { | ||
| kind: 'terminal', | ||
| paneId: 0, | ||
| leafId: deps.ptyId, | ||
| ptyId: deps.ptyId, | ||
| runtime: resolveTerminalPasteRuntime({ platform, ptyId: deps.ptyId }) | ||
| }, | ||
| terminalBracketedPasteMode: pasteTerminal.modes.bracketedPasteMode | ||
| }) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -nP -C4 'isWindowsConpty|normalizeTerminalPasteLineEndings' src/renderer/src/components/terminal-pane/terminal-paste-*.ts | head -80Repository: stablyai/orca
Length of output: 8475
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== candidate files =="
fd -a 'preview-terminal-(paste|options|shortcuts)\.[jt]sx?$|terminal-paste-.*\.ts$' src/renderer/src | sed 's#^\./##' | head -120
echo
echo "== preview-terminal-paste outline =="
ast-grep outline src/renderer/src/components/dashboard-popout/preview-terminal-paste.ts --view expanded || true
echo
echo "== relevant preview-terminal-paste lines =="
cat -n src/renderer/src/components/dashboard-popout/preview-terminal-paste.ts | sed -n '1,140p'
echo
echo "== host platform definitions/usages =="
rg -n "hostPlatform|localWindowsConpty|terminalInput|resolveTerminalPasteRuntime|planTerminalPasteWithYield" src/renderer/src -g'*.ts' -g'*.tsx' | sed -n '1,220p'Repository: stablyai/orca
Length of output: 32367
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== resolveTerminalPasteRuntime implementation and tests =="
cat -n src/renderer/src/components/terminal-pane/terminal-paste-runtime.ts | sed -n '1,220p'
echo
cat -n src/renderer/src/components/terminal-pane/terminal-paste-runtime.test.ts | sed -n '1,260p'
echo
echo "== dashboard preview input types and implementation =="
cat -n src/renderer/src/components/dashboard/dashboard-card-terminal-input.ts | sed -n '1,180p'
echo
cat -n src/renderer/src/components/dashboard-popout/preview-terminal-options.ts | sed -n '1,110p'
echo
cat -n src/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.ts | sed -n '1,90p'
echo
echo "== AgentTerminalPreview prop/building lines =="
cat -n src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx | sed -n '200,275p'
echo
echo "== createPreviewClipboardPaster call sites =="
rg -n "createPreviewClipboardPaster|getShortcutPlatform|terminalInput" src/renderer/src/components/dashboard-popout src/renderer/src/components/dashboard -g'*.ts' -g'*.tsx' | sed -n '1,220p'
echo
echo "== local newline policy and chunk behavior references =="
cat -n src/renderer/src/components/terminal-pane/terminal-paste-multiline-policy.test.ts | sed -n '1,100p'
echo
cat -n src/renderer/src/components/terminal-pane/terminal-paste-coordinator.ts | sed -n '100,220p'
cat -n src/renderer/src/components/terminal-pane/terminal-paste-coordinator.ts | sed -n '330,420p'Repository: stablyai/orca
Length of output: 42319
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== paste payload metadata implementation =="
cat -n src/renderer/src/components/terminal-pane/terminal-paste-payload-metadata.ts | sed -n '1,240p'
echo
echo "== terminal paste model =="
cat -n src/renderer/src/components/terminal-pane/terminal-paste-model.ts | sed -n '1,180p'
echo
echo "== execute plan newline/chunk handling =="
cat -n src/renderer/src/components/terminal-pane/terminal-paste-coordinator.ts | sed -n '220,360p'
cat -n src/renderer/src/components/terminal-pane/terminal-paste-chunks.ts | sed -n '1,200p'
cat -n src/renderer/src/components/terminal-pane/terminal-bracketed-paste.ts | sed -n '1,160p'
echo
echo "== parse/apply terminal-paste-plan in pane =="
rg -n "parse.*terminal.*paste|terminal-paste-plan|executeTerminalPastePlan|planTerminalPasteWithYield" src/renderer/src/components/terminal-pane -g'*.ts' -g'*.tsx' | sed -n '1,220p'
echo
echo "== current AgentTerminalPreview paste plugging lines =="
cat -n src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx | sed -n '150,205p'Repository: stablyai/orca
Length of output: 19446
Use the preview terminal’s host context for paste planning.
resolveTerminalPasteRuntime({ platform, ptyId }) currently uses the client OS and omits isWindowsConpty, so a macOS client previewing a Windows/ConPTY pty builds local darwin paste bytes and chunk metadata instead of host-compatible \r line endings. Thread terminalInput into deps and use terminalInput?.hostPlatform ?? getShortcutPlatform() plus terminalInput?.localWindowsConpty.
| state.agentStatusEpoch !== previousState.agentStatusEpoch || | ||
| // Why: each card carries the host-input profile its preview terminal keys | ||
| // against. A stale profile encodes bytes for the wrong host, so the slices | ||
| // that resolve it have to republish too — all are low-frequency except the | ||
| // foreground agent, whose churn the publish throttle already absorbs. | ||
| state.sshConnectionStates !== previousState.sshConnectionStates || | ||
| state.sshStateByEnvironment !== previousState.sshStateByEnvironment || | ||
| state.runtimeStatusByEnvironmentId !== previousState.runtimeStatusByEnvironmentId || | ||
| state.paneForegroundAgentByPaneKey !== previousState.paneForegroundAgentByPaneKey |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Terminal-input state slices aren't fully wired into either recompute/republish trigger, so preview key-encoding facts can go stale.
DashboardCardTerminalInputState was extended with ~12 fields (detectedWorktreesByRepo, folderWorkspaces, projectGroups, sshConnectionStates, sshStateByEnvironment, runtimeStatusByEnvironmentId, restoredRuntimeHostIdByWorkspaceSessionKey, runtimeEnvironments, runtimeEnvironmentCatalogHydrated, removedRuntimeEnvironmentIds, paneForegroundAgentByPaneKey, agentLaunchConfigByPaneKey) that all feed resolveDashboardCardTerminalInput. Only a subset of these are actually treated as "this changed, recompute/republish" triggers in either consumer:
src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts#L32-L40:dashboardSnapshotInputsChangedonly comparessshConnectionStates,sshStateByEnvironment,runtimeStatusByEnvironmentId, andpaneForegroundAgentByPaneKey. Add the remaining fields (at leastagentLaunchConfigByPaneKey, which directly driveswindowsShiftEnterEncoding/kittyKeyboardAdvertised, plusruntimeEnvironments/removedRuntimeEnvironmentIds/restoredRuntimeHostIdByWorkspaceSessionKey) to the comparison so the popout republishes when they change.src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts#L35-L84: the new fields are read via a one-offuseAppStore.getState()call inside theuseMemobody instead of reactive selectors, and none are in the deps array (only the original selector values plusagentStatusEpochare). Either subscribe to each field viauseAppStore((s) => s.x)and add them to deps, or otherwise ensure the memo recomputes when they change.
Without this, a user changing an agent's launch config, an SSH/runtime host reconnecting, or a runtime environment being removed/restored can leave the preview terminal encoding keys (Shift+Enter, kitty keyboard advertisement, ConPTY behavior) for the wrong host until an unrelated tracked field happens to change.
📍 Affects 2 files
src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts#L32-L40(this comment)src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts#L35-L84
react-compiler rejects ref writes in the render pass; every reader is an event handler or a post-await continuation, so a commit-phase sync is equivalent.
Reverting any of them left every suite green: the dialog's terminalInput prop (the only reader of DashboardCard.terminalInput), the drawer's hand-threaded store slices, and the pop-out's republish triggers. Each new assertion was mutation-checked against its source line.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e4503809-8482-4bf8-bac3-6dad012a6a01
📒 Files selected for processing (4)
src/renderer/src/components/dashboard-popout/AgentTerminalDialog.test.tsxsrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsxsrc/renderer/src/components/dashboard/useDashboardPopoutBridge.test.tsxsrc/renderer/src/components/dashboard/useLiveDashboardSnapshot.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
| // Why: each card's preview terminal keys against a host-input profile | ||
| // derived from these. Not republishing leaves the pop-out encoding bytes | ||
| // for the host the pty used to run on. | ||
| const profileInputs: Partial<DashboardSnapshotWatchState>[] = [ | ||
| { sshConnectionStates: new Map() }, | ||
| { sshStateByEnvironment: new Map() }, | ||
| { runtimeStatusByEnvironmentId: new Map() }, | ||
| { paneForegroundAgentByPaneKey: {} } | ||
| ] | ||
| const republished = profileInputs | ||
| .filter((next) => | ||
| dashboardSnapshotInputsChanged({ ...previousState, ...next }, previousState) | ||
| ) | ||
| .map((next) => Object.keys(next)[0]) | ||
| expect(republished).toEqual([ | ||
| 'sshConnectionStates', | ||
| 'sshStateByEnvironment', | ||
| 'runtimeStatusByEnvironmentId', | ||
| 'paneForegroundAgentByPaneKey' | ||
| ]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use meaningful slice updates in the republish test.
Each new Map()/{} is empty and differs only by reference from the seeded value, so this verifies !== rather than a real host-profile change. Populate each slice with a representative changed entry to protect the stale-profile behavior this PR fixes.
| const clientUserAgent = typeof navigator === 'undefined' ? '' : navigator.userAgent | ||
| const clientPlatform = clientUserAgent.includes('Mac') | ||
| ? 'darwin' | ||
| : clientUserAgent.includes('Windows') | ||
| ? 'win32' | ||
| : 'linux' |
There was a problem hiding this comment.
clientPlatform is derived from navigator.userAgent string matching, but the codebase already exposes getShortcutPlatform() (used in preview-terminal-key-handler.ts, preview-terminal-paste.ts, and elsewhere) as the canonical source of process.platform in the renderer. Parsing the UA string is fragile and inconsistent.
| const clientUserAgent = typeof navigator === 'undefined' ? '' : navigator.userAgent | |
| const clientPlatform = clientUserAgent.includes('Mac') | |
| ? 'darwin' | |
| : clientUserAgent.includes('Windows') | |
| ? 'win32' | |
| : 'linux' | |
| const clientUserAgent = typeof navigator === 'undefined' ? '' : navigator.userAgent | |
| const clientPlatform = getShortcutPlatform() | |
| const clientOsRelease = readClientOsRelease() |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Greptile SummaryThis PR fixes the agent preview terminal's keyboard handling by routing it through the same
Confidence Score: 5/5Safe to merge — the feature remains behind the experimentalAgentDashboardPopout flag, and the bug fix path is exercised by 3,262 tests including new A/B proof of the Ctrl+Backspace word-kill. The keyboard fix and host-profile relay are well-contained: the new modules closely mirror existing pane helpers rather than inventing fresh logic, all disposal paths are symmetric, and the IPC validator degrades at card granularity (bad profile drops one card, not the whole board). Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/dashboard-popout/preview-terminal-key-handler.ts | New key handler replacing preview-clipboard-shortcuts.ts; installs full pane policy, correctly disposes all six window-level listeners, and routes bytes through terminal.input for the user-input signal. |
| src/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.ts | Thin adapter that maps PreviewShortcutContext onto resolveTerminalShortcutAction, correctly using hostPlatform for byte-protocol decisions and clientPlatform for xterm's own ConPTY client-side compat parameter. |
| src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx | Restructured to accept terminalInput prop, use layout effects for live ref updates, mirror the kitty tracker, and apply appearance updates without remounting; cleanup paths correctly dispose all new handlers. |
| src/renderer/src/components/dashboard/dashboard-card-terminal-input.ts | New module that resolves the per-card host-input profile using the same pane helpers; degrades gracefully on a partially-hydrated store via withHydratedSlices. |
| src/renderer/src/components/dashboard/dashboard-client-host.ts | Provides client platform/userAgent/osRelease for the snapshot builder; derives platform from UA string matching rather than the canonical getShortcutPlatform() (flagged in a previous review thread). |
| src/renderer/src/components/dashboard/useLiveDashboardSnapshot.ts | Adds reactive subscriptions for all host-resolution slices; agentLaunchConfigByPaneKey remains a non-reactive getState() read, intentionally documented as not affecting routing output. |
| src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts | dashboardSnapshotInputsChanged now triggers on all 11 host-resolution slices so the pop-out republishes when an SSH host or runtime changes. |
| src/renderer/src/components/dashboard-popout/preview-terminal-compatibility.ts | Installs Unicode 11 shim, Windows Ctrl+Alt repair, links, ligatures, wheel multiplier, lazy Arabic shaping, and IME candidate anchor; returns a disposer that cleans up the two IME and Arabic shaping listeners. |
| src/main/ipc/dashboard-payload-validation.ts | Adds isDashboardTerminalInput validation; correctly handles optional osRelease via isOptionalBoundedString, rejects unknown host platforms, and drops only the affected card on failure. |
| src/renderer/src/lib/pane-manager/terminal-ime-candidate-anchor.ts | IME candidate anchor logic extracted from pane-lifecycle.ts into a reusable function; API and behavior identical to the removed inline block. |
| src/renderer/src/components/dashboard-popout/preview-terminal-options.ts | Builds full preview terminal options mirroring pane behavior; vtExtensions.kittyKeyboard correctly withheld when kittyKeyboardAdvertised is false, ConPTY options applied only for local native Windows. |
| src/shared/dashboard-snapshot.ts | Adds DashboardCardTerminalInput type and optional terminalInput field to DashboardCard; type models all five host-input facts with correct optionality. |
Reviews (4): Last reviewed commit: "refactor(dashboard): extract the board's..." | Re-trigger Greptile
…ting The card resolver handed resolveTerminalInputHostPlatform a transport with no getLocalSessionMetadata, so a WSL pty on a Windows client resolved to win32 while its own pane resolves linux — Shift+Enter would then encode CSI-u where the pane sends alt-enter. Mirror the pane transport's own gate.
…ves from The compare set covered 4 of the ~11 slices that decide a card's execution host, so a change to the rest (folder workspaces, project groups, the runtime catalog, detected worktrees) never triggered a publish. On a quiet board there is no later publish to heal from, and the pop-out — which cannot re-derive the profile — keeps encoding bytes for the host the pty used to run on.
…e effect xterm's keydown is a native listener, so React never flushes a passive effect before it. A just-relayed host profile could therefore miss the next keystroke.
The existing A/B passed either way: a lone CSI > u sets the same flags through scan and scanReplay. Redeliver the push across a snapshot and its replay so stack semantics would leave the TUI's single pop on a stale frame.
…t-dashboard-ctrl Resolves three dashboard conflicts against #11042 (agent status search board): - dashboard-payload-validation.ts: keep both validator constant blocks. - build-dashboard-snapshot.ts: intersect main's DashboardCardContextState with this branch's Partial<DashboardCardTerminalInputState>, and gate the card's terminalInput on main's new includeCardDetails so the sidebar's bucket counts do not pay host resolution on every agent-status tick. - useLiveDashboardSnapshot.ts: union main's review/status slices with this branch's host-profile slices.
The in-window drawer read ~12 host slices through getState() while subscribing to none of them, on the premise that agent activity drives the next rebuild. A quiet board has no such rebuild: an SSH handshake completing with every agent idle leaves the preview terminal encoding bytes for the pre-connect host, and agentStatusEpoch only ticks on live status changes so it never heals. Watch the same set useDashboardPopoutBridge republishes on — each writer bails out when nothing changed, so the added deps are far quieter than agentStatusByPaneKey, which already rebuilds this memo on every status ping. The existing coverage mounted a second hook, which always recomputes; the new test re-renders the same hook after changing only sshConnectionStates.
The preview passed 11 of the 12 inputs the pane's policy takes and let the 12th default to orca-first. Under terminal-first a remapped tab.close chord is meant to yield to the shell — Ctrl+W is a word-kill there — but the preview kept claiming it as a pane close and swallowed the bytes.
The count path main added in #11042 renders no cards, so it must not pay a per-pty host resolution on every agent-status tick. Both assertions run against a card that does have a live pty, so only the gate keeps the profile off.
The merge of main's label bounding pushed build-dashboard-snapshot.ts to 302 lines. The client's own platform facts are a distinct concept from the pty host each card keys against, so they move out rather than earn a max-lines bypass.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 78f4982f-00b6-4489-8500-f859e964ec5e
📒 Files selected for processing (6)
src/main/ipc/dashboard-payload-validation.test.tssrc/main/ipc/dashboard-payload-validation.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.test.tssrc/renderer/src/components/dashboard/build-dashboard-snapshot.tssrc/renderer/src/components/dashboard/dashboard-client-host.tssrc/shared/dashboard-snapshot.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/shared/dashboard-snapshot.ts
- src/main/ipc/dashboard-payload-validation.ts
| options: { includeCardDetails?: boolean; includeFilterOptions?: boolean } = {} | ||
| ): DashboardSnapshot { | ||
| const cards: DashboardCard[] = [] | ||
| const clientHost = readDashboardClientHost() |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Defer the client-host probe until a preview needs it.
readDashboardClientHost() runs even for count-only snapshots and boards with no live PTY, including window.api.platform.get(). Lazily read and memoize it inside the ptyId && includeCardDetails path. Based on PR objectives, count-only/no-live-PTY snapshots must avoid this work.
Proposed direction
- const clientHost = readDashboardClientHost()
+ let clientHost: ReturnType<typeof readDashboardClientHost> | undefined
...
- const terminalInput =
- ptyId && includeCardDetails
+ const terminalInput =
+ ptyId && includeCardDetails
? resolveDashboardCardTerminalInput(state, {
+ ...(clientHost ??= readDashboardClientHost()),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const clientHost = readDashboardClientHost() | |
| let clientHost: ReturnType<typeof readDashboardClientHost> | undefined |
stablyai#11015) * fix(dashboard): give the agent preview terminal a real pane's keyboard The dashboard's preview terminal is a bare xterm, not a pane, so it never ran `resolveTerminalShortcutAction` — its only custom key handler covered copy/paste and IME. Ctrl+Backspace therefore fell through to xterm's default `\x08`, which readline binds to backward-delete-char: one character instead of a word. Route the preview's keys through the pane's own shortcut policy, so word and line kills, Option chords, modified Enter, and scrollback chords encode identically. Pane-scoped verdicts (splits, search, focus) are swallowed rather than passed to xterm, which would send e.g. Ctrl+Shift+D as a bare Ctrl+D. The policy needs three things the preview could not see: - kitty-protocol flags — mirrored locally from the same PTY output stream - the PTY's execution host — bytes follow the host, not the client OS, so a new `DashboardCard.terminalInput` profile is derived in the main renderer (the only one holding the store) and relayed to the pop-out - host terminal options — the ConPTY backend and the kitty withhold now apply Also brings the emulator itself up to a pane's: Orca's Unicode 11 width shim (replayed CJK/emoji/ZWJ laid out wrong without it), Windows Ctrl+Alt chord repair, user font/cursor/line-height/word-separator/sensitivity settings, ligatures, the TUI wheel multiplier, lazy Arabic shaping, clickable links, and the IME candidate anchor — extracted from pane-lifecycle so both surfaces share one implementation. The in-window drawer built its snapshot from a slice subset, which would have degraded the new profile to client-OS defaults there; it now reads the full store non-reactively. * fix(dashboard): enumerate pane-scoped chords instead of a default case The switch-exhaustiveness gate rejects a `default` over the shortcut-action union — it would let a newly added action be swallowed silently instead of forcing a decision at the preview's boundary. * fix(dashboard): preserve native shortcuts and PTY host routing * chore: keep merge scope limited to dashboard * perf(dashboard): avoid full-store copies for terminal profiles * fix(dashboard): validate terminal input profiles at IPC boundary * fix(dashboard): sync preview terminal refs on commit, not during render react-compiler rejects ref writes in the render pass; every reader is an event handler or a post-await continuation, so a commit-phase sync is equivalent. * test(dashboard): cover the three seams that relay the host-input profile Reverting any of them left every suite green: the dialog's terminalInput prop (the only reader of DashboardCard.terminalInput), the drawer's hand-threaded store slices, and the pop-out's republish triggers. Each new assertion was mutation-checked against its source line. * fix(dashboard): follow the WSL host for a preview terminal's byte routing The card resolver handed resolveTerminalInputHostPlatform a transport with no getLocalSessionMetadata, so a WSL pty on a Windows client resolved to win32 while its own pane resolves linux — Shift+Enter would then encode CSI-u where the pane sends alt-enter. Mirror the pane transport's own gate. * fix(dashboard): republish on every slice the host-input profile resolves from The compare set covered 4 of the ~11 slices that decide a card's execution host, so a change to the rest (folder workspaces, project groups, the runtime catalog, detected worktrees) never triggered a publish. On a quiet board there is no later publish to heal from, and the pop-out — which cannot re-derive the profile — keeps encoding bytes for the host the pty used to run on. * fix(dashboard): sync preview terminal refs on layout, not on a passive effect xterm's keydown is a native listener, so React never flushes a passive effect before it. A just-relayed host profile could therefore miss the next keystroke. * test(dashboard): pin the preview's replay-vs-live kitty scan The existing A/B passed either way: a lone CSI > u sets the same flags through scan and scanReplay. Redeliver the push across a snapshot and its replay so stack semantics would leave the TUI's single pop on a stale frame. * fix(dashboard): rebuild the drawer's snapshot on every host-input slice The in-window drawer read ~12 host slices through getState() while subscribing to none of them, on the premise that agent activity drives the next rebuild. A quiet board has no such rebuild: an SSH handshake completing with every agent idle leaves the preview terminal encoding bytes for the pre-connect host, and agentStatusEpoch only ticks on live status changes so it never heals. Watch the same set useDashboardPopoutBridge republishes on — each writer bails out when nothing changed, so the added deps are far quieter than agentStatusByPaneKey, which already rebuilds this memo on every status ping. The existing coverage mounted a second hook, which always recomputes; the new test re-renders the same hook after changing only sshConnectionStates. * fix(dashboard): key the preview by the user's terminal shortcut policy The preview passed 11 of the 12 inputs the pane's policy takes and let the 12th default to orca-first. Under terminal-first a remapped tab.close chord is meant to yield to the shell — Ctrl+W is a word-kill there — but the preview kept claiming it as a pane close and swallowed the bytes. * test(dashboard): pin the host-input profile to card snapshots only The count path main added in stablyai#11042 renders no cards, so it must not pay a per-pty host resolution on every agent-status tick. Both assertions run against a card that does have a live pty, so only the gate keeps the profile off. * refactor(dashboard): extract the board's client-host read The merge of main's label bounding pushed build-dashboard-snapshot.ts to 302 lines. The client's own platform facts are a distinct concept from the pty host each card keys against, so they move out rather than earn a max-lines bypass.
The bug
In the Agent Dashboard's terminal, Ctrl+Backspace deleted one character instead of a word.
The dashboard's terminal (
AgentTerminalPreview, used by both the in-window drawer and the pop-out) is a bare xterm, not a pane — and its only custom key handler covered copy/paste and IME.resolveTerminalShortcutActionnever ran there, so Ctrl+Backspace fell through to xterm's default\x08, which readline binds tobackward-delete-char.Since the same gap applied to every other chord, this routes the preview through the pane's own policy rather than patching the one key.
What changed
Keyboard. The preview now runs the pane's
resolveTerminalShortcutAction: word/line kills, Option chords with layout-aware base characters (Dvorak/AZERTY), modified Enter, Cmd+←/→, Cmd+↑/↓ scrollback, input-source switch. Pane-scoped verdicts (splits, search, focus) are swallowed — letting them reach xterm would send e.g. Ctrl+Shift+D to the agent as a bare Ctrl+D. The swallow list enumerates all 13 members ofTerminalShortcutActionwith nodefault:, so the=> booleanreturn type makes a newly added action a build error rather than a silent byte leak.Three inputs the policy needs that the preview couldn't see:
TerminalKittyKeyboardModeTrackerfedscan()/scanReplay()matches the paneDashboardCard.terminalInput, derived in the main renderer (the only one holding the store) and relayed to the pop-out, which has no storeEmulator. Also brought up to a pane's: Orca's Unicode 11 width shim (replayed CJK/emoji/ZWJ laid out wrong without it), Windows Ctrl+Alt chord repair, user font/cursor/line-height/word-separator/scroll-sensitivity settings applied live, ligatures, the TUI wheel multiplier, lazy Arabic shaping, clickable links, and the IME candidate anchor — the last extracted from
pane-lifecycle.tsso both surfaces share one implementation instead of a copy.Fixes added during review
The first pass shipped the keyboard routing but missed several things that review caught. Each is a real defect with a mutation-verified test:
PtyTransportsilently loses capability.resolveTerminalInputHostPlatformonly detects WSL throughtransport.getLocalSessionMetadata(), which the hand-built transport omitted — so the branch was dead and a WSL pty on a Windows client resolvedhostPlatform: 'win32'where its own pane resolves'linux'. Shift+Enter then encoded CSI-u where the pane sends alt-enter. The existing WSL test passed vacuously: it assertedlocalWindowsConpty/kittybut neverhostPlatform.resolveTerminalShortcutActiontakes 12 args; the preview passed 11.terminalShortcutPolicy(fromsettings, not keybindings) silently defaulted toorca-first. Underterminal-first— the documented escape hatch for shells and TUIs — a remappedtab.closechord must reach the shell, and Ctrl+W is a shell word-kill.dashboardSnapshotInputsChangedcovered 4 of ~11 slices feeding the host profile; folder workspaces, project groups, the runtime catalog and detected worktrees were missing, so on a quiet board there was no "next publish" to self-heal from.useLiveDashboardSnapshot(the drawer) had the same staleness class, reading those slices throughgetState()while subscribing to none.useEffect(to satisfy react-compiler) opened a real stale-read window.useLayoutEffectcloses it and makes ordering independent of declaration order.includeCardDetailsopt-out. feat(dashboard): add agent status search board #11042 added a count-only snapshot path (useAgentBucketCounts, recomputed on every agent-status tick); a naive union merge leftterminalInputresolving on it, allocating 3 Maps + a Set per live-pty row for a value the counts discard.boundedLabellines putbuild-dashboard-snapshot.tsat 302 against a 300max-linescap — neither branch alone crossed it, so neither branch's CI could see it, and typecheck plus every test suite were green at 302. Fixed by extractingdashboard-client-host.ts, not a disable or a limit bump.isDashboardSnapshot(all-or-nothing) toadmitDashboardSnapshot(drops only the offending card, and logs). No production change was needed —isDashboardTerminalInputis a conjunct ofisDashboardCard, so it inherited per-card dropping — but the tests only pinnedisDashboardSnapshot, which is now production-dead.Live QA — A/B on a real dev build
Typed through the real xterm via CDP into a live shell behind a dashboard card, then asserted on a file the shell wrote (the WebGL/DOM buffer isn't scrapeable). Same keystrokes both runs:
echo one two three→ Ctrl+Backspace →> /tmp/marker.txt→ Enter.echo one two > …one twoecho one two thre > …one two threThis branch — the whole word is gone:
Negative control (changes stashed) — one character deleted, bug reproduces:
The board the preview opens from:
Re-validated after the review fixes. The A/B above was run on the first version of this branch, so it was re-run against the current tree on an isolated profile:
echo one two three→one two, andecho alpha beta gamma→alpha beta. Both killed the whole word. Because the preview and the pane share one pty — and the pane has always word-killed correctly — the runs were instrumented to rule out a keystroke leak: 2 xterms mounted (pane + preview) with focus confirmed inside the dialog's own helper textarea, which the pane's container-scoped handler ignores.QA scaffolding note: an isolated user-data profile with a scratch repo, and the agent-status entry that puts the card on the board was seeded directly into the store. The keystroke path under test was fully real — CDP keys → xterm → policy → IPC → PTY → shell → file.
Tests and gates
New coverage: policy delegation (host-routed Shift+Enter, ConPTY Ctrl+arrow suppression, kitty gating), the option builder, the card profile resolver (SSH host, ConPTY, the Grok kitty exception, WSL with an explicit
hostPlatformassertion, unhydrated store), preview-level A/B tests proving the kitty tracker flips Option+Backspace handling, a replay-vs-live scan test, the three seams that relay the host-input profile, theincludeCardDetailsgate, the shortcut-policy differential, and per-card drop of an unusable profile.tscclean on node/cli/web;oxlint0 errors;oxfmt --checkclean;check:code-quality:changedreports 0 new findings (react-compiler, type-aware, React Doctor);check:max-lines-ratchetshows no new bypasses. Notelint:switch-exhaustivenessno longer exists — main folded that rule intoaudit:code-quality:type-aware, which is green.AgentTerminalPreview.tsxwas split into paste/compatibility/IME-bridge modules rather than adding amax-linesdisable.Deliberate divergences
Links open in the system browser (the pop-out hosts no in-app browser pane); scrollback stays at 1000 rows since main only ever serializes 24; no search overlay or pane splits in a dialog; DOM renderer, so no WebGL atlas rebuild after a ligature toggle.
The preview calls
resolveTerminalShortcutActiondirectly rather than theresolveTerminalKeyboardShortcutActionwrapper: the wrapper only makes one arg non-optional, and it lives inkeyboard-handlers.ts, which would drag pane-manager and split machinery into the pop-out's separate rollup entry.Known, pre-existing, not fixed here
settingschange tears down and recreates the preview terminal (terminalThemeis a fresh object in the effect deps), reconnecting the PTY. Identical at the merge base; a correct fix means moving theme into the appearance sync.Note for reviewers
The dashboard is behind
experimentalAgentDashboardPopout, so this ships dark until that flag is on.