Skip to content

Improve take back all terminals - #8200

Merged
AmethystLiang merged 1 commit into
mainfrom
improve-take-back-all-terminals
Jul 11, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
improve-take-back-all-terminals

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Describe the user-visible change.

Screenshots

  • Add screenshots or a screen recording for any new or changed UI behavior.
  • If there is no visual change, say No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

AI Review Report

Summarize the code review you ran with your AI coding agent. Include the main risks it checked, what it flagged, and what you changed or verified as a result.
Confirm that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR.

Security Audit

Provide a basic security audit summary from your AI coding agent. Call out any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks that were reviewed, plus any follow-up needed.

Notes

Call out any platform-specific behavior, risks, or follow-up work.

Previously a failed resize during reclaimTerminalForDesktop left the
override/lock in place (#7588 semantics), but for an explicit "take
back all terminals" gesture that could strand banners on background
panes whose resize can't converge. Now the take-back unconditionally
releases the driver and clears any held fit-override via a new
releaseDesktopTakeBack helper, while auto-restore and phone-initiated
paths keep the original keep-lock-on-failure behavior.

Also extract the local mapWithConcurrency helper out of
workspace-cleanup.ts into a shared, tested src/shared/map-with-concurrency.ts
and use it to bound concurrent desktop-fit reclaims in
terminal-fit-restore.ts.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Desktop terminal reclamation now consistently releases the mobile driver lock and fit override, including failed-resize and stale-lock cases, while emitting desktop-fit notifications and resetting display mode. Runtime tests were updated for these outcomes. A shared mapWithConcurrency utility was added with ordered results and bounded worker execution. Terminal fit restoration now limits concurrent restores to eight, and workspace cleanup reuses the shared utility.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only contains template placeholders and lacks the required concrete details for every section. Replace the placeholders with a real summary, screenshots or 'No visual change', testing, AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: improving terminal take-back behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

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
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/main/runtime/mobile-presence-lock.test.ts (1)

634-648: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider asserting desktop-fit event emissions in Scenario 5b for consistency.

Scenarios 4 and 5 both verify desktop-fit events on notifier and listener channels after a failed-resize take-back. Scenario 5b checks the same state invariants (driver, override, mode) but omits the event emission assertions. If the production code is expected to emit desktop-fit in all take-back paths, adding the same event checks here would strengthen the regression coverage.

♻️ Optional: add event assertions to Scenario 5b
 it('failed take-back leaves no stranded override or lock', async () => {
-    const { runtime, setResizeSucceeds } = createRuntime()
+    const { runtime, setResizeSucceeds, fitOverrideEvents } = createRuntime()

     await runtime.handleMobileSubscribe('pty-1', 'phone-A', { cols: 45, rows: 20 })

     setResizeSucceeds(false)
+    const notifierBefore = fitOverrideEvents.length
+    const listenerBefore = listenerEvents.length
     expect(await runtime.reclaimTerminalForDesktop('pty-1')).toBe(true)

     expect(runtime.getDriver('pty-1')).toEqual({ kind: 'desktop' })
     expect(runtime.getTerminalFitOverride('pty-1')).toBeNull()
     expect(runtime.getMobileDisplayMode('pty-1')).toBe('auto')
+    expect(fitOverrideEvents.slice(notifierBefore).some((e) => e.mode === 'desktop-fit')).toBe(true)
+    expect(listenerEvents.slice(listenerBefore).some((e) => e.mode === 'desktop-fit')).toBe(true)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8c3387e4-deae-4d2a-b754-d8b4bf54a9fd

📥 Commits

Reviewing files that changed from the base of the PR and between e2b4bc2 and 61a2f0f.

📒 Files selected for processing (6)
  • src/main/runtime/mobile-presence-lock.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/terminal-pane/terminal-fit-restore.ts
  • src/renderer/src/store/slices/workspace-cleanup.ts
  • src/shared/map-with-concurrency.test.ts
  • src/shared/map-with-concurrency.ts

@AmethystLiang
AmethystLiang merged commit a916a93 into main Jul 11, 2026
3 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ck (stablyai#8200)

Previously a failed resize during reclaimTerminalForDesktop left the
override/lock in place (stablyai#7588 semantics), but for an explicit "take
back all terminals" gesture that could strand banners on background
panes whose resize can't converge. Now the take-back unconditionally
releases the driver and clears any held fit-override via a new
releaseDesktopTakeBack helper, while auto-restore and phone-initiated
paths keep the original keep-lock-on-failure behavior.

Also extract the local mapWithConcurrency helper out of
workspace-cleanup.ts into a shared, tested src/shared/map-with-concurrency.ts
and use it to bound concurrent desktop-fit reclaims in
terminal-fit-restore.ts.
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