Repository navigation
Hotfix: mobile terminal attach/detach loop (letterbox dims in identity key) - #92
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… identity key, frozen per attachment (live-topology feedback via agentd pin/release) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe terminal descriptor key now uses session and pane identity only, while tmux letterbox dimensions remain fixed during a session attachment. Wave 6 deployment and agent rollout completion records were added for version v0.4.1. ChangesTerminal stability
Wave 6 records
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx`:
- Around line 96-108: Update the primaryLetterbox useMemo dependencies to
include hostTopology and primarySession, and change the frozenLetterboxRef logic
to replace its cached dims when getLetterboxDimensions returns a valid value
while the current cached dims are undefined. Preserve the attachment key reset
behavior and keep valid dimensions frozen thereafter to avoid attach/detach
loops.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 965112a2-f7be-4609-a570-7369600a0861
📒 Files selected for processing (4)
apps/dashboard/src/components/terminal/terminalHostStore.tsapps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsxtasks/frontend-ux-log.mdtasks/frontend-ux-metrics.jsonl
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx`:
- Around line 96-108: Update the primaryLetterbox useMemo dependencies to
include hostTopology and primarySession, and change the frozenLetterboxRef logic
to replace its cached dims when getLetterboxDimensions returns a valid value
while the current cached dims are undefined. Preserve the attachment key reset
behavior and keep valid dimensions frozen thereafter to avoid attach/detach
loops.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 965112a2-f7be-4609-a570-7369600a0861
📒 Files selected for processing (4)
apps/dashboard/src/components/terminal/terminalHostStore.tsapps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsxtasks/frontend-ux-log.mdtasks/frontend-ux-metrics.jsonl
🛑 Comments failed to post (1)
apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx (1)
96-108: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Prevent letterbox dimensions from permanently freezing at
undefined.If
hostTopologyhas not fully populated when this component first renders (e.g., on initial page load),getLetterboxDimensionswill returnundefined. BecausehostTopologyis excluded from theuseMemodependency array, the dimensions will never re-evaluate when the topology finally arrives over the network. The terminal will remain permanently stuck without its correct layout.To fix this, include
hostTopologyandprimarySessionin the dependencies, and update the logic to latch onto the dimensions only once a valid value is received. This allows the terminal to receive its initial dimensions asynchronously while still freezing them thereafter to prevent the attach/detach loop.🐛 Proposed fix to capture dimensions after topology loads
- const frozenLetterboxRef = useRef<{ key: string; dims: TerminalGridDimensions | undefined } | null>(null); - const primaryLetterbox = useMemo(() => { - const attachmentKey = `${primarySession.id} ${primarySession.tmux_pane_id || ''}`; - if (frozenLetterboxRef.current?.key !== attachmentKey) { - frozenLetterboxRef.current = { - key: attachmentKey, - dims: getLetterboxDimensions(hostTopology, primarySession), - }; - } - return frozenLetterboxRef.current.dims; - // eslint-disable-next-line react-hooks/exhaustive-deps -- topology churn is - // deliberately excluded: dims are frozen per attachment (see comment above). - }, [primarySession.id, primarySession.tmux_pane_id]); + const frozenLetterboxRef = useRef<{ key: string; dims: TerminalGridDimensions | undefined } | null>(null); + const primaryLetterbox = useMemo(() => { + const attachmentKey = `${primarySession.id} ${primarySession.tmux_pane_id || ''}`; + const dims = getLetterboxDimensions(hostTopology, primarySession); + + if ( + frozenLetterboxRef.current?.key !== attachmentKey || + frozenLetterboxRef.current.dims === undefined + ) { + frozenLetterboxRef.current = { + key: attachmentKey, + dims, + }; + } + return frozenLetterboxRef.current.dims; + }, [primarySession.id, primarySession.tmux_pane_id, hostTopology, primarySession]);📝 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 frozenLetterboxRef = useRef<{ key: string; dims: TerminalGridDimensions | undefined } | null>(null); const primaryLetterbox = useMemo(() => { const attachmentKey = `${primarySession.id} ${primarySession.tmux_pane_id || ''}`; const dims = getLetterboxDimensions(hostTopology, primarySession); if ( frozenLetterboxRef.current?.key !== attachmentKey || frozenLetterboxRef.current.dims === undefined ) { frozenLetterboxRef.current = { key: attachmentKey, dims, }; } return frozenLetterboxRef.current.dims; }, [primarySession.id, primarySession.tmux_pane_id, hostTopology, primarySession]);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx` around lines 96 - 108, Update the primaryLetterbox useMemo dependencies to include hostTopology and primarySession, and change the frozenLetterboxRef logic to replace its cached dims when getLetterboxDimensions returns a valid value while the current cached dims are undefined. Preserve the attachment key reset behavior and keep valid dimensions frozen thereafter to avoid attach/detach loops.
Device-checklist finding from the owner's S25 Ultra: opening a terminal loops attach/detach. Root cause: letterbox dims (derived from live topology) were part of the terminal identity key, and agentd's own pin-on-attach/release-on-detach changes those dims — a self-sustaining remount loop, armed whenever a desktop tmux client is attached. Fix: identity key is session+pane only; letterbox dims frozen per attachment. Gate: 21/21 smoke, 27/27 journeys, build, 201 dashboard tests.
🤖 Generated with Claude Code
Summary by CodeRabbit