Skip to content

Hotfix: mobile terminal attach/detach loop (letterbox dims in identity key) - #92

Merged
cvsloane merged 3 commits into
mainfrom
refactor/frontend-command-center
Jul 21, 2026
Merged

cvsloane merged 3 commits into
mainfrom
refactor/frontend-command-center

Conversation

@cvsloane

@cvsloane cvsloane commented Jul 21, 2026 •

Copy link
Copy Markdown
Owner

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

  • Bug Fixes
    • Improved terminal stability when display or topology dimensions change.
    • Letterbox resizing no longer causes unnecessary terminal descriptor updates.
    • Terminal dimensions now remain consistent throughout a session attachment, reducing visual disruption during layout changes.

cvsloane and others added 3 commits July 20, 2026 23:35
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>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 965112a2-f7be-4609-a570-7369600a0861

📥 Commits

Reviewing files that changed from the base of the PR and between e8b9ce7 and 22c00c9.

📒 Files selected for processing (4)
  • apps/dashboard/src/components/terminal/terminalHostStore.ts
  • apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx
  • tasks/frontend-ux-log.md
  • tasks/frontend-ux-metrics.jsonl

📝 Walkthrough

Walkthrough

The 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.

Changes

Terminal stability

Layer / File(s) Summary
Descriptor and attachment stability
apps/dashboard/src/components/terminal/terminalHostStore.ts, apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx
getTerminalDescriptorKey excludes letterbox dimensions, and primaryLetterbox freezes dimensions per session attachment.

Wave 6 records

Layer / File(s) Summary
Deployment record updates
tasks/frontend-ux-log.md, tasks/frontend-ux-metrics.jsonl
Wave 6 deployment and fleet-wide agentd v0.4.1 rollout completion were recorded.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: removing letterbox dimensions from the terminal identity key to stop the attach/detach loop.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/frontend-command-center

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e8b9ce7 and 22c00c9.

📒 Files selected for processing (4)
  • apps/dashboard/src/components/terminal/terminalHostStore.ts
  • apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx
  • tasks/frontend-ux-log.md
  • tasks/frontend-ux-metrics.jsonl

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e8b9ce7 and 22c00c9.

📒 Files selected for processing (4)
  • apps/dashboard/src/components/terminal/terminalHostStore.ts
  • apps/dashboard/src/components/tmux/TmuxTerminalWorkspace.tsx
  • tasks/frontend-ux-log.md
  • tasks/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 hostTopology has not fully populated when this component first renders (e.g., on initial page load), getLetterboxDimensions will return undefined. Because hostTopology is excluded from the useMemo dependency 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 hostTopology and primarySession in 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.

@cvsloane
cvsloane merged commit fbac2dd into main Jul 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant