Repository navigation
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion and a nitpick, both below.
Reviewed changes
- Inline snapshot grant — a new
inlineDocPreviewOwnerserves self-contained HTML that main already holds; strictly narrower than both filesystem owners and un-mintable from the renderer, with traversal looked up against aMaprather than the filesystem. - One host-side implementation, three transports —
executeOfficeMethodis shared verbatim by the local host, the SSH relay, and the paired runtime; failures cross the boundary as stable codes with reader-facing copy owned by the renderer. - Snapshot + live preview surfaces — render on the owning host, re-render control,
officecli watchwith pushed/api/switchrefresh and a debounced fs subscription, loopback-only ports, and teardown on tab close/reload/disconnect/quit. - Selection → agent handoff and marks — stable
@id=element paths land in the composer withsubmit: false; the marks panel reads the watch process's advisory marks and disappears when no watch holds the document. - Unrenderable-format panel + detect-never-install — first-class panel for
.doc/.xls/.ppt/.odt/.ods/.odpthat never mentionsofficecli; the missing-binary notice names the owning host and types (never executes) the install command. - Agent skills — a Settings action shells out to
officecli skills installwith the catalogue read at runtime; Orca authors no skill content. - Wiring & parity — additive routing arms in
file-preview.ts; relay/runtime method-name and zod-schema parity tests;office.preview.v1capability.
ℹ️ Literal NUL separators make two source files binary to Git
officeSessionKey in src/main/office/office-document-path.ts and recordKey in src/main/office/office-watch-client-ledger.ts use a raw \0 byte as the host/path separator inside a template literal. Git auto-detects both as binary (i/-text w/-text), which is why this PR's own diff renders them as "(binary file or no changes)" — the canonical-path and client-ledger modules are not reviewable at all from the diff, and future edits will hit the same wall (git diff, git blame, and grep all treat them as binary). The separator itself is also redundant: canonicalPath is always absolute, so a plain ${hostKey}${canonicalPath} cannot collide.
Technical details
# Replace the raw NUL separator with a visible one (or a `\u0000` escape)
## Affected sites
- `src/main/office/office-document-path.ts` — `officeSessionKey` returns `${hostKey}\0${canonicalPath}` with a literal NUL byte.
- `src/main/office/office-watch-client-ledger.ts` — `recordKey` returns `${officeHostOwnerKey(owner)}\0${path}` with a literal NUL byte.
## Required outcome
- Both files are text (diffable/`git blame`-able) again, with no behavior change:
either `\u0000` as an escaped separator, or drop the separator entirely since both keys
already terminate in an absolute `/`-prefixed path.
## Open questions for the human
- Was the NUL chosen deliberately as an unpronounceable collision guard, or is it leftover from a
separator that outlived a switch to always-absolute paths?ℹ️ Nitpicks
OFFICE_PREVIEW_UPDATE_REQUIRED_MESSAGE(src/shared/protocol-version.ts:102) is exported but never read — the office path reportsOFFICE_HOST_UPDATE_REQUIREDas a code and lets the renderer supply the sentence. Consider dropping the unused constant.- The
office.preview.v1capability is advertised but never consumed; the actual old-host protection is themethod_not_found→OFFICE_HOST_UPDATE_REQUIREDmapping insrc/main/office/office-host-dispatch.ts, same asdoc-preview-file-reader.ts. The comment insrc/main/runtime/rpc/methods/office.ts("reads the advertised capability up front") overstates a check that doesn't exist — worth rewording to "fails closed onmethod_not_found".
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis change adds first-class Office document support. It defines workspace-relative document contracts and host-aware Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to This large feature adds first-class Office document preview support, and several previously raised concerns (duplicate RPC registration detection, an import cycle, and incorrect pluralization) have been fixed. A few real gaps remain: an invalid workspace path can silently fall back to a default execution context instead of failing loudly, long-running live document watches can grow memory without a total cap, cancelling a WSL-hosted Office operation may not stop the underlying process promptly, and a WSL-hosted document whose rendered output fails to read could appear as a valid but empty preview instead of a clear error. None of these are likely to cause data loss or a broad outage, but they should be addressed before merge to avoid confusing failures for real users. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 41.49% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 188 functions across 83 files. (1 skipped: 1 unsupported.) 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.
Actionable comments posted: 13
🧹 Nitpick comments (4)
src/main/office/office-watch-manager.integration.test.ts (1)
51-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReport a skip instead of a silent pass.
When
officecliis absent, the test returns early and the reporter records a pass. The same happens after thestarted.okguard. Nobody can tell from CI output that the watch lifecycle was never exercised. Use the test context to skip explicitly.♻️ Proposed change
- it('starts, serves, refreshes and stops without leaving a listener', async () => { - if (!installed) { - return - } + it('starts, serves, refreshes and stops without leaving a listener', async (ctx) => { + if (!installed) { + ctx.skip() + return + } const started = await startOfficeWatch(document) expect(started.ok).toBe(true)src/main/office/office-surface-parity.test.ts (1)
18-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePreserve registration cardinality in the parity assertions.
OFFICE_RPC_METHODSandcreateOfficeMethods()currently contain each method once, so this is not a runtime defect.Setequality still hides a future duplicate. Compare sorted arrays to preserve cardinality.Proposed fix
- expect(new Set(registered)).toEqual(new Set(OFFICE_RPC_METHODS)) + expect([...registered].sort()).toEqual([...OFFICE_RPC_METHODS].sort()) ... - expect(new Set(registered)).toEqual(new Set(OFFICE_RPC_METHODS)) + expect([...registered].sort()).toEqual([...OFFICE_RPC_METHODS].sort())src/main/office/office-document-path.test.ts (1)
35-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStrengthen the normalization test.
joinremoves.and..beforecanonicalOfficeDocumentPathreceives the value. Buildnoisyas a literal path so the test coversresolvenormalization. This improves test coverage; current callers already canonicalize paths.♻️ Proposed change
- const noisy = join(directory, '.', 'sub', '..', 'deck.pptx') + const noisy = `${directory}${sep}.${sep}sub${sep}..${sep}deck.pptx`Import
sepfromnode:path.src/main/browser/doc-preview-inline-grant.test.ts (1)
44-51: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd coverage for inline-key normalization.
normalizeInlineKeysupports leading/and\variants, but the inline-grant tests cover onlydocument.html. The preview URL builder and parser already canonicalize these paths, so this adds regression coverage rather than fixing a current production failure.♻️ Proposed additional test
+ it('normalizes slash variants onto the one key', async () => { + const grant = mint() + for (const path of [`/${INLINE_DOC_PREVIEW_ENTRY}`, `\\${INLINE_DOC_PREVIEW_ENTRY}`]) { + const outcome = await readDocPreviewFile(grant, path) + expect(outcome.ok).toBe(true) + } + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: bb12971c-74cc-4821-9bbd-512d86cbfb25
📥 Commits
Reviewing files that changed from the base of the PR and between b94bcdc and f1fc8ebccfa2f9cf37dcd25d01aa98e0aae83a0d.
⛔ Files ignored due to path filters (3)
src/main/office/__fixtures__/sample.docxis excluded by!**/*.docxsrc/main/office/__fixtures__/sample.pptxis excluded by!**/*.pptxsrc/main/office/__fixtures__/sample.xlsxis excluded by!**/*.xlsx
📒 Files selected for processing (88)
src/main/browser/doc-preview-file-reader.tssrc/main/browser/doc-preview-grant-registry.tssrc/main/browser/doc-preview-inline-grant.test.tssrc/main/ipc/doc-preview-grant-ipc.tssrc/main/ipc/office-preview-ipc.tssrc/main/office/__fixtures__/README.mdsrc/main/office/__fixtures__/sample.docmsrc/main/office/office-document-path.test.tssrc/main/office/office-document-path.tssrc/main/office/office-error-codes.test.tssrc/main/office/office-error-codes.tssrc/main/office/office-host-dispatch.test.tssrc/main/office/office-host-dispatch.tssrc/main/office/office-local-execution.tssrc/main/office/office-method-executor.tssrc/main/office/office-probe-service.tssrc/main/office/office-render-service.integration.test.tssrc/main/office/office-render-service.tssrc/main/office/office-selection-service.tssrc/main/office/office-skills-service.test.tssrc/main/office/office-skills-service.tssrc/main/office/office-surface-parity.test.tssrc/main/office/office-watch-client-ledger.tssrc/main/office/office-watch-manager.integration.test.tssrc/main/office/office-watch-manager.tssrc/main/office/office-watch-port.test.tssrc/main/office/office-watch-port.tssrc/main/office/office-watch-refresh.tssrc/main/office/officecli-argv.test.tssrc/main/office/officecli-argv.tssrc/main/office/officecli-invocation.tssrc/main/office/officecli-lane.tssrc/main/office/officecli-resolution.tssrc/main/providers/filesystem-provider-contract.tssrc/main/providers/ssh-filesystem-office.tssrc/main/providers/ssh-filesystem-provider.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/rpc/methods/office.tssrc/main/startup/main-process-ready-foundation.tssrc/main/window/main-window-webview-security.tssrc/preload/api-types.tssrc/preload/api/office-api.tssrc/preload/api/office-bridge.tssrc/preload/index.tssrc/relay/office-handler.tssrc/relay/relay-runtime-services.tssrc/renderer/src/app-shell/use-app-shell-services.tssrc/renderer/src/components/browser-pane/workspace-doc/office-marks-panel.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-missing-binary-notice.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-preview-failure-panel.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-preview-pane.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-preview-refresh-state.test.tssrc/renderer/src/components/browser-pane/workspace-doc/office-preview-refresh-state.tssrc/renderer/src/components/browser-pane/workspace-doc/office-preview-status.tssrc/renderer/src/components/browser-pane/workspace-doc/office-preview-toolbar.tsxsrc/renderer/src/components/browser-pane/workspace-doc/use-office-document-change.tssrc/renderer/src/components/browser-pane/workspace-doc/use-office-probe.tssrc/renderer/src/components/browser-pane/workspace-doc/use-office-snapshot.tssrc/renderer/src/components/browser-pane/workspace-doc/workspace-doc-page-pane.tsxsrc/renderer/src/components/editor/EditorEditFileSurface.tsxsrc/renderer/src/components/editor/editor-office-binary-placeholder.tsxsrc/renderer/src/components/settings/AgentsPane.tsxsrc/renderer/src/components/settings/OfficeSkillsSetting.tsxsrc/renderer/src/components/settings/office-skills-catalog-state.test.tssrc/renderer/src/components/settings/office-skills-catalog-state.tssrc/renderer/src/components/terminal-pane/terminal-file-open-routing.tssrc/renderer/src/hooks/useOfficeLivePreviewSweep.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/file-preview.tssrc/renderer/src/lib/file-type-icon-extension-table.tssrc/renderer/src/lib/office-install-terminal.tssrc/renderer/src/lib/office-live-preview.tssrc/renderer/src/lib/office-live-refresh.tssrc/renderer/src/lib/office-preview-plan.test.tssrc/renderer/src/lib/office-preview-plan.tssrc/renderer/src/lib/office-selection-handoff.tssrc/renderer/src/lib/office-selection-reference.test.tssrc/renderer/src/lib/workspace-doc-page-conversion.tssrc/shared/binary-file-extensions.tssrc/shared/office-file-extensions.test.tssrc/shared/office-file-extensions.tssrc/shared/office-host-owner.tssrc/shared/office-preview-channels.tssrc/shared/office-preview-contracts.tssrc/shared/office-preview-rpc.tssrc/shared/protocol-version.tstests/e2e/helpers/officecli-availability.tstests/e2e/office-document-preview.spec.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| child.stdout?.on('data', (chunk: Buffer) => { | ||
| stdout += chunk.toString('utf8').slice(0, 4_000) | ||
| }) | ||
| child.stderr?.on('data', (chunk: Buffer) => { | ||
| stderr += chunk.toString('utf8').slice(0, 4_000) | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Bound the accumulated stdout and stderr, not each chunk.
slice(0, 4_000) truncates every chunk, but the concatenation is unbounded. On the success path the session keeps the child (Line 109) and these listeners stay attached, so a watch server that logs on each request grows both strings for the whole lifetime of the live preview. Both buffers are only read inside startOnPort (Lines 113-135), so growth after readiness has no consumer.
Cap the total length, and stop collecting once readiness resolves.
🐛 Proposed fix to cap the buffers and detach the listeners
- child.stdout?.on('data', (chunk: Buffer) => {
- stdout += chunk.toString('utf8').slice(0, 4_000)
- })
- child.stderr?.on('data', (chunk: Buffer) => {
- stderr += chunk.toString('utf8').slice(0, 4_000)
- })
+ const MAX_CAPTURED_CHARS = 4_000
+ const onStdout = (chunk: Buffer): void => {
+ stdout = (stdout + chunk.toString('utf8')).slice(0, MAX_CAPTURED_CHARS)
+ }
+ const onStderr = (chunk: Buffer): void => {
+ stderr = (stderr + chunk.toString('utf8')).slice(0, MAX_CAPTURED_CHARS)
+ }
+ child.stdout?.on('data', onStdout)
+ child.stderr?.on('data', onStderr)Then release the listeners after waitForWatchPort resolves:
const readiness = await waitForWatchPort(port, {
intervalMs: OFFICE_WATCH_READY_POLL_INTERVAL_MS,
timeoutMs: OFFICE_WATCH_READY_TIMEOUT_MS,
isAlive: () => !exited
})
+ child.stdout?.off('data', onStdout)
+ child.stderr?.off('data', onStderr)
+ child.stdout?.resume()
+ child.stderr?.resume()
if (readiness === 'ready') {resume() keeps the pipes drained after the listeners are removed, so the child does not block on a full stdout buffer.
| if (lane.kind === 'wsl') { | ||
| const result = await runWslProcess({ | ||
| program: resolved.path, | ||
| args, | ||
| distro: lane.distro, | ||
| loginPath: 'preferred', | ||
| cwd: options.cwd, | ||
| timeoutMs: options.timeoutMs, | ||
| maxOutputBytes: options.maxOutputBytes | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Description: Check runWslProcess option shape and officecli callers that pass an AbortSignal.
set -euo pipefail
fd -t f 'wsl-runner.ts' src | while IFS= read -r file; do
ast-grep outline "$file" --items all
rg -n -C 5 'signal|AbortSignal|RunWslProcessOptions|export (async )?function runWslProcess' "$file"
done
# Callers that hand a signal to runOfficecli.
rg -nP -C 4 'runOfficecli\(' src | rg -n -C 4 'signal'Repository: stablyai/orca
Length of output: 2433
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- officecli invocation ---'
sed -n '1,125p' src/main/office/officecli-invocation.ts
printf '%s\n' '--- WSL runner contract and execution path ---'
sed -n '35,95p' src/main/wsl/wsl-runner.ts
sed -n '185,285p' src/main/wsl/wsl-runner.ts
printf '%s\n' '--- shared process runner signal contract ---'
sed -n '1,220p' src/shared/child-process/run-process.ts
printf '%s\n' '--- WSL option construction and signal references ---'
rg -n -C 4 'runWslProcess\\(|signal:|AbortSignal|timeoutMs' src/main src/shared/child-processRepository: stablyai/orca
Length of output: 19075
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- officecli invocation ---'
sed -n '1,125p' src/main/office/officecli-invocation.ts
printf '%s\n' '--- WSL runner contract and execution path ---'
sed -n '35,95p' src/main/wsl/wsl-runner.ts
sed -n '185,285p' src/main/wsl/wsl-runner.ts
printf '%s\n' '--- shared process runner signal contract ---'
sed -n '1,220p' src/shared/child-process/run-process.ts
printf '%s\n' '--- WSL option construction and signal references ---'
rg -n -C 4 'runWslProcess\(|signal:|AbortSignal|timeoutMs' src/main src/shared/child-processRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,125p' src/main/office/officecli-invocation.ts
sed -n '35,95p' src/main/wsl/wsl-runner.ts
sed -n '185,285p' src/main/wsl/wsl-runner.ts
sed -n '1,220p' src/shared/child-process/run-process.ts
rg -n -C 4 'runWslProcess\(|signal:|AbortSignal|timeoutMs' src/main src/shared/child-processRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- process option contract ---'
sed -n '1,180p' src/shared/child-process/process-spec.ts
printf '%s\n' '--- WSL environment probe contract ---'
rg -n -C 8 'export (async )?function getWslGuestEnvironment|getWslGuestEnvironment\\(' src/main/wsl/wsl-guest-environment.ts src/main/wsl/wsl-runner.tsRepository: stablyai/orca
Length of output: 3415
Propagate AbortSignal through the WSL runner.
ProcessSpec.signal kills the child when aborted, but WslSpec does not expose a signal and runWslProcess omits it from its final runProcess call. An aborted WSL Office call therefore cannot terminate its child and remains subject to timeoutMs. Add signal?: AbortSignal to WslSpec, pass options.signal to runWslProcess, and forward spec.signal to runProcess.
| "installed": "Installed {{count}} skills.", | ||
| "installedPartial": "Installed {{installed}}; {{failed}} could not be installed.", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Handle pluralization for installedPartial independently.
OfficeSkillsSetting reaches this toast when failed > 0 and passes installed and failed, but no count option. A reachable { installed: 1, failed: 1 } result renders Installed 1; 1 could not be installed. Add the missing noun and use plural-aware translations for each count. Do not add only _one/_other variants to the existing key, because i18next cannot select them without count.
| import type { OfficeDocKind } from '../../../shared/office-file-extensions' | ||
| import { resolveOfficePreviewRouting } from '@/lib/office-preview-plan' | ||
|
|
||
| export { convertBrowserPageToWorkspaceDoc } from '@/lib/workspace-doc-page-conversion' |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Break the file-preview.ts ↔ workspace-doc-page-conversion.ts cycle.
file-preview.ts re-exports convertBrowserPageToWorkspaceDoc, while workspace-doc-page-conversion.ts imports openFileInBrowserTab from file-preview.ts. This triggers the configured import/no-cycle warning, and lint runs that configuration with --deny-warnings, so the lint gate can fail. Update all callers and test mocks to import from @/lib/workspace-doc-page-conversion, then remove the re-export.
| export function isValidOfficeDocumentPath(value: unknown): value is string { | ||
| return ( | ||
| typeof value === 'string' && | ||
| value.trim().length > 0 && | ||
| value.length <= MAX_PATH_LENGTH && | ||
| !value.includes('\0') | ||
| ) | ||
| } |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check whether office RPC registrations scope the document path to a worktree root.
set -euo pipefail
fd -t f 'office' src/main/runtime src/relay src/main/providers --exec rg -n -C6 'path|worktree|scope|resolveWithin|isInside|OFFICE_RENDER_METHOD|officeRequest' {}
# Compare with the existing scoped read path for reference.
rg -n -C6 'worktree|scope|isInside|resolveWithin' src/main/browser/doc-preview-file-reader.tsRepository: stablyai/orca
Length of output: 2860
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- shared RPC definitions ---'
cat -n src/shared/office-preview-rpc.ts | sed -n '1,180p'
printf '%s\n' '--- SSH relay ---'
fd -t f -i 'office' src | xargs -r rg -n -C8 'createOfficeMethods|DocumentPath|executeOfficeMethod|officeRequest|dispatchOfficeRequest|OFFICE_RENDER_METHOD'
printf '%s\n' '--- runtime registration and render implementation ---'
rg -n -C10 'createOfficeMethods|office.preview|renderOfficeLocally|renderOffice|officecli|DocumentPath|isValidOfficeDocumentPath|resolveWithin|worktree' src/main src/relay src/sharedRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- Office-related files ---'
git ls-files | rg '(^|/)(office|.*office.*)\.(ts|tsx)$'
printf '%s\n' '--- Office path validators and executors ---'
rg -l 'DocumentPath|isValidOfficeDocumentPath|renderOfficeLocally|executeOfficeMethod' src --glob '*.ts' --glob '*.tsx' |
while IFS= read -r file; do
echo "### $file"
rg -n -C5 'DocumentPath|isValidOfficeDocumentPath|renderOfficeLocally|executeOfficeMethod|officeRequest|createOfficeMethods' "$file"
doneRepository: stablyai/orca
Length of output: 28095
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- canonical path handling ---'
cat -n src/main/office/office-document-path.ts
printf '%s\n' '--- local execution and lane resolution ---'
cat -n src/main/office/office-local-execution.ts | sed -n '1,180p'
rg -n -C8 'function resolveOfficeLaneTarget|resolveOfficeLaneTarget|type OfficecliLane|NATIVE_OFFICECLI_LANE|resolve.*Path|worktree|root' src/main/office src/main/providers/ssh-filesystem-office.ts
printf '%s\n' '--- scoped file-read implementation ---'
rg -n -C8 'canonical.*Path|resolveWithin|isInside|worktree|files.read|doc-preview-file-reader' src/main src/shared --glob '*.ts'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
cat -n src/main/office/office-document-path.ts
printf '%s\n' '---'
cat -n src/main/office/office-local-execution.ts | sed -n '1,180p'
printf '%s\n' '---'
cat -n src/main/office/officecli-lane.ts
printf '%s\n' '---'
cat -n src/main/providers/ssh-filesystem-office.tsRepository: stablyai/orca
Length of output: 11751
Path Traversal
Exploitability: Difficult
CWE: CWE-22 — Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Bind Office paths to the owning worktree before execution.
canonicalOfficeDocumentPath only requires an absolute, existing path and resolves symlinks. It does not enforce a permitted root. The local, SSH, and runtime paths then pass the canonical path to officecli, so a caller can request Office files outside the worktree and receive their preview or extracted data. Add a host-side root-boundary check after canonicalisation.
|
Too many files changed for review (104 files, 100 file limit). Bypass the limit by tagging |
|
Thanks both — all of it acted on in 45897ba, plus something neither review caught. The repo's own gate was failing. @pullfrog — the NUL separator: confirmed, and worse than a nitpick. Byte-inspected: one Both nitpicks were right too: the unused @coderabbitai — one correction and one partial disagreement. Path traversal (CWE-22, Major): the severity is overstated, but the fix was worth doing and I did it. A paired client can already call Import cycle: the cycle is real and I broke it — 6 production callers plus 2 test mocks now import from Everything else landed as suggested: the accumulated (not per-chunk) stdout/stderr cap with the listeners detached and the pipes resumed once readiness settles; One I did not take: Verified: |
There was a problem hiding this comment.
Important
The workspace-boundary refactor is clean and addresses every prior finding, but the stopOfficeWatch fallback now breaks watch teardown on Windows (see the inline comment). Fixing it is a one-line change.
Reviewed changes
- Bound Office methods to a
(workspaceRoot, relativePath)pair — the bare absolutepathparam became a root-plus-relative pair across the IPC shape, the shared RPC contracts, the local/SSH/paired host implementations, and every renderer call site, with a host-sideresolveOfficeDocumentTargetthat joins, canonicalises (symlinks included, plus a WSLreadlink -flane) and proves containment before any spawn. - Replaced the NUL-byte session separators —
officeSessionKeyandrecordKeyare now JSON tuples, restoring both modules to diffable text; the inline-grant slash-normalisation test and the parity assertions (sorted arrays instead of sets) were added alongside. - Made the integration test skip explicitly (
ctx.skip()) and broadenedsupportsWatchdetection (^[ \t]+watch\b); the E2E binary probe now runsofficecli --versionrather than only statting it. - Gated the Live toggle on a real probe answer —
useOfficeProbegained anansweredflag so an absent binary no longer masquerades as a missing one for the first frames, and "too old to watch" is surfaced separately from failure. - Keyed the live-preview sweep on the converted page id —
findLivePageIdties teardown to the freshly minted live page, so Back-to-document retires the watch instead of keying on the surviving workspace row. - Polish — plural-aware mark and skills copy,
aria-pressedon the skills toggle, "Reveal in folder" hidden on remote hosts, and the misleadingoffice.preview.v1comment plus the unusedOFFICE_PREVIEW_UPDATE_REQUIRED_MESSAGEremoved.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
Every prior finding except one landed cleanly in 45897baa70 and I found no new defects in the delta. The one that remains open — a hardcoded / in the stopOfficeWatch fallback key — is a genuine, still-unfixed leak on native Windows, so I am not approving until it is resolved.
⚠️ Windows stop fallback rebuilds the session key with a hardcoded /
stopOfficeWatch falls back to canonicalPath = \${ref.workspaceRoot}/${ref.relativePath}` when the document no longer canonicalises. On native Windows the key recorded at start (resolveOfficeDocumentTarget→realpath) spells the path with backslashes (c:\repo\a\b.docx), while this fallback produces the mixed c:\repo/a\b.docx. officeSessionKeylowercases both but the separators still differ, sosessions.get(...)misses, theunwatchcall goes out with a spelling the server never saw, and the process-tree kill that owns the child never runs — leaking theofficecli watchprocess and its loopback port until app quit. The fix is to rebuild the fallback withjoinOfficeRelativePath(ref.workspaceRoot, ref.relativePath)(which selects the lane's separator) rather than the manual/join; the symlinked-path case stays unrecoverable by any lexical join, andstopAllOfficeWatches` remains the quit-time backstop.
Reviewed changes
- Bound every document to a workspace — every office method now names
(workspaceRoot, relativePath)instead of a bare absolute path; the host joins and canonicalises both halves and enforcesisPathInsideOrEqual, with a newOFFICE_DOCUMENT_OUTSIDE_WORKSPACEcode and boundary tests that pin the symlink escape. - Restored two modules to text —
officeSessionKeyandrecordKeynow buildJSON.stringify([...])tuples instead of a raw NUL separator, sooffice-document-path.tsandoffice-watch-client-ledger.tsdiff normally again. - Made the method executor exhaustive —
executeOfficeMethodis one switch with nodefault, so an unhandledOFFICE_RPC_METHODSentry is a compile error; the copy tables enumerate every error code for the same reason. - Re-keyed live-preview teardown — the sweep watches the converted live page's fresh id rather than the workspace row, so Back-to-document retires the watch.
- Hardened the probe — an
answeredflag stops the Live toggle blaming a present binary during first render, andsupportsWatchnow matches any indentation. - Polished surface copy —
_one/_otherplural keys,aria-pressedon skill toggles, "Reveal in folder" hidden on remote hosts, the unused constant dropped, and theoffice.preview.v1comment rewritten to match the code.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
@pullfrog — confirmed, fixed in a343908, and the finding turned up a second bug underneath it. Your finding is real. I fixed the class rather than the instance. Your suggested one-liner is right about the cause but incomplete: The second bug. Normalising by the path's shape rather than by Both are pinned in Verified: On your open question from the first review, now that both are settled: the NUL was a deliberate collision guard, not a leftover — a separator has to be a byte neither half can contain. Dropping it entirely ( |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/office/office-render-service.ts (1)
95-95: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReject failed WSL output reads.
Line 95 returns
read.stdouteven whencatexits non-zero. The precedingwcresult is also unchecked. Ifofficecliexits successfully but does not createdocument.html, WSL returns empty stdout and this function reports{ ok: true, html: '' }instead of a render failure.Check both process exit codes and throw or return
OFFICECLI_RENDER_FAILEDwhen either read command fails. Add a WSL test where the render command succeeds without creating the output file.src/main/office/office-watch-manager.ts (1)
96-100: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winBound the watch output buffers.
startOnPortkeeps stdout and stderr listeners attached to the long-livedofficeclichild. Each listener appends up to 4,000 characters from every chunk, but neither accumulated string has a total cap. A noisy live preview can therefore grow main-process memory until the watch stops. Keep draining both streams, but bound each accumulated buffer at this capture site.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 149c0543-4a9a-46cb-a97e-38e7947c1eb1
📥 Commits
Reviewing files that changed from the base of the PR and between f1fc8ebccfa2f9cf37dcd25d01aa98e0aae83a0d and 45897baa70ff7b80028dd1cfe1c22993236dd050.
📒 Files selected for processing (48)
src/main/browser/doc-preview-inline-grant.test.tssrc/main/ipc/office-preview-ipc.tssrc/main/office/office-document-boundary.test.tssrc/main/office/office-document-path.tssrc/main/office/office-host-dispatch.test.tssrc/main/office/office-host-dispatch.tssrc/main/office/office-local-execution.tssrc/main/office/office-method-executor.tssrc/main/office/office-probe-service.tssrc/main/office/office-render-service.integration.test.tssrc/main/office/office-render-service.tssrc/main/office/office-selection-service.tssrc/main/office/office-surface-parity.test.tssrc/main/office/office-watch-client-ledger.tssrc/main/office/office-watch-manager.integration.test.tssrc/main/office/office-watch-manager.tssrc/main/office/office-watch-refresh.tssrc/main/runtime/rpc/methods/office.tssrc/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.tsxsrc/renderer/src/components/browser-pane/assemble-chrome/browser-page-toolbar.tsxsrc/renderer/src/components/browser-pane/navigate/workspace-doc-address-submission.tssrc/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.tsxsrc/renderer/src/components/browser-pane/workspace-doc/doc-preview-address-edit.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-marks-panel.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-preview-pane.tsxsrc/renderer/src/components/browser-pane/workspace-doc/office-preview-status.tssrc/renderer/src/components/browser-pane/workspace-doc/office-preview-toolbar.tsxsrc/renderer/src/components/browser-pane/workspace-doc/use-office-document-change.tssrc/renderer/src/components/browser-pane/workspace-doc/use-office-probe.tssrc/renderer/src/components/browser-pane/workspace-doc/use-office-snapshot.tssrc/renderer/src/components/settings/OfficeSkillsSetting.tsxsrc/renderer/src/components/settings/office-skills-install-copy.test.tssrc/renderer/src/components/settings/office-skills-install-copy.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/browser-page-conversion-history.test.tssrc/renderer/src/lib/browser-page-conversion-history.tssrc/renderer/src/lib/file-preview.test.tssrc/renderer/src/lib/file-preview.tssrc/renderer/src/lib/office-live-preview.tssrc/renderer/src/lib/office-live-refresh.tssrc/renderer/src/lib/office-preview-plan.tssrc/renderer/src/lib/office-selection-handoff.tssrc/shared/office-host-owner.tssrc/shared/office-preview-channels.tssrc/shared/office-preview-contracts.tssrc/shared/office-preview-rpc.tssrc/shared/protocol-version.tstests/e2e/helpers/officecli-availability.ts
💤 Files with no reviewable changes (4)
- src/shared/protocol-version.ts
- src/main/office/office-watch-client-ledger.ts
- src/main/office/office-document-path.ts
- src/renderer/src/lib/file-preview.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/renderer/src/components/browser-pane/workspace-doc/office-marks-panel.tsx
- src/renderer/src/components/settings/OfficeSkillsSetting.tsx
- tests/e2e/helpers/officecli-availability.ts
- src/main/office/office-host-dispatch.ts
- src/main/office/office-render-service.integration.test.ts
- src/main/office/office-watch-refresh.ts
- src/renderer/src/components/browser-pane/workspace-doc/office-preview-toolbar.tsx
- src/renderer/src/i18n/locales/en.json
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Tip For best results, initiate chat on the files or code changes.
I agree that the original CWE-22 severity overstated the impact in this trust model. The canonicalized I also agree with leaving The exhaustive gate fixes, text-safe JSON tuple keys, corrected capability description, and reported test results address the review items. 🐇✅ ✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Keyed watch sessions on a normalised path —
officeSessionKeynow routes both producers throughnormalizeRuntimePathForComparison, so therealpathspelling (C:\repo\docs\a.docx) and the delete-fallback join can no longer disagree by separator;stopOfficeWatchalso falls back throughjoinOfficeRelativePath, which fixes the string handed toofficecli unwatchtoo, not just the registry lookup. - Folded case by the path's shape, not the host platform — the WSL lane's guest path stays case-sensitive, so
/home/me/Repo/a.docxand/home/me/repo/a.docxremain two documents on ext4 instead of sharing one watch and showing the wrong document. - Pinned both in
office-document-path.test.ts— separator and case assertions plus a WSL case-sensitivity assertion, with the honest caveat documented that the case half of the separator test is what proves the shape-driven fold off Windows.
The prior finding is resolved, and the NUL-separator question is settled: it was a deliberate collision guard, and the JSON tuple keeps that injectivity in text.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Normalised the watch-session key —
officeSessionKeynow runs the canonical path throughnormalizeRuntimePathForComparison(the same basisisPathInsideOrEqualuses), so the two key producers —realpathat start and the lexical-join fallback at stop — can no longer disagree on separator spelling, closing the native-Windows watch leak flagged last review. - Rebuilt the stop fallback with the lane-aware join —
stopOfficeWatchnow usesjoinOfficeRelativePathinstead of a hardcoded/, so the fallback string works as both the registry lookup and theofficecli unwatchargument on Windows. - Fixed a latent WSL case-folding bug — case-folding now follows the path's shape rather than
process.platform, so a WSL lane on a Windows host no longer merges/home/me/Repoand/home/me/repointo one session. - Pinned both halves with tests — new
officeSessionKeycases prove Windows separators and case fold regardless of host platform, and that a WSL guest path stays case-sensitive.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
@coderabbitai — all four taken, in 240cf8d. They were written against Stop pending watch startups. Confirmed:
RPC boundary validation. Confirmed exactly as described — zod accepted Symlink test on Windows. Taken, Verified: Two earlier items from your first pass I should close out explicitly, since they were about code that has since been rewritten: the |
|
Tip For best results, initiate chat on the files or code changes.
The four findings are addressed.
Leaving 🐇✅ 🧠 Learnings usedYou are interacting with an AI system. |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor observation about an in-flight race the new stop-path wait still does not fully cover, inline.
Reviewed changes
- Collapsed
./..injoinOfficeRelativePath— the shared join now runs the result through the lane-flavouredpath.normalize, so a caller that cannot canonicalise (the stop path, once the document is deleted) can still test containment lexically withoutrealpath. - Applied the boundary on the way out —
stopOfficeWatch's deleted-document fallback now rejects a traversal relative path (OFFICE_DOCUMENT_OUTSIDE_WORKSPACE) instead of handing it toofficecli unwatch, usingisPathInsideOrEqualon the collapsed join. - Waited for an in-flight start before reading the session registry —
stopOfficeWatchawaits the start promise for its key, closing the "reader clicks Live, then closes the tab inside the readiness budget" leak. - Refined the paired-runtime schemas through the shared predicates —
WorkspaceRootandRelativePathnow.refineonisValidOfficeDocumentPath/isValidOfficeRelativePath, so a whitespace-only or NUL-carrying root no longer reads as absent and silently probes the default lane. - Adjusted tests — the symlink-escape boundary case skips on Windows (needs elevation/Developer Mode), and new tests pin traversal collapse plus stopping a watch whose start is still in flight.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Renders .docx/.xlsx/.pptx on the host that owns the document, through officecli, and shows the result in the existing document-preview partition. Adds a live-preview toggle, selection handoff to the agent composer, and a Settings action that installs officecli's own agent skills. One host-side implementation is shared by the local host, the SSH relay and paired runtimes, so a refusal cannot be named three different things depending on where the document lives. Failures cross the boundary as stable codes; the renderer owns every reader-facing sentence. Snapshots ride a new `inline` preview-grant owner that reads no filesystem at all — strictly narrower than both existing owners, and it keeps rendered output out of the reader's worktree and git status.
Addresses the PR review, plus the repo's own changed-files quality gate, which was failing with seven findings CI would have caught. Documents are now named as (workspace root, path relative to it) — the shape every runtime `files.*` method already uses. The host joins the two, canonicalises both, and refuses anything landing outside the root, so the check survives a symlink that a lexical test would miss. office was the only surface taking a bare absolute path; it no longer is. Two path modules carried a literal NUL byte as a key separator, which made Git treat them as binary — the canonicalisation and client-ledger modules were unreviewable in the diff. Both now build the key from a JSON tuple, which is collision-proof without the exotic byte. Also: the Live toggle now really is gated on the host's `watch` support (the earlier edit silently no-op'd and typecheck cannot see that); the watch is torn down when the reader leaves the live page rather than only when the tab closes; "Reveal in folder" hides on remote hosts instead of quietly opening the system app; watch stdout/stderr are bounded in total rather than per chunk; and counted strings use the repo's `_one`/`_other` plural convention.
The stop path falls back to a lexical join when the document has been deleted since the watch started, and that join spelled a Windows path with a stray forward slash — `C:\repo/a.docx` against the all-backslash spelling realpath recorded at start. The lookup missed, so the watch process and its loopback port leaked until app quit. Rather than fix the one producer, the key itself now normalises through `normalizeRuntimePathForComparison` — the same basis `isPathInsideOrEqual` already uses — so the two producers cannot disagree by separator at all. The fallback also uses the lane's own join, because that string is handed to `officecli unwatch` as well as being the registry key. That normaliser also folds case by the path's shape instead of this process's platform, which fixes a second, latent bug: a WSL lane on a Windows host hands back a guest path on a case-sensitive filesystem, and the old `process.platform === 'win32'` lowercase merged `/home/me/Repo` and `/home/me/repo` into one session — showing the wrong document.
Four findings from the CodeRabbit pass on 45897ba, all still present. `stopOfficeWatch` never consulted `starting`, so a stop issued while a watch was still coming up found no session, returned ok, and the child registered a moment later kept its process and loopback port for the rest of the run. Readiness is bounded at 15s and so is the wait, so the stop now awaits an in-flight start before looking the session up. The delete-fallback also handed its lexically joined path to `officecli unwatch` without re-testing the boundary, so a traversal relative path reached the tool after every other method had refused it. It is checked lexically now — which needed `joinOfficeRelativePath` to collapse `..` first, because `isPathInsideOrEqual` folds separators and case but does not resolve traversal, and the check would otherwise have passed `/w/repo/../../elsewhere/x.docx` as inside `/w/repo`. Also: the runtime schemas refine through the shared predicates, so a whitespace-only or NUL-carrying `workspaceRoot` is an RPC validation error instead of quietly reading as absent and selecting the default lane; and the symlink boundary test skips on Windows, where creating one needs elevation, as `worktree-trash.test.ts` already does.
Rebasing onto main landed two contracts the office surface predates: RPC methods now bind a shared params schema the generated catalog indexes by identity, and changed files may not use type assertions. - Move the office param schemas to src/shared/rpc-contract/office-params.ts and register OFFICE_METHODS as plain defineMethod declarations, so the catalog and the params-parity gate see each method's literal name. - Replace the unknown-params casts with record guards; the two remaining casts are wire replies and carry a SAFETY rationale.
240cf8d to
b8ee4bf
Compare
There was a problem hiding this comment.
ℹ️ No new issues — this delta is a type-safety and RPC params catalog cleanup, verified against the type-parity gate and the targeted tests.
Reviewed changes
Reviewed the delta fc51d75c82..b8ee4bf0e0 (commit b8ee4bf0e0, "follow main's RPC params catalog and casting rule"); all earlier commits were covered by prior pullfrog reviews.
- Moved the paired-runtime params schemas into the shared contract —
src/main/runtime/rpc/methods/office.tsnow bindsOfficeDocumentParams/OfficeElementParams/OfficeOptionalDocumentParams/OfficeProbeParams/OfficeSkillInstallParamsfrom the newsrc/shared/rpc-contract/office-params.ts, so the RPC params type-parity gate (which only catalogs schemas reachable fromsrc/shared) sees the office methods instead of treating them as uncatalogued. - Regenerated the RPC params catalog —
rpc-params-catalog.generated.tsgains the elevenoffice.*entries;pnpm run generate:rpc-params-catalog --checkis clean. - Turned
createOfficeMethods()into the exported constOFFICE_METHODS— consumed bymethods/index.tsand the surface-parity test, which is what lets the generator resolve each method'sparamsschema by identity. - Replaced type assertions with unknown-safe narrowing —
isRecord/fieldhelpers inoffice-preview-ipc.ts,office-method-executor.ts,office-selection-service.ts,office-host-owner.tsandoffice-preview-rpc.ts;'html' in outcomeinoffice-host-dispatch.ts;.find/.some/Setin place ofascasts; documentedSAFETY:exemptions where a cast remains.
Verified locally: pnpm tc:node, pnpm tc:web, the catalog drift check, and the six targeted office/shared test files (40 tests) all pass.
The one open pullfrog thread from review 5159695954 (the stopOfficeWatch in-flight-start race) is untouched by this commit and remains open as a non-blocking observation; it is not re-raised here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: fc9e6d63-e2f4-4d1f-8a5d-8042b385e311
📥 Commits
Reviewing files that changed from the base of the PR and between 240cf8daf167ac869a1ec4406e613d2241ad1ce7 and b8ee4bf.
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (23)
src/main/ipc/office-preview-ipc.tssrc/main/office/office-document-boundary.test.tssrc/main/office/office-host-dispatch.tssrc/main/office/office-method-executor.tssrc/main/office/office-selection-service.tssrc/main/office/office-surface-parity.test.tssrc/main/providers/filesystem-provider-contract.tssrc/main/providers/ssh-filesystem-office.tssrc/main/providers/ssh-filesystem-provider.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/rpc/methods/office.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/browser-pane/workspace-doc/office-preview-status.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/office-preview-plan.test.tssrc/shared/office-file-extensions.test.tssrc/shared/office-host-owner.tssrc/shared/office-preview-contracts.tssrc/shared/office-preview-rpc.tssrc/shared/protocol-version.tssrc/shared/rpc-contract/office-params.tstests/e2e/office-document-preview.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/i18n/locales/en.json
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…op race Three findings from the PR review bots, all reproducible: - An invalid `workspaceRoot` read as absent, and absent means "this host's default lane". Only the paired-runtime path has a zod schema; the local IPC and SSH relay paths hand params straight to the executor, so a skills install for a WSL workspace could land in the native lane and report success. `readOfficeWorkspaceRoot` now answers three states and both paths refuse the unusable one. - `stopOfficeWatch` waited on `starting`, which is keyed on the canonical path and therefore empty until the start's `realpath` resolves. A stop that canonicalised first left the child running. The start now claims a lexical intent key before its first await, and the stop waits on that. - The e2e spec left report.docx and legacy.doc in the worker-scoped seeded repo; both are now removed after Electron shuts down.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta b8ee4bf0e0..9f1e5610d4 (commit 9f1e5610d4); the six underlying commits were covered by prior pullfrog reviews. This delta closes both open threads from the last review: the stopOfficeWatch in-flight-start race and the absent-vs-unusable workspace-root ambiguity.
- Made an unusable workspace root a typed refusal — the new
readOfficeWorkspaceRootreadsworkspaceRootas three states ({}absent means the host's default lane,{ workspaceRoot }valid,nullsupplied-but-unusable); the IPC layer and the method executor now refuse a whitespace-only, NUL-carrying or non-string root withOFFICECLI_FILE_NOT_FOUNDinstead of silently probing or installing skills into the native lane. - Closed the start/stop race —
startOfficeWatchnow claims a lexicalstartingIntentskey synchronously, before its first await, andstopOfficeWatchawaits that key before its ownresolveOfficeDocumentTarget. A stop that wins therealpathrace can no longer miss a later-registering child and leak its process and loopback port. - Tidied the E2E fixtures — the seeded
.docx/.docare now removed throughregisterPostElectronShutdownCleanup, so the worker-scoped repo is not left dirty for later tests.
Verification: pnpm tc:node clean; oxlint clean on the eight changed files; office-document-boundary, office-surface-parity, office-document-path and office-file-extensions pass; office-watch-manager.integration passes with 2 skips (no officecli on this runner, so the new race test does not execute here).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Today a
.docx,.xlsxor.pptxin a workspace is a dead end — the editor says "Binary file — cannot display" and that is the whole story. This makes Orca render those documents so you can actually read them in a tab, keeps the render current while an agent edits the file, lets you point at a slide and hand that selection to the agent, and adds one Settings action that installsofficecli's own Office skills for your agents. The rendering is done byofficecli, which Orca detects but never installs for you.What Changed
Snapshot preview. Opening an Office document renders it on the host that owns it —
officecli view <f> html— and shows the result in the existingorca-preview://partition, under the same strict CSP a workspace HTML document gets. Nothing about that partition is relaxed. The routing arm is added togetWorkspaceFilePreviewPlan, so the file tree, terminal file links and the editor's binary placeholder all inherit it.A new
inlinepreview-grant owner. The obvious design — write the rendered HTML somewhere and point a grant at it — does not fit: aruntimegrant reads through the worktree-scopedfiles.readRPC, so the output would have to land inside the reader's worktree and show up in theirgit status. Since the snapshot is exactly one self-contained file,office:openSnapshotrenders on the host, mints aninlinegrant over the bytes in main, and answers a URL. That owner reads no filesystem on any machine, so it is strictly narrower than both existing owners; the renderer never holds document bytes, anddoc-preview-grant-ipcrefuses to mint one from the renderer at all.One host-side implementation, three transports.
executeOfficeMethodis shared verbatim by this client'slocalhost,src/relay/office-handler.ts(SSH) andsrc/main/runtime/rpc/methods/office.ts(paired). A refusal therefore cannot be named three different things depending on where the document lives — pinned byoffice-surface-parity.test.ts. Failures cross the boundary as stable codes (OFFICECLI_NOT_FOUND,OFFICECLI_UNSUPPORTED_FORMAT,OFFICE_RENDER_TOO_LARGE, …); every reader-facing sentence lives in the renderer.A format we cannot render says so itself.
.doc,.xls,.ppt,.odt,.ods,.odpget a first-class panel that names the format and offers the system app. It never mentionsofficecli, because the tool was not the problem and offering an install would send the reader to fix something that is already fine..csvis deliberately untouched — Orca's CSV viewer owns it andofficeclirejects it.Detect, never install. When the owning host has no binary, the notice names that host (on a remote workspace the reader's own machine is the wrong place to look), shows the platform-correct install command as selectable text, and offers Run in terminal — which opens a terminal on that host with the command typed and not executed. That is the whole install mechanism. It keeps Orca from originating a
powershell.exeinvocation against a downloaded script, the patterndocs/reference/windows-edr-posture.mdrecords as producing Defender incidents.Live preview. The Live toggle starts
officecli watchon the owning host and converts the page tohttp://127.0.0.1:<port>through the same door the address bar uses, so Back crosses back to the document. No new transport: a local workspace loads it directly, an SSH workspace's pages already mount on a proxy-verified partition routed through the target, and a paired workspace's page is bound to its runtime.officecli watchdoes not detect external edits, so refresh is pushed viaPOST /api/switchfrom a subscriber that outlives the pane.Selection and marks.
officeclireturns selected elements as stable@id=paths that survive edits; Use selection puts a compact reference into the agent composer withsubmit: false— the reader pointed at something, they have not yet said what to do with it. The marks panel lists, jumps to and clears the watch process's advisory marks, and disappears entirely when no watch process holds the document, because marks are process state and an empty list would read as "no annotations".Agent skills. One Settings action next to the existing agent controls, reading the catalogue from
officecli skills listrather than hardcoding it, and reporting per (skill, agent) pair. No Orca-authored Office skill, no MCP registration.Contract findings that changed the design
Verified against
officecli 1.0.148on macOS:view … htmlrenders a genuine.docm(macro content type,vbaProject.binpart and relationship) byte-for-byte like its.docxtwin, and the tool's own unsupported-type message names all three. Onlycreaterefuses them, and Orca never callscreate.src/main/office/__fixtures__/sample.docmholds the verdict in place./api/switchtakesfile, notpath—pathanswers400 missing required field: file.unwatchmatches the spellingwatchwas given. A watch started from a relative path cannot be stopped by an absolute one; unwatch answers "No watch running" and the server keeps listening. Canonicalising at the edge is what makes teardown work at all, not just what keeps two opens from racing.watchreports the running server's URL, so a client that lost track of its own session adopts it instead of asking the reader to hunt down a process.viewleaves a warm resident that self-exits after ~2 minutes idle. Orca does not callcloseon it:closealso flushes in-memory edits, so an agent mid-batch would have its work written and its resident killed by somebody else's preview.Why
Fixes #8301. Researchers, writers and technical authors keep Office documents beside code, and today Orca makes them leave to read one.
The approach deliberately invents almost no transport: snapshots ride the document-preview pipe that already renders workspace HTML behind a strict CSP, and live previews ride the browser pane and the routing that already reaches a remote host's loopback. The one genuinely new thing is the
inlinegrant owner, and it exists to avoid widening read authority — it is narrower than what shipped before it.officecliruns on the host that owns the document, always. A worktree on an SSH host renders with that host's binary, fonts and locale; an unresolved or unreachable owner is an error, never permission to render on the client. Loss of contact is reported asunverifiableand never as "the document is gone".Linked Issue
Fixes #8301
Visual Proof
Opening a
.docxfrom the editor — before / after.docxrendered in the preview partition — paragraph, table and embedded image, with the re-render control, the Live toggle, Use selection, Reveal in folder and Open in the system app..pptx, toolbar naming the kind:A format we do not render — names the format, offers the system app, never mentions
officecli:Note on the grey band in the
.docxshot: that isofficecli's own page CSS (body { background: #f0f0f0 }with a fixed-width.page), not an Orca layout bug. The guest fills its container exactly — measured atx=281 width=809for both guest and host — and the.pptxshot, which has no page box, fills edge to edge.Testing
Ran on macOS (Apple Silicon), local workspace, against real
officecli 1.0.148.pnpm tc(all projects),oxlintoversrc+tests,check:max-lines-ratchet,check:reliability-gates,check:ts-nocheck-ratchet,check:runtime-electron-ratchet, and all fourverify:localization-*scripts: clean./api/switchrejection maps to its code;parseAlreadyWatchedPortrecovers the running server's port and rejects an out-of-range one; a symlinked and a redundantly-spelled path canonicalise to the same session key; the refresh control's four states, including that a missing binary stays retryable while an unsupported format does not; inline grants serve their one document and 404 everything else including../secrets.env; relay/runtime method parity; andoffice.skillsInstallrejecting{skill: 'rm -rf /'}at the schema.office-render-service.integration.test.tsrenders all four committed fixtures and asserts zero non-data:src/hrefreferences — the self-contained-HTML property the whole CSP story rests on, so a futureofficeclithat emits an external reference fails here instead of as a blank image in front of a reader.office-watch-manager.integration.test.tsdrives start → serve → reuse → refresh → stop and asserts the port is genuinely released.tests/e2e/office-document-preview.spec.ts, headless withORCA_BACKGROUND_LAUNCH=1): a real.docxpaints inside the preview partition, and a.docshows the unrenderable panel withgetByText(/officecli/i)asserted at count 0.Not tested: Windows and Linux (host fonts change the render — the plan calls for a manual pass per release), SSH and paired-runtime hosts end to end, and the live-preview path in E2E. The watch lifecycle underneath live preview is covered by the integration test against the real binary.
AI Disclosure
Implemented with Claude Opus 5 via Claude Code, from
docs/office-document-support-plan.md. All contract claims aboutofficecliwere verified by running the binary, not taken from the plan — five of them contradicted it and are listed above.Review
Cross-platform: paths go through
path.join/ the win32 flavour; child processes go throughsrc/shared/child-process/(the ratchet test passes) with a WSL lane derived from the document path itself, so a\\wsl$\<distro>\…worktree uses the guest's binary and fonts. No hardcodedmetaKeyis introduced. Windows install guidance is shown, never executed.SSH / remote: one shared implementation behind provider dispatch; the relay needs no negotiation because it is bundle-hash-locked to its client, while the paired-runtime path is gated on
office.preview.v1and mapsmethod_not_foundto "update the paired machine" rather than a broken preview. An unreachable host answersOFFICE_HOST_UNREACHABLEand never falls back to rendering locally.Security: the preview partition's CSP is unchanged; inline grants read no filesystem; watch servers stay on loopback;
office.*params are shape-validated on the host before any spawn and every call is an argv array — no reader-supplied string is ever interpolated into a shell string. The renderer cannot mint an inline grant.Performance: the probe and binary resolution are cached per execution host and invalidated on the reader's Retry; snapshots are capped at 10 MB and refused rather than truncated; the fs-change subscription is one filtered listener per open preview and the live refresh is debounced.
Backwards compatibility: additive. The only behaviour change for an existing surface is the editor's Office binary placeholder gaining an Open preview button.
One defect was found and fixed during UI validation: the host-owner selector returned a fresh object each call, which under Zustand's
Object.iscomparison re-rendered the pane on every store write and looped through the effects — React #185, taking down the whole workbench. It is nowuseShallow, with the hazard documented at the hook.Agent skill upstream boundary
officecli skills installand reads its catalogue at runtime.Notes
officeclipredateswatch, or when the owner cannot be resolved, and any watch failure falls back to the snapshot silently. Happy to put it behind a flag if you would rather.Checklist
pnpm lint,pnpm typecheck,pnpm testpass locally (pnpm buildnot run; CI covers it)