Files
archived-orca/src/main/runtime/runtime-file-command-surface.ts
T
NeilandCopilot 2f6601da60 feat(editor): add opt-in format on save (#37716)
* feat(editor): add opt-in format on save

Run project-configured stdin/stdout formatters before guarded saves, with an off-by-default setting, host-aware execution, and safe error fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(settings): localize formatter search terms and placeholder

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test(editor): stub view state in Monaco fakes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(editor): skip SSH formatter guard when no formatter applies

Unconfigured or excluded files in SSH workspaces now save silently instead
of toasting a misleading reconnect error. Configured SSH formatters report
that SSH hosts are not supported yet. Document that include globs skip
dot-prefixed names unless listed explicitly.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-03 01:29:31 -08:00

86 lines
4.0 KiB
TypeScript

import type { RuntimeFileCommands } from './orca-runtime-files'
type RuntimeFileCommandName =
| 'listMobileFiles'
| 'searchMobileFilePaths'
| 'searchQuickOpenFilePaths'
| 'openMobileFile'
| 'openMobileDiff'
| 'readMobileFile'
| 'resolveTerminalPath'
| 'readTerminalArtifactFile'
| 'readTerminalArtifactPreview'
| 'writeTerminalArtifactFile'
| 'revokeTerminalFileGrantsForClient'
| 'readFileExplorerDir'
| 'watchFileExplorer'
| 'readFileExplorerPreview'
| 'readChatImagePreview'
| 'readFileExplorerChunk'
| 'readDocPreviewFile'
| 'readDocPreviewChunk'
| 'writeFileExplorerFile'
| 'formatFileExplorerText'
| 'writeFileExplorerFileBase64'
| 'writeFileExplorerFileBase64Chunk'
| 'createFileExplorerFile'
| 'createFileExplorerDir'
| 'createFileExplorerDirNoClobber'
| 'commitFileExplorerUpload'
| 'replaceFileExplorerFileWithUpload'
| 'renameFileExplorerPath'
| 'copyFileExplorerPath'
| 'deleteFileExplorerPath'
| 'searchRuntimeFiles'
| 'listRuntimeFiles'
| 'listRuntimeMarkdownDocuments'
| 'pathsExistRuntimeFiles'
| 'statRuntimeFile'
| 'stagedFileSaves'
export type RuntimeFileCommandSurface = Pick<RuntimeFileCommands, RuntimeFileCommandName>
export function installRuntimeFileCommandSurface(
target: RuntimeFileCommandSurface,
commands: RuntimeFileCommands
): void {
Object.assign(target, {
listMobileFiles: commands.listMobileFiles.bind(commands),
searchMobileFilePaths: commands.searchMobileFilePaths.bind(commands),
searchQuickOpenFilePaths: commands.searchQuickOpenFilePaths.bind(commands),
openMobileFile: commands.openMobileFile.bind(commands),
openMobileDiff: commands.openMobileDiff.bind(commands),
readMobileFile: commands.readMobileFile.bind(commands),
resolveTerminalPath: commands.resolveTerminalPath.bind(commands),
readTerminalArtifactFile: commands.readTerminalArtifactFile.bind(commands),
readTerminalArtifactPreview: commands.readTerminalArtifactPreview.bind(commands),
writeTerminalArtifactFile: commands.writeTerminalArtifactFile.bind(commands),
revokeTerminalFileGrantsForClient: commands.revokeTerminalFileGrantsForClient.bind(commands),
readFileExplorerDir: commands.readFileExplorerDir.bind(commands),
watchFileExplorer: commands.watchFileExplorer.bind(commands),
readFileExplorerPreview: commands.readFileExplorerPreview.bind(commands),
readChatImagePreview: commands.readChatImagePreview.bind(commands),
readFileExplorerChunk: commands.readFileExplorerChunk.bind(commands),
readDocPreviewFile: commands.readDocPreviewFile.bind(commands),
readDocPreviewChunk: commands.readDocPreviewChunk.bind(commands),
writeFileExplorerFile: commands.writeFileExplorerFile.bind(commands),
formatFileExplorerText: commands.formatFileExplorerText.bind(commands),
writeFileExplorerFileBase64: commands.writeFileExplorerFileBase64.bind(commands),
writeFileExplorerFileBase64Chunk: commands.writeFileExplorerFileBase64Chunk.bind(commands),
createFileExplorerFile: commands.createFileExplorerFile.bind(commands),
createFileExplorerDir: commands.createFileExplorerDir.bind(commands),
createFileExplorerDirNoClobber: commands.createFileExplorerDirNoClobber.bind(commands),
commitFileExplorerUpload: commands.commitFileExplorerUpload.bind(commands),
replaceFileExplorerFileWithUpload: commands.replaceFileExplorerFileWithUpload.bind(commands),
renameFileExplorerPath: commands.renameFileExplorerPath.bind(commands),
copyFileExplorerPath: commands.copyFileExplorerPath.bind(commands),
deleteFileExplorerPath: commands.deleteFileExplorerPath.bind(commands),
searchRuntimeFiles: commands.searchRuntimeFiles.bind(commands),
listRuntimeFiles: commands.listRuntimeFiles.bind(commands),
listRuntimeMarkdownDocuments: commands.listRuntimeMarkdownDocuments.bind(commands),
pathsExistRuntimeFiles: commands.pathsExistRuntimeFiles.bind(commands),
statRuntimeFile: commands.statRuntimeFile.bind(commands),
stagedFileSaves: commands.stagedFileSaves
} satisfies RuntimeFileCommandSurface)
}