Skip to content

fix(updater): list plain SSH terminals on the phone's restart confirm - #52612

Merged
AmoabaKelvin merged 2 commits into
mainfrom
fix/restart-impact-ssh-terminals
Nov 29, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
fix/restart-impact-ssh-terminals

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When a phone updates a desktop's Orca, it first shows what the restart will stop. That list left out plain SSH terminals, which the restart ends and never brings back. Now they're listed by host. The phone also checks the list again the moment you tap Restart, so something opened after you looked at it can't be ended without you seeing it.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​95

What Changed

  • Before:
    • updater.restartImpact named chats and in-process terminals, but not plain SSH terminals. Those are the SSH sessions Orca offers for a host whose server couldn't be set up.
    • Those terminals aren't in terminal.list. Quit's SSH shutdown drain ends them (*plain-ssh → closeAllPlainSshTerminals), and nothing restores them.
    • The phone's "Will restart" list could be empty while a live SSH session was about to end.
    • The phone read the list once when the confirm opened, then restarted without looking again.
  • After:
    • The host reports plainSshTerminals: [{ targetId, label }], read from the same session inventory the shutdown drain closes. That covers sessions that are open and ones still opening.
    • The phone shows one row per SSH host, titled with the saved host name and labelled "SSH terminal", next to the existing chat and terminal rows.
    • When Restart is tapped, the phone reads the list again and compares it with the list on screen at the tap. If something would now stop that wasn't shown, it shows the new list instead of restarting, and the user taps again.

Why

  • Root cause: restartImpact assembled its answer from the chat host's quit rule and the in-process PTY map. It never read the SSH shutdown path, which ends a third kind of session.
  • Why the session module's state: plainSshTerminalTargetIds() reads the same slots map that closeAllPlainSshTerminals clears. The confirm and the drain can't disagree about which sessions end.
  • Why the recheck compares this way:
    • The confirm was a snapshot, and work can start between reading it and tapping Restart.
    • Chats and SSH terminals are compared by identity, because they're shown one by one. In-process terminals are compared by count, because that's how they're shown.
    • A confirm that already said "couldn't check what's running" lets the restart through, since it warned about everything.

Linked Issue

STA-19683. Follow-up to #51246 and #51708.

Visual Proof

No phone capture. The confirm only appears for a host whose update has finished downloading, which a dev build can't reach. The new rows reuse the sheet's existing ListRow pattern (title, subtitle, terminal icon).

Host evidence from a hidden dev build of this branch. The SSH host was a real loopback sshd whose Orca server setup failed, so Orca offered a plain SSH terminal there:

plainSsh.open → {"ok":true,"label":"build-box"}
updater.restartImpact → {"chats":[],"terminalPtyIds":[],"plainSshTerminals":[{"targetId":"ssh-1795980131336-0af7i3","label":"build-box"}]}
plainSsh.close, then updater.restartImpact → {"chats":[],"terminalPtyIds":[],"plainSshTerminals":[]}

On main the field doesn't exist, so the phone listed nothing.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • macOS dev build: a real plain SSH terminal appeared in updater.restartImpact while open and left it once closed.

  • host-orca-restart-impact.test.ts: pins the restart recheck invariant on the real function. A newly opened SSH terminal refuses the restart, and anything already shown lets it through. It fails if SSH terminals are ignored.

  • Checks: pnpm check:changed, tc:node, mobile typecheck and verify:mobile-localization pass. The new string is translated in all 11 locales.

  • Needs a store build: the phone half is in the native app (mobile/src/host-screen), so it reaches users with the next release.

Performance

None, because updater.restartImpact runs only when the confirm opens or Restart is tapped. With no SSH terminal open it reads one empty Map. The phone adds one read per Restart tap, capped at 15 s, and skips it when a restart was already requested.

Risk

Level: Low

  • Riskiest part: the recheck. A wrong comparison could make Restart need a second tap. It can't loop: each refusal needs a new tap, and the next tap compares against the list just shown.
  • Mixed versions:
    • An older host sends no plainSshTerminals, and the phone treats that as none, the same as before.
    • An older phone ignores the extra field.
  • Back out: plain revert.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Other SSH state that quit ends comes back after the restart: port forwards are restored, and SSH workspace terminals reconnect. Plain SSH terminals were the only SSH item with nothing to restore them.
  • SSH host labels already reach paired phones through ssh.listTargetSummaries at the same permission, so this exposes nothing new.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…before a phone restart

Plain SSH terminals aren't in terminal.list and quit's SSH drain ends them,
so updater.restartImpact now names them from the same session inventory the
drain closes. The phone lists them on the update confirm and reads the impact
again when Restart is tapped, showing anything new instead of restarting.
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; the remaining test-coverage finding is non-blocking.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining test-coverage finding is non-blocking.

Findings

  1. P2 Restart action lacks test coverage ▶

Summary

The PR adds plain SSH terminals to the phone’s restart confirmation and checks the impact again when Restart is tapped.

  • Restart confirmations now list plain SSH terminals by host.
  • The phone checks the restart list again when you tap Restart.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[User taps Restart] --> B{Restart already requested?}
  B -->|Yes| C[Wait for host to return]
  B -->|No| D[Read current restart impact]
  D --> E{Covered by accepted warning?}
  E -->|No| F[Show new list and wait for another tap]
  E -->|Yes| G[Request install]
  G --> C
Loading

Reviews (2) · Last reviewed commit: "fix(updater): recheck against the impact..." · Reviewed by Greptile

Comment on lines +20 to +27
it('accepts the restart only when everything that would stop was on the confirm', () => {
const shown = ready({ chats: ['c1'], ssh: ['prod'] })
expect(restartImpactShown(shown, ready({ chats: ['c1'] }))).toBe(true)
expect(restartImpactShown(shown, ready({ chats: ['c1'], ssh: ['prod'] }))).toBe(true)
// A plain SSH terminal opened after the confirm was read must be shown before restarting.
expect(restartImpactShown(shown, ready({ chats: ['c1'], ssh: ['prod', 'staging'] }))).toBe(
false
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Restart action lacks test coverage

This test checks restartImpactShown, but never calls restartHostOrcaUpdate. It would still pass if the restart action ignored false and called updater.install anyway.

Add a test that drives the restart action with a newly opened SSH terminal, checks that install was not called, and checks that the new list was published. A second tap against that list should allow install.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Restart-impact data now includes active plain SSH terminals and their saved labels. The mobile update flow reads this data and checks it against the impact shown when the user tapped. If the current impact was not shown, the flow updates the displayed impact and does not start a new install. The update sheet displays SSH terminal entries alongside chats and in-process terminal PTYs. Locale files add SSH terminal labels.

Merge Risk: Low · up to cbbf6

In a narrow timing case the restart confirmation list can briefly omit an item. Restart remains protected by the recheck on the next tap. Low risk; fix the newest-read check before or soon after merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the phone's update-restart confirm now lists plain SSH terminals. It uses the conventional fix(updater) prefix, is one sentence, and matches the raw summary, which add…
Description check Passed The description follows the template. It has ELI5, What Changed (before and after), Why, Linked Issue (STA-19683, a follow-up to #51246 and #51708), Visual Proof with host evidence and an explanation …
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.
Full details: Title check

Explanation

The title names the main change: the phone's update-restart confirm now lists plain SSH terminals. It uses the conventional fix(updater) prefix, is one sentence, and matches the raw summary, which adds plain SSH terminals to restart-impact rows. Scope is clear.

Full details: Description check

Explanation

The description follows the template. It has ELI5, What Changed (before and after), Why, Linked Issue (STA-19683, a follow-up to #51246 and #51708), Visual Proof with host evidence and an explanation of why no phone capture exists, Testing, Performance, Risk with level and back-out plan, and Notes. The AI Disclosure section is empty, which is acceptable for a maintainer. The Review section is empty. The final pnpm checklist item is unchecked, and the description says these checks passed only in the Testing section. These are minor gaps.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3699be16-d527-41c6-8089-4a6e2ec5a62c
Commits

Reviewing files that changed from the base of the PR and between bf356f4 and cbbf63d.

Files selected for processing: 19

  • mobile/src/host-screen/identity/updates/HostOrcaUpdateSheet.tsx
  • mobile/src/host-screen/identity/updates/host-orca-restart-impact.test.ts
  • mobile/src/host-screen/identity/updates/host-orca-restart-impact.ts
  • mobile/src/host-screen/identity/updates/host-orca-update-operations.ts
  • mobile/src/host-screen/identity/updates/host-orca-update.ts
  • mobile/src/i18n/locales/de.json
  • mobile/src/i18n/locales/en.json
  • mobile/src/i18n/locales/es.json
  • mobile/src/i18n/locales/fr.json
  • mobile/src/i18n/locales/ja.json
  • mobile/src/i18n/locales/ko.json
  • mobile/src/i18n/locales/pt.json
  • mobile/src/i18n/locales/ru.json
  • mobile/src/i18n/locales/tr.json
  • mobile/src/i18n/locales/zh-Hant.json
  • mobile/src/i18n/locales/zh.json
  • src/main/runtime/hosts/management/update-restart-impact.ts
  • src/main/ssh/plain-ssh-terminal/plain-ssh-terminal-sessions.ts
  • src/shared/remote-runtime/host-catalog/remote-server-update.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

// Anything that would now stop and wasn't on the confirm is shown first, never restarted over.
const now = await readHostOrcaRestartImpact(connections, hostId)
if (!restartImpactShown(accepted, now)) {
write(hostId, (update) => ({ ...update, impact: now }), owner)

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.

Minor · Functional Correctness · Quick win

The restart recheck can overwrite a newer impact list with an older one.

The recheck at line 254 writes its result without the newest-read check used by refreshHostOrcaRestartImpact. If a sheet refresh starts during the recheck and its result lands first, a late recheck result that includes an item not in the accepted list replaces the newer list. The re-prompt then omits that item until the next tap.

The restart remains guarded. The next tap rechecks against the list accepted at that tap and re-prompts for any item not shown.

Count rechecks in the same impactReads sequence, and apply the newest-read check to the write at line 254. The write must not replace a newer list, and the update must not leave impact in loading.

@AmoabaKelvin
AmoabaKelvin merged commit a55699c into main Nov 29, 2026
65 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