Repository navigation
fix(relay): signal capacity loss instead of dropping, hanging, or truncating - #17870
Conversation
There was a problem hiding this comment.
Important
One cross-cutting behavior change to settle before merge: the relay-side fs.listFiles cap is now unconditional, and it silently truncates two fs.listFiles callers that never asked for a bound and have no truncation UI — markdown-document listing. Details below.
Reviewed changes
- Relay workspace snapshot publication —
workspace.changedis now published per client on the producer lane, and a frame that exceeds the per-client producer capacity degrades to a newworkspace.stalecontrol-lane marker instead of a silent drop (workspace-snapshot-publication.ts,workspace-session-handler.ts). - Client stale resync — the client coalesces
workspace.stalemarkers per target and re-reads the snapshot throughworkspace.get, suppressing the authoring client's own echo via session comparison (remote-workspace-stale-resync.ts,remote-workspace.ts). - Marker machinery extraction — the retention/retry state machine is lifted out of the watcher emitter into
relay-client-resync-marker.tsand shared by bothfs.changedandworkspace.stale. fs.listFilesbounding — the relay appliesresolveQuickOpenResultLimit()unconditionally rather than only when the caller remembered to sendmaxResults(fs-handler.ts).- Quick Open truncation flag — the renderer requests the cap explicitly and derives
truncatedfrom a full page instead of hardcodingfalse(quick-open-file-list.ts,runtime-file-search-client.ts). - Windows upload framing — directory uploads split into a batched mkdir pass plus per-file 32 KB stdin writes, and
waitForChannelClosegains an optional timeout applied to every Windows stdin write (system-ssh-file-transfer.ts,system-ssh-file-binary-transfer.ts,system-ssh-operation-lifecycle.ts).
⚠️ The unconditional fs.listFiles cap also truncates markdown-document listing
The relay change is right for Quick Open — but fs.listFiles is a shared listing endpoint, and two callers pass no maxResults and surface no truncation signal. They now silently return only the first 20,001 paths on large repos, where they were previously unbounded.
Technical details
# fs.listFiles cap reaches callers without a truncation signal
## Affected sites
- src/main/ipc/filesystem.ts:826 — `fs:listMarkdownDocuments` calls `provider.listFiles(args.rootPath)` with no `maxResults`.
- src/main/runtime/runtime-file-commands-search-runtime-files.ts:81 — `listRuntimeMarkdownDocuments` calls `provider.listFiles(target.worktree.path)` with no `maxResults`.
- src/relay/fs-handler.ts — now bounds every `fs.listFiles` request at `QUICK_OPEN_LISTING_MAX_RESULTS` regardless of caller.
## Required outcome
- Markdown-document listing must not silently omit documents beyond 20,001 paths, OR the truncation must be visible to the user.
- Quick Open keeps its refine hint; the markdown paths currently have no equivalent signal.
## Suggested approach (optional)
- Have the two markdown callers pass an explicit, larger bound (or a dedicated scan) and/or return a `truncated` flag, or scope the relay default so non-Quick-Open callers can opt into unbounded listing.
## Open questions for the human (optional)
- Is a silently partial markdown-document list acceptable for >20k-file repos, or should these callers be updated in this PR?ℹ️ Nitpicks
quick-open-file-list.ts:271reportstruncated: files.length >= QUICK_OPEN_LISTING_MAX_RESULTS, so a workspace with exactly 20,001 files shows a spurious "more matches available" hint. The PR body describes thelimit + 1/length > limitpattern, but the relay clamps the request at the cap, solimit + 1is not actually used here; the>=check is the only workable heuristic given that clamp — just noting the description/off-by-one mismatch.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
494fa7b to
48a097f
Compare
📝 WalkthroughWalkthroughThe PR adds stale remote workspace resynchronization across the relay and main process. It adds bounded, staged Windows SSH uploads with channel timeouts. It replaces hard-coded quick-open listing limits with shared limit propagation and truncation reporting. New tests cover resynchronization coalescing, relay fallback markers, Windows upload framing and failure modes, and file listing limits. Merge Risk: 🟠 High · up to The PR improves large workspace, file-list, and Windows upload handling, but a failed Windows replacement upload can delete the existing destination before the replacement is published, leaving the file missing. This high-impact data-loss risk, along with staging-file interference, should be fixed or explicitly accepted before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR satisfies [ Full details: Out of Scope Changes checkExplanation The PR includes Quick Open listing changes associated with Full details: Description checkExplanation The description is detailed and covers the ELI5 summary, changes, rationale, linked issues, visual proof, testing, platforms, and residual risks. Some template headings and checklist items are not included explicitly, but the required information is mostly present.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
ℹ️ No code issues in this delta — one commit-message nitpick below.
Reviewed changes
- Rebased the
fs.listFileshandler change onto main's split ofsrc/main/ipc/filesystem.tsintosrc/main/ipc/filesystem/filesystem-search-handlers.ts: themaxResultspass-through tolistQuickOpenFilesmoved with the function and is byte-identical, so no behavior changed.
ℹ️ Nitpicks
- The amended commit message body lost its
#15238/#12547/#16432lead-in lines, leaving sentence fragments in the merged history (e.g. "…silence or with a wait that never ends. stderr line, so the client kept a stale tab/session list…", "and the failing UI is a call site that does not."). Restore those three lines before merge so the permanentgit logentry stays coherent.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Merge blocker: this must not land without #17934 — data-corruption riskIndependent audit found a new unsafe pair. This PR makes a corruption path more reachable than (a) Windows large-file upload writes a truncated prefix under the final name
No staging, no rename. And this PR newly arms a 60s A truncated #17934 is exactly the fix: stage to (b) This PR does not fix the single-file Windows upload it is titled for
So this ships as "stop the Windows upload hanging" while leaving the user-facing upload hanging. #17934 routes it through (c) A TOCTOU check is silently weakened
(d)
|
…ncating Three failures with one shape: a payload past a fixed capacity was met with silence, with a wait that never ends, or with a prefix presented as a whole. **The workspace snapshot was silently dropped.** `workspace.changed` carries the tab/session list, and a snapshot past the producer frame capacity (12288 B on a Node <=21 remote) was dropped with only a relay stderr line, so the client kept a stale list forever. The relay now publishes per client and, for a client whose sink refused the frame, sends a compact `workspace.stale` marker on the control lane; the client re-reads through `workspace.get`, whose lane is budgeted in megabytes rather than in one producer frame. A new JSON-RPC notification rather than a new field on `workspace.changed`: `normalizeSnapshot(undefined, ns)` yields revision 0 and an empty session, so a Rule-1 field would make an old client replace its tab list with nothing — worse than the drop. An old client ignores the unknown method and is exactly where it is today. The marker retention/retry machinery is extracted from the `fs.changed` overflow path and shared by both. **The Windows upload hung, and the fix for it could truncate.** `#16432` was attributed to `[Console]::In.ReadToEnd()` materializing the base64 bundle. That is not what the reporter measured: he also measured `new IO.StreamReader([Console]::OpenStandardInput())` — an incremental reader — hanging at 1 MB. The limit is in the stdin the host hands PowerShell over a non-pty ssh exec, not in the string the script builds. - `uploadFileViaSystemSsh` — the user file-import path — was piping a whole file into one Windows stdin, unchunked and untimed. That is the path large files take; it now chunks into 32 KB writes and bounds each wait. - The Windows directory upload reuses that single-file path rather than repeating a weaker copy of chunk-read + write-buffer; the `ino`/`dev` TOCTOU verification comes with it. - A Windows write needing more than one exec lands on a `.orca-partial` staging path and is published by rename, so a failed chunk cannot leave a truncated artifact under the real name. `exclusive` is enforced once at the rename, not on the first chunk, where a retry met its own leftovers. - The mkdir batch reads stdin through the stream reader the reporter measured surviving 50 KB, not `[Console]::In`, which he measured wedging at that size. - `waitForChannelClose` takes an optional bound. A wedged PowerShell stays alive at idle CPU and never closes, so without one the promise is simply never settled and the caller waits forever with no error to show. **Quick Open showed a prefix as the whole workspace.** The mechanism "a full page means there is more" only works if the caller named the cap, and the failing UI named none — it hardcoded `truncated: false`. Quick Open now names `QUICK_OPEN_LISTING_MAX_RESULTS` on both the Electron IPC hop and the runtime-RPC hop (the field #17954 added to `files.listAll`), and reads a full page as truncation. The local hop honours the cap too, which it previously ignored. Rebase note on `fs.listFiles`: an earlier revision of this work also clamped the host unconditionally, and #17934 escalated an uncapped request to an explicit error. #17954 has since landed and made an oversized reply streamable, which removes the premise — the host no longer has to choose between a prefix and a refusal, so it returns the whole listing when no limit is named and only clamps a limit it was given. Keeping either would have regressed #17954 and hard-failed three in-tree callers that deliberately pass no options (`runtime-file-commands-search-runtime-files.ts:81`, `filesystem-read-handlers.ts:125`, `runtime-file-commands-constructor.ts:41`).
48a097f to
6c93e03
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Removed the relay-side
fs.listFilesdefault cap — the host no longer bounds a caller that omittedmaxResults; it only clamps a named limit viaresolveQuickOpenResultLimit, leaning on the merged #17954 reply streaming. This resolves the prior markdown-document truncation concern. - Staged multi-chunk Windows writes —
writeWindowsBytesViaSystemSshnow lands any write exceeding one stdin chunk on a.orca-partialpath and publishes it withFile::Move, so a mid-file failure no longer leaves a truncated artifact under the real name;exclusiveis enforced once at the rename instead of smeared across the first chunk. - Chunked, bounded single-file Windows uploads —
uploadFileViaSystemSshreuses the chunked writer with the 60swaitForChannelClosetimeout on every write, and directory uploads delegate per file instead of base64-ing the whole bundle. - Mkdir batch reader swap — the directory batch reads stdin via
StreamReaderon[Console]::OpenStandardInput()(the construct the reporter measured surviving 50KB) instead of[Console]::In.ReadToEnd(). - Optional
maxResultsforwarding —listRuntimeFilesforwardsmaxResultsonly when a caller names one, so unnamed callers keep the whole listing rather than an unannounced prefix.
The prior [!IMPORTANT] (unconditional cap truncating markdown listing) is correctly addressed: with #17954 merged, an unbounded listing is streamable, and callers that want a bound state it explicitly.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
src/main/ssh/system-ssh-file-binary-transfer.ts (1)
257-261: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy liftConfirm that per-chunk execs stay multiplexed, or uploads will regress badly.
Each 32 KB chunk now spawns its own
sshexec. A 600 KB artifact becomes about 19 sequential connections, and a 1.9 MB bundle about 60. With ControlMaster multiplexing active, each exec is cheap.getSystemSshBuildArgsFromOperationOptionsstill forwardsdisableControlMasterandsuppressOrcaControlMaster, andexpectOrcaControlMasterArgsinsrc/main/ssh/ssh-system-fallback.test.tsshows that a Windows local client suppresses the Orca ControlMaster args entirely. On those paths every chunk pays a full handshake and authentication round trip.Measure the upload duration on a target without multiplexing. If it regresses, consider one exec per file that reads length-prefixed frames in a PowerShell loop, so the stdin bound is preserved without one connection per chunk.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: ef0b0292-91f0-4f11-a4e9-d54a44cb7fed
📒 Files selected for processing (20)
src/main/ipc/filesystem/filesystem-search-handlers.tssrc/main/ipc/remote-workspace-stale-resync.test.tssrc/main/ipc/remote-workspace-stale-resync.tssrc/main/ipc/remote-workspace.tssrc/main/ssh/ssh-system-fallback.test.tssrc/main/ssh/system-ssh-file-binary-transfer.tssrc/main/ssh/system-ssh-file-transfer.tssrc/main/ssh/system-ssh-operation-lifecycle.tssrc/main/ssh/system-ssh-windows-upload.test.tssrc/relay/fs-handler-list-files-result-limit.test.tssrc/relay/fs-handler.tssrc/relay/relay-client-resync-marker.tssrc/relay/relay-watcher-event-emitter.tssrc/relay/workspace-session-handler.tssrc/relay/workspace-snapshot-publication.test.tssrc/relay/workspace-snapshot-publication.tssrc/renderer/src/components/quick-open-file-list.react.test.tsxsrc/renderer/src/components/quick-open-file-list.tssrc/renderer/src/runtime/runtime-file-search-client.tssrc/shared/remote-workspace-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| void resyncStaleRemoteWorkspace(target, (snapshot) => | ||
| sendRemoteWorkspaceChanged(targetId, snapshot, undefined) | ||
| ) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Pass an onError handler to resyncStaleRemoteWorkspace.
resyncStaleRemoteWorkspace declares onError: (error: unknown) => void = () => {} and catches every error from the workspace.get read. This call site omits the argument, so the default no-op applies. If the re-read fails, the main process emits no renderer event and writes no log. The workspace stays stale with no diagnostic, which is the silent-desync outcome this change replaces.
Log the failure so an operator can distinguish a failed resync from a suppressed echo.
🪵 Proposed fix to report resync failures
void resyncStaleRemoteWorkspace(target, (snapshot) =>
sendRemoteWorkspaceChanged(targetId, snapshot, undefined)
- )
+ , (error) => {
+ console.error(`[remote-workspace] stale resync failed for ${targetId}:`, error)
+ })Use the project logger if this module already has one.
📝 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.
| void resyncStaleRemoteWorkspace(target, (snapshot) => | |
| sendRemoteWorkspaceChanged(targetId, snapshot, undefined) | |
| ) | |
| void resyncStaleRemoteWorkspace(target, (snapshot) => | |
| sendRemoteWorkspaceChanged(targetId, snapshot, undefined) | |
| , (error) => { | |
| console.error(`[remote-workspace] stale resync failed for ${targetId}:`, error) | |
| }) |
| ...(exclusive ? [] : ['[System.IO.File]::Delete($path)']), | ||
| '[System.IO.File]::Move($staging, $path)' |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🌐 Web query:
Windows PowerShell 5.1 .NET Framework System.IO.File Move overwrite overload availability and File.Replace atomic replacement
💡 Result:
In Windows PowerShell 5.1 (which runs on.NET Framework), the System.IO.File.Move method does not support an overwrite overload [1]. The overload accepting a boolean overwrite parameter was introduced later in.NET Core 3.0 and is not available in.NET Framework 4.8 or earlier versions [1][2][3]. Consequently, attempting to move a file to an existing destination path in PowerShell 5.1 will result in an IOException stating that the file already exists [2]. To achieve a file move with overwrite capability in PowerShell 5.1, you can use the Move-Item cmdlet with the -Force parameter [4]. Alternatively, if working directly with.NET objects, a common workaround is to delete the destination file before moving, though this is not atomic [1][5]. Regarding File.Replace, it is a separate method that replaces the contents of a specified file with another, optionally creating a backup [6]. While it is often used as a way to perform a more robust replacement on Windows because it internally calls the native Win32 ReplaceFile API, its atomicity is not formally guaranteed or documented as a strict contractual behavior [7][8]. Although it may behave atomically in many NTFS scenarios—essentially swapping file IDs—developers should not rely on it as a guaranteed transactional operation for critical data integrity, especially across different file systems or in the presence of complex metadata/ACL configurations [7][8]. For strict transactional requirements, Microsoft has historically suggested using TxF (Transactional NTFS), though that technology is deprecated and generally discouraged [7][8].
Citations:
- 1: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.move?view=net-9.0
- 2: https://stackoverflow.com/questions/18659716/system-io-file-move-gives-exception-the-file-exists
- 3: https://stackoverflow.com/questions/5920882/file-move-does-not-work-file-already-exists
- 4: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/move-item?view=powershell-7.6
- 5: GitHub issue 114230 in dotnet/runtime (link omitted to avoid creating a cross-reference)
- 6: https://learn.microsoft.com/en-us/dotnet/api/system.io.file.replace?view=netframework-4.8.1
- 7: https://stackoverflow.com/questions/34667770/c-file-replace-protecting-against-a-crash
- 8: https://stackoverflow.com/questions/34667770/c-sharp-file-replace-protecting-against-a-crash
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- repository convention scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '--- target file outline and changed region ---'
ast-grep outline src/main/ssh/system-ssh-file-binary-transfer.ts
sed -n '270,345p' src/main/ssh/system-ssh-file-binary-transfer.ts
printf '%s\n' '--- direct references to the transfer implementation and PowerShell target ---'
rg -n -F 'system-ssh-file-binary-transfer' src test tests 2>/dev/null || true
rg -n -F 'System.IO.File' src/main/ssh/system-ssh-file-binary-transfer.tsRepository: stablyai/orca
Length of output: 7357
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- applicable repository conventions and learnings ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/repo-wide.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main-ssh.md
printf '%s\n' '--- transfer flow and callers ---'
sed -n '1,285p' src/main/ssh/system-ssh-file-binary-transfer.ts
sed -n '1,180p' src/main/ssh/system-ssh-windows-upload.test.ts
sed -n '1,100p' src/main/ssh/system-ssh-file-transfer.tsRepository: stablyai/orca
Length of output: 22628
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- publish-related tests and command assertions ---'
sed -n '180,420p' src/main/ssh/system-ssh-windows-upload.test.ts
printf '%s\n' '--- exact working-tree change summary ---'
git diff --stat -- src/main/ssh/system-ssh-file-binary-transfer.ts
git diff -- src/main/ssh/system-ssh-file-binary-transfer.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 4638
Use a single-operation replacement for non-exclusive publishes.
When exclusive is false, the code deletes $path before moving $staging. A connection drop or remote process failure between these commands can leave the destination missing while $path.orca-partial remains. Select a replacement primitive supported by the target PowerShell/.NET runtime, including a safe path for an absent destination.
| const entryBytes = Buffer.byteLength(directory) + 4 | ||
| if (batch.length > 0 && batchBytes + entryBytes > WINDOWS_STDIN_WRITE_CHUNK_BYTES) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
The batch size estimate undercounts escaped JSON, so the 32 KB bound can be exceeded.
entryBytes charges Buffer.byteLength(directory) + 4. The serialized form is longer than that. JSON.stringify escapes every backslash as \\, and Windows remote paths carry backslash separators when hostPlatform.pathSeparator is '\\'. A path of N backslash-heavy bytes serializes to close to 2N bytes but is budgeted at N+4.
The comment above createWindowsUploadDirectories states that a pathological tree cannot reach the stdin size that wedges PowerShell. With the current accounting it can: the payload can reach roughly twice the budget while batchBytes still reads as under 32768.
Measure the serialized payload instead of estimating it.
🐛 Proposed fix: budget against the actual JSON length
for (const directory of directories) {
- const entryBytes = Buffer.byteLength(directory) + 4
+ // Budget the serialized form: JSON escapes backslashes, which Windows paths are full of.
+ const entryBytes = Buffer.byteLength(JSON.stringify(directory)) + 1
if (batch.length > 0 && batchBytes + entryBytes > WINDOWS_STDIN_WRITE_CHUNK_BYTES) {
await flush()
}📝 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 entryBytes = Buffer.byteLength(directory) + 4 | |
| if (batch.length > 0 && batchBytes + entryBytes > WINDOWS_STDIN_WRITE_CHUNK_BYTES) { | |
| // Budget the serialized form: JSON escapes backslashes, which Windows paths are full of. | |
| const entryBytes = Buffer.byteLength(JSON.stringify(directory)) + 1 | |
| if (batch.length > 0 && batchBytes + entryBytes > WINDOWS_STDIN_WRITE_CHUNK_BYTES) { |
🧰 Tools
🪛 ast-grep (0.45.2)
[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawn } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(detect-child-process-typescript)
| expect( | ||
| waitForChannelCloseSpy.mock.calls.every((call) => call[2] === WINDOWS_STDIN_WRITE_TIMEOUT_MS) | ||
| ).toBe(true) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
This assertion passes when no wait was recorded at all.
Array.prototype.every returns true for an empty array. If the production code stops calling waitForChannelClose, or the partial mock at lines 28-32 stops intercepting it, waitForChannelCloseSpy.mock.calls is empty and this assertion still passes. The test then reports success for the exact regression it exists to catch.
Assert the call count as well.
💚 Proposed fix: require the spy to have observed the waits
// A wedged PowerShell never closes on its own, so no wait on this path may be unbounded.
+ expect(waitForChannelCloseSpy.mock.calls.length).toBe(writes.length)
expect(
waitForChannelCloseSpy.mock.calls.every((call) => call[2] === WINDOWS_STDIN_WRITE_TIMEOUT_MS)
).toBe(true)| // false unconditionally is what made the truncation silent — the host bounds the scan to | ||
| // the cap it is given, so a full page means there are more paths behind it. | ||
| files, | ||
| truncated: files.length >= QUICK_OPEN_LISTING_MAX_RESULTS |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Carry an explicit truncation signal instead of inferring it from page length.
An exact-cap result is ambiguous. The production code currently reports complete listings as truncated, and the test preserves that behavior.
src/renderer/src/components/quick-open-file-list.ts#L272-L272: consume an explicithasMoreor truncation value from the listing layer, or use a distinct over-fetch sentinel.src/renderer/src/components/quick-open-file-list.react.test.tsx#L220-L221: test both an exact-cap complete listing and a response explicitly marked as truncated.
📍 Affects 2 files
src/renderer/src/components/quick-open-file-list.ts#L272-L272(this comment)src/renderer/src/components/quick-open-file-list.react.test.tsx#L220-L221
…ncating (stablyai#17870) Three failures with one shape: a payload past a fixed capacity was met with silence, with a wait that never ends, or with a prefix presented as a whole. **The workspace snapshot was silently dropped.** `workspace.changed` carries the tab/session list, and a snapshot past the producer frame capacity (12288 B on a Node <=21 remote) was dropped with only a relay stderr line, so the client kept a stale list forever. The relay now publishes per client and, for a client whose sink refused the frame, sends a compact `workspace.stale` marker on the control lane; the client re-reads through `workspace.get`, whose lane is budgeted in megabytes rather than in one producer frame. A new JSON-RPC notification rather than a new field on `workspace.changed`: `normalizeSnapshot(undefined, ns)` yields revision 0 and an empty session, so a Rule-1 field would make an old client replace its tab list with nothing — worse than the drop. An old client ignores the unknown method and is exactly where it is today. The marker retention/retry machinery is extracted from the `fs.changed` overflow path and shared by both. **The Windows upload hung, and the fix for it could truncate.** `stablyai#16432` was attributed to `[Console]::In.ReadToEnd()` materializing the base64 bundle. That is not what the reporter measured: he also measured `new IO.StreamReader([Console]::OpenStandardInput())` — an incremental reader — hanging at 1 MB. The limit is in the stdin the host hands PowerShell over a non-pty ssh exec, not in the string the script builds. - `uploadFileViaSystemSsh` — the user file-import path — was piping a whole file into one Windows stdin, unchunked and untimed. That is the path large files take; it now chunks into 32 KB writes and bounds each wait. - The Windows directory upload reuses that single-file path rather than repeating a weaker copy of chunk-read + write-buffer; the `ino`/`dev` TOCTOU verification comes with it. - A Windows write needing more than one exec lands on a `.orca-partial` staging path and is published by rename, so a failed chunk cannot leave a truncated artifact under the real name. `exclusive` is enforced once at the rename, not on the first chunk, where a retry met its own leftovers. - The mkdir batch reads stdin through the stream reader the reporter measured surviving 50 KB, not `[Console]::In`, which he measured wedging at that size. - `waitForChannelClose` takes an optional bound. A wedged PowerShell stays alive at idle CPU and never closes, so without one the promise is simply never settled and the caller waits forever with no error to show. **Quick Open showed a prefix as the whole workspace.** The mechanism "a full page means there is more" only works if the caller named the cap, and the failing UI named none — it hardcoded `truncated: false`. Quick Open now names `QUICK_OPEN_LISTING_MAX_RESULTS` on both the Electron IPC hop and the runtime-RPC hop (the field stablyai#17954 added to `files.listAll`), and reads a full page as truncation. The local hop honours the cap too, which it previously ignored. Rebase note on `fs.listFiles`: an earlier revision of this work also clamped the host unconditionally, and stablyai#17934 escalated an uncapped request to an explicit error. stablyai#17954 has since landed and made an oversized reply streamable, which removes the premise — the host no longer has to choose between a prefix and a refusal, so it returns the whole listing when no limit is named and only clamps a limit it was given. Keeping either would have regressed stablyai#17954 and hard-failed three in-tree callers that deliberately pass no options (`runtime-file-commands-search-runtime-files.ts:81`, `filesystem-read-handlers.ts:125`, `runtime-file-commands-constructor.ts:41`).

Three failures with one shape: a payload past a fixed capacity was met with silence, with a wait that never ends, or with a prefix presented as a whole.
#15238 — the workspace snapshot was silently dropped
workspace-session-handler.ts:154calleddispatcher.notify(...), which on rejection does nothing butlogDroppedProducerNotification— one stderr line, no client-visible effect. Producer notifications are capped per frame at ¾ of the sink high-water mark (12288 B on a Node ≤21 remote), butDispatcherWriterAdmission.admitapplies no per-frame cap to thecontrol(1 MB) orlegacy-response(2 MB) lanes. A 13.8 KB snapshot was never too big for the link, only for the one lane that broadcasts it unsolicited. So the relay publishes per client and, for a client whose sink refused the frame, sends a compactworkspace.stalemarker on the control lane; the client re-reads throughworkspace.get.Wire compatibility.
relay-handshake.ts:129enforces exact version equality, so a paired client and relay are always the same build — but the failure shape ofhandleRemoteWorkspaceNotification(remote-workspace.ts:141) is identical todecodeTerminalStreamFramereturningnull: an unknown method vanishes silently. Hence:workspace.stalemethod, not a new field onworkspace.changed. The tempting Rule-1 move —workspace.changedwithsnapshotomitted plustruncated: true— is destructive under Rule 3:normalizeSnapshot(undefined, ns)yields revision 0 and an empty session, whichrememberRemoteWorkspaceSnapshotcaches. An old client would replace its tab list with nothing, worse than the drop. A separate method degrades to exactly today's behaviour.{ namespace }only — norevision, nosourceClientId. Markers coalesce per (client, namespace); one naming an author or generation would replay a projection the producer had moved past, re-creating the staleness being fixed.The retention/retry machinery is extracted from the
fs.changedoverflow path intorelay-client-resync-marker.tsrather than duplicated — the watcher emitter sheds ~130 lines and its 28 tests pass unchanged.Fixture is 3 worktrees × 8 tabs ⇒ 13024 B, against the reported 13798 B.
#16432 — the Windows upload hung, and the naive fix could truncate
The issue was attributed to
[Console]::In.ReadToEnd()materializing the base64 bundle. That is not what the reporter measured: he also measurednew IO.StreamReader([Console]::OpenStandardInput())— an incremental reader — hanging at 1 MB. The limit is in the stdin the host hands PowerShell over a non-pty ssh exec, not in the string the script builds. (A later measurement on real Windows PowerShell 5.1 confirmedCopyTomoves 2 MB through a plain pipe in under a second, so the constraint is the sshd exec channel specifically.)uploadFileViaSystemSsh— the user file-import path (ssh-connection.ts:567-587) — was piping a whole file into one Windows stdin, unchunked and untimed. That is the path large files take, and it was untouched by the first half of this work. It now chunks into 32 KB writes, each with a bounded wait.readLocalUploadFile'sisFile && size && ino && devTOCTOU verification comes back with it.${remotePath}.orca-partialand is published by[System.IO.File]::Move, so a failed chunk cannot leave a truncated artifact under the real name.exclusiveis enforced once at the rename, not on the first chunk, where a retry met its own leftovers.[Console]::In, which he measured wedging at that size. Paths only, batched, so a pathological tree cannot walk back into the same size.waitForChannelClosetakes an optional bound. A wedged PowerShell stays alive at idle CPU and never closes, so without one the promise is never settled and the caller waits forever with no error. It settles before closing — closing first made the resultingSIGTERMmask the timeout, the only diagnosis a wedged remote gives.Why the two halves cannot land apart — truncation injected on both
A 262144 B source, upload driven through
uploadDirectoryViaSystemSshagainst a simulated Windows host, failing the 4th chunk write:A truncated
relay.jsis a broken relay that looks installed.#12547 — Quick Open showed a prefix as the whole workspace
quick-open-file-list.ts:265hardcodedtruncated: false. The mechanism "a full page means there is more" only works if the caller named the cap, and this caller named none. Quick Open now sendsQUICK_OPEN_LISTING_MAX_RESULTSon the Electron IPC hop and the runtime-RPC hop (the optionalmaxResultsfield #17954 added tofiles.listAllbut nothing was sending), and reads a full page as truncation — lighting thequickOpen.moreMatchesAvailablestring that already existed, so no catalog change. The locallistQuickOpenFilespath honours the cap too, which it previously ignored.What the rebase dropped, and why
Earlier revisions of this work also clamped the host unconditionally (#17870) and escalated an uncapped request to an explicit error (#17934). #17954 landed today and removed the premise. An oversized
fs.listFilesreply is now streamed on the bulk lane; its commit message states the case directly — "picking a ceiling to refuse at does not fix that, it just moves where it shows up and refuses listings that would have been delivered."Keeping either would have been a regression:
runtime-file-commands-search-runtime-files.ts:81,filesystem-read-handlers.ts:125,runtime-file-commands-constructor.ts:41— so the markdown panel and the mobile file browser break on any large remote workspace. That is this build calling itself.So the host now returns the whole listing when no limit is named and only clamps a limit it was given.
fs-handler-list-files-bounded-response.test.tsis renamedfs-handler-list-files-result-limit.test.tsand inverted: it asserts an uncapped request is answered in full, so nothing can quietly re-add a host-side default.Verification
Rebase check: of the 20 files touched,
mainhad moved three since the merge base —filesystem-search-handlers.ts(inlinedQUICK_OPEN_SSH_LEGACY_RESULT_LIMIT),ssh-system-fallback.test.ts(+3 unclaimed-alias cases from #17946),fs-handler.ts(#17954's streaming). All three verified present in the final file content, not just in the patch. No other file differs frommain;en.jsonis untouched.Residual risk
The 32 KB chunk size is derived from the reporter's measurements, not verified against a real Windows sshd, which is the layer the constraint actually lives in. The 60 s bound makes the failure mode a timeout rather than a hang either way, and staging makes a mid-file failure non-destructive. It adds ~47 round-trips for a 1.5 MB bundle — cheap under ControlMaster, worth watching if deploy latency regresses. The reporter's own preferred fix (bsdtar, in Windows since 10 1803, reusing the POSIX transport and cutting the payload ~4.8×) remains the better long-term answer.
Fixes #15238, #16432
Refs #12547, #17954
Supersedes #17934
ELI5
Three ways a remote connection dropped or hung on a large payload: workspace updates over ~12 KB were silently thrown away, leaving your tab list stale; a big Windows upload hung forever instead of erroring, and the obvious fix for that could leave half a file under the real name; and Quick Open showed you the first 20,001 files as if that were all of them.
User-facing regression risk
.orca-partialfile behind instead of a truncated real one.Visual Proof
N/A — no visual or interaction change. The only user-visible surface is the existing
quickOpen.moreMatchesAvailablehint, which now appears when it should.Testing
pnpm test src/relay src/main/ssh src/main/runtime src/main/ipc)pnpm tc)system-ssh-windows-upload.test.tsagainst a simulated host; no real Windows sshd was available.