Skip to content

fix(terminal): keep the host's platform through an unverifiable probe - #21188

Merged
nwparker merged 1 commit into
mainfrom
np/terminal-host-platform-holds-unverifiable
Sep 18, 2026
Merged

nwparker merged 1 commit into
mainfrom
np/terminal-host-platform-holds-unverifiable

Conversation

@nwparker

@nwparker nwparker commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4

Stacked on #20095.

The platform a host runs is a fact about the host. It does not stop being true because the host's last status probe did not come back.

resolveTerminalInputHostPlatform read entry.status?.hostPlatform, which the store nulls for any non-verified probe, and fell through to args.clientPlatform. So a Windows host driven from a macOS client silently began resolving keystrokes and paths with POSIX conventions the moment a probe went unverifiable, and switched back on the next successful one. Two sites, terminal-input-host-platform.ts:75 and :98 — the active-PTY path and the worktree-owner path.

This is the same conversion as the four sibling reads in #20095, using the same shared reader (lastVerifiedRuntimeStatus) introduced in #20085. Governing rule: docs/reference/ssh-execution-boundary.md — loss of contact is never evidence, and it is certainly not evidence that the host changed operating system.

Why this one is worth calling out separately

The other reads in this family degrade an affordance: a button greys out, a row shows the wrong badge, a capability is briefly unavailable. This one changes what the user's input means. Path separators, shell quoting and modifier handling all key off the resolved platform, so the failure is silent and the output is wrong rather than absent.

Verification

  • pnpm test src/renderer/src/components/terminal-pane/terminal-input-host-platform.test.ts — 14 passed (14).
  • Mutation-tested. Reverting the worktree-owner site to ?.status?.hostPlatform fails the new assertion (1 failed | 13 passed (14)); restoring it returns 14 passed (14). The assertion is not inert.
  • The new fixture builds a real RuntimeStatus and a real RuntimeEnvironmentStatus rather than casting a partial, so it cannot drift out of the contract and cannot silently miss a field added later.
  • pnpm tc exit 0, zero error TS.
  • check:code-quality:changed against this PR's base — exit 0, zero findings.

Scope

Two expressions and one test. No new predicate, no new helper, no behaviour change for a host whose probe is verified — lastVerifiedRuntimeStatus returns snapshot.status ?? status, which for a verified entry is the same value it read before.

Stacking

Based on nwparker/status-reads-hold-unverifiable-host (#20095) because it reuses lastVerifiedRuntimeStatus, which arrives in #20085. It is the fifth member of the same family and belongs behind the same atomic unit: #20085 → #20095 → #20096 → #20359.

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

ℹ️ No critical issues — one minor coverage gap inline.

Reviewed changes

  • Host platform held through an unverifiable probe: both kind === 'runtime' reads in resolveTerminalInputHostPlatform now go through lastVerifiedRuntimeStatus(entry)?.hostPlatform instead of entry.status?.hostPlatform, which the store nulls for any non-verified probe. Keeps a Windows host's platform (and thus keystroke quoting / path conventions) from collapsing to the client's OS while contact is lost.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

return (
args.state.runtimeStatusByEnvironmentId.get(runtimeEnvironmentId)?.status?.hostPlatform ??
args.clientPlatform
lastVerifiedRuntimeStatus(args.state.runtimeStatusByEnvironmentId.get(runtimeEnvironmentId))

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.

The new fixture only exercises the worktree-owner site below (line 102), so this active-PTY site has no regression coverage: the existing PTY-owner test uses a snapshotless { status: { hostPlatform } } entry, which the old read handled just as well. A companion case that sets transport.getRuntimeEnvironmentId (or a remote:<env>@@... PTY id) to windows-box with the same unverifiable fixture would pin both sites; mutation-testing only the second leaves this one free to regress silently.

The platform a host runs is a fact about the host, not about whether its last
probe came back. Reading `entry.status` fell through to the client's platform
the moment a probe went unverifiable, so a Windows host driven from a Mac
silently started resolving keystrokes and paths with POSIX conventions
mid-session -- and switched back on the next successful probe.

Same conversion as the four sibling reads, using the same shared reader.
@nwparker
nwparker force-pushed the np/terminal-host-platform-holds-unverifiable branch from 7b4a782 to 034d544 Compare September 17, 2026 09:11
@nwparker
nwparker changed the base branch from nwparker/status-reads-hold-unverifiable-host to main September 17, 2026 09:11
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

resolveTerminalInputHostPlatform now uses lastVerifiedRuntimeStatus in both runtime-environment branches. The client platform remains the fallback. Tests add an unverifiable Windows runtime fixture and verify that a worktree resolves to win32 when the client platform is darwin.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 034d5

The current behavior is not protected against regressions in live runtime terminals when status probes are unavailable. Add the focused live-PTY test before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, motivation, scope, implementation, testing, and linked stacked work. However, it does not follow several required template sections, including ELI5, What Changed, … Add the required template sections and complete them. Include a direct issue-closing reference such as Fixes #...; state N/A with a reason for Visual Proof if no visual change exists; complete the Testing, Agent skill upstream boundary,…
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving the host platform when a probe is unverifiable.
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: Description check

Explanation

The description explains the change, motivation, scope, implementation, testing, and linked stacked work. However, it does not follow several required template sections, including ELI5, What Changed, Why, Linked Issue with a Fixes reference, Visual Proof or an explicit N/A explanation, Review, Notes, and the required checklists.

Resolution

Add the required template sections and complete them. Include a direct issue-closing reference such as Fixes #...; state N/A with a reason for Visual Proof if no visual change exists; complete the Testing, Agent skill upstream boundary, Notes, and Checklist items; and add the required ELI5, What Changed, Why, and Review content.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: bb19fabe-5d43-43a5-9559-1273131c7bff

📥 Commits

Reviewing files that changed from the base of the PR and between 96eb97a and 034d544.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-input-host-platform.test.ts
  • src/renderer/src/components/terminal-pane/terminal-input-host-platform.ts

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

Comment on lines +311 to +337
// A probe that did not come back says nothing about which OS the host runs. Falling through to
// the client's platform re-points every keystroke and every path at the wrong conventions --
// a Windows host driven from a Mac silently starts speaking POSIX mid-session.
it('keeps the Windows host platform while its probe is unverifiable', () => {
const worktreeId = 'repo::C:\\repo'
expect(
resolveTerminalInputHostPlatform({
clientPlatform: 'darwin',
state: state({
repos: [
{
id: 'repo',
path: 'C:\\repo',
displayName: 'repo',
badgeColor: '#000',
addedAt: 0,
executionHostId: 'runtime:windows-box'
}
],
runtimeStatusByEnvironmentId: new Map([['windows-box', unverifiableWindowsHost()]])
}),
worktreeId,
transport: null
})
).toBe('win32')
})

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,140p' src/renderer/src/components/terminal-pane/terminal-input-host-platform.ts
sed -n '1,380p' src/renderer/src/components/terminal-pane/terminal-input-host-platform.test.ts
rg -n "runtimeEnvironmentId|unverifiableWindowsHost|lastVerifiedRuntimeStatus|verification.*unavailable" src/renderer/src/components/terminal-pane/terminal-input-host-platform.test.ts

Repository: stablyai/orca

Length of output: 15279


🏁 Script executed:

set -e
printf '%s\n' '--- helper and direct callers ---'
rg -n -C 5 "function lastVerifiedRuntimeStatus|lastVerifiedRuntimeStatus|resolveTerminalInputHostPlatform" src/renderer/src src/shared
printf '%s\n' '--- candidate test files ---'
rg -l "resolveTerminalInputHostPlatform|unverifiableWindowsHost|verification: 'unavailable'|lastVerifiedRuntimeStatus" src --glob '*.{test,spec}.{ts,tsx,js,jsx}'

Repository: stablyai/orca

Length of output: 46204


Cover the live runtimeEnvironmentId branch. The new test passes transport: null, so it reaches the worktree-owner branch. Existing live-PTY tests provide status.hostPlatform directly and would still pass if the live branch reverted to reading status?.hostPlatform. Add a live PTY case with getRuntimeEnvironmentId() === 'windows-box', lastVerifiedRuntimeStatus containing hostPlatform: 'win32', status: null, and a darwin client. The test must assert win32; otherwise this regression returns darwin and applies the wrong terminal conventions.

@nwparker
nwparker merged commit 355757c into main Sep 18, 2026
1 check passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…stablyai#21188)

The platform a host runs is a fact about the host, not about whether its last
probe came back. Reading `entry.status` fell through to the client's platform
the moment a probe went unverifiable, so a Windows host driven from a Mac
silently started resolving keystrokes and paths with POSIX conventions
mid-session -- and switched back on the next successful probe.

Same conversion as the four sibling reads, using the same shared reader.
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