Repository navigation
Conversation
There was a problem hiding this comment.
Important
The uncapped-fs.listFiles guard does more than stop old clients: it also breaks current in-tree SSH callers that intentionally omit maxResults. The markdown document panel and the mobile file browser both request full listings over the relay and would now fail with "more than 20000 files" on large remote workspaces. See the inline comment for the specific call sites.
Reviewed changes
- Windows uploads now chunk and stage —
writeBufferViaSystemSshanduploadFileViaSystemSshroute Windows writes throughwriteWindowsBytesViaSystemSsh, splitting every stdin into ≤32 KB chunks and landing multi-chunk creates on a.orca-partialpath published byFile::Move, which is whereexclusiveis now enforced exactly once. - Directory upload reuses the single-file uploader —
uploadDirectoryViaSystemSshWindowsdrops its private chunker and callsuploadFileViaSystemSshper file, gainingO_NOFOLLOW+ ino/dev identity checks it previously lacked. fs.listFilesrefuses a prefix for uncapped callers — a request that names nomaxResultsand hits the 20,001 ceiling throws instead of returning a partial list that older renderers show as complete; the scan stays bounded either way.- Renderer reports truncation from page length —
quick-open-file-list.tsnow setstruncated: files.length >= QUICK_OPEN_LISTING_MAX_RESULTSinstead of hardcodingfalse.
ℹ️ Nitpicks
- The
files.length >= maxResultsboundary over-rejects a workspace with exactlyQUICK_OPEN_LISTING_MAX_RESULTS(20,001) files: the listing is actually complete, yet the request throws and the renderer would reporttruncated: true. This is inherent to cap-based truncation detection, but worth being aware of.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| // compatibility, rule 3). The verdict each caller gets is its own, so coalescing is unaffected. | ||
| // Failing here is the same choice the readdir walker already makes: silent truncation is worse | ||
| // than an explicit error. | ||
| if (requestedMaxResults === undefined && files.length >= maxResults) { |
There was a problem hiding this comment.
This throw also hits current in-tree SSH callers that intentionally omit maxResults and apply their own limits client-side: the markdown document panel (listRuntimeMarkdownDocuments → provider.listFiles(rootPath)) and the mobile file browser (listMobileFiles → listRemoteMobileFiles(..., undefined)), plus fs:listMarkdownDocuments. On a remote workspace with more than 20,000 files those features now fail with this error instead of returning a list, and the markdown panel swallows it into an empty document list. The PR body only accounts for old clients, not these current ones.
Technical details
# Uncapped `fs.listFiles` throw reaches current in-tree SSH callers
## Affected sites
- src/main/runtime/runtime-file-commands-search-runtime-files.ts:81 — `listRuntimeMarkdownDocuments` calls `provider.listFiles(target.worktree.path)` with no `maxResults`
- src/main/ipc/filesystem/filesystem-read-handlers.ts:125 — `fs:listMarkdownDocuments` SSH path calls `provider.listFiles(args.rootPath)` with no `maxResults`
- src/main/runtime/runtime-file-commands-constructor.ts:41 — `listMobileFiles` → `listRemoteMobileFiles(..., undefined)` forwards `maxResults: undefined`
## Required outcome
- These current features must not hard-fail on >20,000-file remote workspaces: pass an explicit cap, or scope the throw to callers that genuinely cannot render truncation.
## Suggested approach (optional)
- Markdown: give `listRuntimeMarkdownDocuments` / `fs:listMarkdownDocuments` an explicit high `maxResults` with graceful degradation, or a dedicated bounded listing.
- Mobile: pass `maxResults: MOBILE_FILE_LIST_LIMIT + 1` from `listMobileFiles` and slice as it already does.There was a problem hiding this comment.
This throw also hits current in-tree SSH callers that intentionally omit
maxResults…runtime-file-commands-search-runtime-files.ts:81,filesystem-read-handlers.ts:125,runtime-file-commands-constructor.ts:41
Confirmed and fixed by removing the throw entirely — not by giving those three callers a budget. Your finding is right, and #17954 (merged today, f737f3499f3) removed the premise underneath it.
What changed on main. The throw existed because the host had to choose between handing a caller an unannounced 20,001-row prefix and refusing. #17954 removed that fork: an oversized fs.listFiles reply is now streamed on the bulk lane via maybeStreamRpcResponse, and its own commit message says the quiet part out loud — "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." So the host no longer needs a default cap at all.
What this branch does now. The rebased, squashed commit:
- drops the unconditional
resolveQuickOpenResultLimit(requestedMaxResults)clamp from fix(relay): signal capacity loss instead of dropping, hanging, or truncating #17870 — which, on top of fix(relay): stream an oversized fs.listFiles reply instead of refusing it #17954, would have re-introduced exactly the silent prefix it set out to fix, for every caller that names no limit; - drops the throw from this PR;
- keeps the half that was always right: the caller names its cap, so a full page reads as truncation. Quick Open now sends
QUICK_OPEN_LISTING_MAX_RESULTSon the Electron IPC hop and the runtime-RPC hop (the optionalmaxResultsfield fix(relay): stream an oversized fs.listFiles reply instead of refusing it #17954 added tofiles.listAllbut nothing sent yet), and the locallistQuickOpenFilespath honours it too.
Your three call sites therefore keep main's behaviour — a full listing, streamed — rather than either a prefix or a hard failure. src/relay/fs-handler-list-files-bounded-response.test.ts is renamed to fs-handler-list-files-result-limit.test.ts and inverted: it now asserts an uncapped request is answered in full and that a named cap is honoured and clamped, so nothing can quietly re-add a host-side default.
Thanks — the call-site list is what made it obvious the throw had no honest caller behind it.
Measured on a real Windows host — the chunking is correctly placed, but the stated mechanism needs correctingThis PR reasoned from the .NET stream contract because no Host: Windows, PowerShell 5.1.26100.9168 — the exact version #16432 concerns. 2 MB streamed through What this changesThis PR argued that because That inference is wrong. What this does not changeThe fix is still correctly placed and should land. Chunking is applied to the ssh upload path, which is exactly where the constraint actually lives. And this measurement independently supports the PR's other correction — that What should change is the narrative: the mechanism is the sshd stdin channel, not Still unmeasuredThe actual ssh-path threshold. awin has no |
Blocker: the throw is reachable from two in-tree, same-version callersIndependent audit flagged this, and I verified the call sites. This PR's repair — throwing instead of silently returning a 20,001-entry prefix — is correct in principle, but two current in-tree callers omit Neither passes an options object at all. On any workspace at or over the scan limit, both now fail where they previously received a (silently truncated) list. That is not an old-client compatibility question — it is this build calling itself. So the Rule 3 repair is right and the ergonomics are wrong: the honest error has no honest caller behind it yet. Either give those two call sites an explicit budget, or give That second option is the one worth taking, and it connects to the design discussion on #17954: the reply is a bare What this PR gets right, for the recordThe audit confirmed the Rule 3 analysis in this PR's favour: #17870 alone silently returns a 20,001-entry prefix when the client asked for no cap, and clients predating Also cleared in the same audit, all safe: |
…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
5358082 to
6c93e03
Compare
Folded into #17870 — this PR can be closedThe two were never separable: #17870 alone arms a 60 s write timeout on an unstaged chunked Windows upload, which converts a hang into a mid-file failure that leaves a truncated artifact under the real remote name. Reproduced by injecting a chunk failure into a 262144 B upload: So both are now one squashed commit on One thing did not survive the rebase, deliberately: the uncapped- Everything else from this PR — the corrected mechanism narrative, |
…ncating (#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.** `#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`).
…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`).

An adversarial review found #17870's Windows third internally inconsistent: it blamed
[Console]::In.ReadToEnd()materializing a giant string, but the construct it chunks —makeWindowsWriteFileCommand— usesOpenStandardInput()+CopyTo, a streaming copy. MeanwhileuploadFileViaSystemSsh, the path that carries the large files, piped whole files into that same command unchunked and untimed.I expected the answer to be "chunking is pure cost, remove it". That was wrong, and the deciding evidence was already in #16432 — #17870 just read it wrong.
Chunking is right, and the large-file path was still wedged
The reporter's table has three rows. The third is the one that matters:
[Console]::In.ReadToEnd()StreamReader(OpenStandardInput())StreamReader(OpenStandardInput())reads the same objectCopyToreads, the same way: a loop ofStream.Readinto a byte buffer.Stream.CopyTois that identical loop with an 81920-byte buffer, minus the text decode. It hangs at 1 MB. There is no property ofCopyTothat escapes a limit an incrementalStream.Readloop on that stream already hits.The same data also refutes #17870's stated mechanism: both measured constructs materialize, yet they diverge at 50 KB and converge at 1 MB. Materialization explains neither, and a 1.9 MB string does not hang .NET. The limit is in the stdin the Windows sshd hands PowerShell — consistent with the threshold moving when
DefaultShellchanges, which an inner script's allocation cannot explain.Stated plainly: this is reasoning, not measurement. No
CopyTo-on-Windows-PowerShell-5.1 number exists — mine or the reporter's.pwsh7.4.2 on Linux confirmed only the structural claim (both expressions are the same stream object) before dying under qemu, and Linux pwsh 7 cannot speak to Windows PowerShell 5.1 + Windows sshd anyway. 32 KB is chosen to sit under the 50 KB the reporter measured a stream reader surviving on the worseDefaultShell. Only a real Windows host settles the actual threshold.Changes
uploadFileViaSystemSshnow chunks on Windows. POSIX keeps its single streamingcat >pipeline, untouched and untimed. The Windows directory upload's separate chunker is deleted and now routes through the same path, which also gains itO_NOFOLLOW+ ino/dev identity verification it never had (it only compared size).<path>.orca-partialand is published byFile::Move. A mid-file failure can no longer leave a truncated artifact under the real name. Single-chunk writes still go straight to the destination, so the common case costs no extra round trip.exclusiveleaking into follow-on chunks — the leak was handled, the design around it was not.exclusivewas smeared onto chunk 0 asCreateNew, so a retry after a mid-file failure met its own leftovers and failed on a file Orca itself wrote.exclusiveis now enforced once, at the rename —File::Movethrows on an existing destination, which is exactly the contract.appendcannot be staged without reading the remote file back, so it still writes straight through.[Console]::In.ReadToEnd()under a 32 KB cap — unjustified, since that is the construct measured wedging at 50 KB with only 9 B known-good. Switched to the stream reader measured surviving 50 KB.Wire compat: a prefix is no longer presented as complete
New host, old client: the old client omits
maxResults, the host truncates at 20,001, and the old renderer hardcodestruncated: false— a partial list shown as complete.Simply not truncating reinstates #12547 (
listFilesWithRgwithmaxResults: undefinedis a genuinely unboundedSet; only a 25 s timeout bounds it). So the scan stays bounded, and a request that named no limit and hits the ceiling now fails with an explicit error rather than returning a prefix. That is the position this codebase already records atfs-list-files-fallback-chain.ts:72— "the readdir walker rejects on cap/deadline instead of returning a partial list (design doc: silent truncation is worse than an explicit error)". Old clients render it through their existing error path.Acknowledged trade: an old client on a 20k–200k-file remote workspace now sees an error where it previously got a large, slow, complete list. Above that it already failed as "Message too large". If you would rather old clients keep working to the transport ceiling, the alternative is a byte-budgeted ceiling (
limitQuickOpenFilesBySerializedBytesalready exists) that errors only where the frame genuinely cannot carry it — more code, non-regressive. Not built; this is a product call.Verification
typecheck:nodeclean;check:code-quality:changed0 new findings across 20 files. Wider sweep:src/main/ssh+ipc/filesystem+ the bounded-response test → 169 files / 2208 passed;src/relay→ 153 files / 1560 passed.Also repaired three pre-existing tests in
ssh-system-fallback.test.tsthat emittedclosesynchronously after the call and raced once the Windows write reads its source asynchronously.What remains unverified
StreamReaderrow. Could be too small (wasted round trips) or, less likely, still too large..orca-partialleftovers are deliberately not swept: they are the failure evidence, a retry truncates them viaFileMode::Create, and the relay install probe is an allow-list plus a completion sentinel, so a stray partial cannot make an incomplete install read complete. WindowsMAX_PATHheadroom for the 13-char suffix on a deeply nested tree is unchecked.tests/e2e/cross-version-wire/does not cover file RPCs, so the new unit tests are the only record.Refs #16432, #12547