Files
orca/src/shared/files-runtime-capabilities.ts
T
NeilandClaude 6ddcf1d453 feat(files): save a remote text file larger than one request (#35073)
* feat(files): save a remote text file larger than one request

The editor opened files up to 50 MB from a WSL host or SSH server but refused to save anything
over 720 KB. A staged save sends the content in chunks to a temp the host makes beside the
target, and the commit replaces the target by rename under the same locks and disk
precondition as files.writeIfUnchanged. Bounded per save, connection and host; idle saves are
dropped; a journal lets host start remove temps a crash left. Older hosts keep the refusal.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(files): stage large remote saves privately and commit them with the one-request save

Review of #35073: chunks now go to the profile's private staging folder, the commit
re-authorizes the target and writes it in place through writeLocalTextFileWithDiskPrecondition
(same locks, precondition and inode as a one-request save), ops on a save run one at a time so
an abort or commit never races an append, a closed socket's saves are aborted, and host start
clears the staging folder in the background.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(files): check a staged save's temp size at commit, and stage per process

Review of #35073: the commit refuses a temp whose size on disk isn't the declared total, and each
process stages in its own subfolder; the start sweep removes only its own folder and those whose
owner has exited, so runtimes sharing a profile never wipe each other's saves.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(files): a runtime without staged saves closes a socket cleanly

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-28 09:03:53 -07:00

28 lines
1.2 KiB
TypeScript

import {
FILE_WRITE_DISK_PRECONDITION_RUNTIME_CAPABILITY,
FILE_WRITE_IDENTICAL_RUNTIME_CAPABILITY
} from './file-write-disk-precondition'
import { STAGED_FILE_SAVE_RUNTIME_CAPABILITY } from './staged-file-save'
// Why: older runtimes strip mutation owner fields, so clients must fence writes before RPC.
export const FILE_MUTATION_OWNERSHIP_RUNTIME_CAPABILITY = 'files.mutation-ownership.v1' as const
export const FILE_MUTATION_OWNERSHIP_UPDATE_REQUIRED_MESSAGE =
'Remote file changes require a newer Orca server. Update the HUB and try again.'
// Why: older hosts drop `offset`/`limit` and answer with the whole folder.
export const FILE_READ_DIR_PAGED_RUNTIME_CAPABILITY = 'files.readDir.paged.v1' as const
export const FILE_DOC_PREVIEW_RUNTIME_CAPABILITY = 'files.readDocPreview' as const
export const FILES_RUNTIME_CAPABILITIES = [
'files.pathsExist',
'files.resolve-terminal-path.cross-workspace.v1',
'files.resolve-terminal-path.absolute-files.v1',
FILE_DOC_PREVIEW_RUNTIME_CAPABILITY,
FILE_READ_DIR_PAGED_RUNTIME_CAPABILITY,
FILE_WRITE_DISK_PRECONDITION_RUNTIME_CAPABILITY,
FILE_WRITE_IDENTICAL_RUNTIME_CAPABILITY,
FILE_MUTATION_OWNERSHIP_RUNTIME_CAPABILITY,
STAGED_FILE_SAVE_RUNTIME_CAPABILITY
] as const