Skip to content

Preserve Docs opener host routing - #2088

Merged
ymichael merged 1 commit into
mainfrom
bb/post-merge-fix-docs-opener-drops-explicit-host-thr_tivk5tf382
Aug 20, 2026
Merged

Preserve Docs opener host routing#2088
ymichael merged 1 commit into
mainfrom
bb/post-merge-fix-docs-opener-drops-explicit-host-thr_tivk5tf382

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

What was wrong

The Docs file opener rebuilt the SDK's PluginFileOpenerSource for its private RPC contract but dropped experimental_hostId. Its backend schema could not accept that field, and host-file resolution hardcoded hostId: null, so opening, previewing, or autosaving a file selected on remote host A could read or overwrite the same absolute path on the primary host.

What changed

The Docs app now carries the existing optional experimental_hostId through its opener source for both openFile and saveOpenedFile. The Docs RPC schema and parser preserve that value, and host-file resolution returns it to the existing Files SDK read, preview, and write calls. When the field is omitted, resolution still returns null, intentionally preserving primary-host behavior.

This is the smallest complete fix because it extends the direct data flow for the existing SDK source identity; it does not add a parallel host field or refactor unrelated routing. PR #2083 is now merged, and this branch is rebased on top of it; that PR changes persisted app-tab source routing, while this change fixes the separate Docs app/server RPC hop.

There is no host-daemon wire change: the plugin RPC is server-owned and the Files SDK already supports its host selector, so HOST_DAEMON_PROTOCOL_VERSION is unchanged. There are no CLI, guide, SDK, or user-facing configuration changes.

How you verified

The regressions failed before the implementation with the exact routing break: the app test received an opener source without experimental_hostId, while the server test rejected it as an unrecognized schema key (2 failed, 56 passed):

  • pnpm exec turbo run test --filter=bb-plugin-simple-notes -- app.test.tsx server.test.ts

After the fix:

  • The same focused command passed 58 tests. The app regression verifies read and autosave RPC identities, and the two-host server regression gives the primary and remote hosts different content, preview URLs, and write results, then proves read, preview, and save all selected host_remote.
  • pnpm exec turbo run test typecheck build --filter=bb-plugin-simple-notes --force passed after the final rebase: 65 tests passed; the Docs typecheck and build passed; 7 Turbo tasks succeeded.
  • git diff --check origin/main...HEAD passed.

Related to #2005 and #2083.

AGENT GENERATED: by GPT-5.6-Sol

@ymichael
ymichael merged commit 9c096dd into main Aug 20, 2026
13 checks passed
@ymichael
ymichael deleted the bb/post-merge-fix-docs-opener-drops-explicit-host-thr_tivk5tf382 branch August 20, 2026 22:41
ymichael added a commit that referenced this pull request Aug 20, 2026
## What was wrong

PR #2088 correctly preserved
`PluginFileOpenerSource.experimental_hostId` through the Docs frontend
and private RPC, but `resolveOpenerFile` consumed it only for
`source.kind === "host"`. Root Compose opens a project-source Markdown
file as `{ kind: "workspace", environmentId: null, projectId,
experimental_hostId }`, so Docs accepted the source identity and then
skipped its only workspace branch, throwing “Docs can open workspace,
host, and thread-storage files only.” The same project-backed file
already works in the PDF opener through the core project content route.

## What changed

Docs now resolves a workspace source with no environment and a project
ID through the project's authoritative local-path source. An explicit
`experimental_hostId` selects that host; omission resolves through
`system.config().primaryHostId`, matching the public opener contract and
core project-workspace routing. The resolved source root and host feed
the existing confined Files SDK read, preview, and optimistic-write
calls. Missing, duplicate, or non-absolute project-source identities
fail closed instead of selecting another machine.

This is the smallest complete fix: one resolver branch plus one server
regression. Environment-backed workspace, absolute host-file, and
thread-storage behavior is unchanged. There is no SDK, CLI, guide,
configuration, or host-daemon wire change, so
`HOST_DAEMON_PROTOCOL_VERSION` is unchanged.

## How you verified

The pre-fix focused regression failed both project-backed cases with the
reported error (2 failed, 31 passed):

- `pnpm exec turbo run test --filter=bb-plugin-simple-notes --
server.test.ts`

After the fix and the final rebase onto `deb723091` / merged #2059:

- The focused server suite passed 32 tests. The regression proves
selected-host read, preview, and optimistic save routing; omitted-host
primary routing even when a different project source is marked default;
and rejection of an unknown selected host before file I/O.
- `pnpm exec turbo run test typecheck build
--filter=bb-plugin-simple-notes --force` passed: 66 tests, Docs build
and typecheck, 7 successful Turbo tasks.
- `git diff --check origin/main...HEAD` passed.

Related to #2088, #2083, and #2059.

> AGENT GENERATED: by GPT-5.6-Sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant