Skip to content

Preserve persisted file opener source routing - #2083

Merged
ymichael merged 1 commit into
mainfrom
bb/post-merge-fix-preserve-file-opener-source-host-thr_evbnkb2vv3
Aug 20, 2026
Merged

Preserve persisted file opener source routing#2083
ymichael merged 1 commit into
mainfrom
bb/post-merge-fix-preserve-file-opener-source-host-thr_evbnkb2vv3

Conversation

@ymichael

@ymichael ymichael commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

What was wrong

PR #1979 correctly persisted the selected host for a project-backed file in the file-opener params, and the PDF plugin read that source. Root Compose did not: it reconstructed experimental_Original, copy-path resolution, and Open in editor from the currently selected environment/host plus fileOpenerOwner. Because Root Compose intentionally preserves file tabs across context changes, a PDF opened on host A could keep rendering from host A while those native surfaces routed to host or environment B.

What changed

useThreadFileTabs now parses the persisted opener params once and treats them as the routed file identity. fileOpenerOwner remains responsible only for native presentation state that is not part of the plugin source, such as line ranges and workspace status.

Root Compose gives a persisted project-backed opener source precedence over the live compose selection. The same resolved routing now drives the host-rendered project preview, source root and absolute copy path, and editor-open context. An explicit persisted host stays explicit; an omitted host continues to mean primary-host routing. Native file tabs still follow the existing live compose selection.

This is direct data flow from the existing persisted source, so it does not add a second host field or change the tab/server/daemon contract. HOST_DAEMON_PROTOCOL_VERSION is unchanged. There are no CLI, guide, SDK, or documentation changes because the documented plugin contract already requires this behavior.

How you verified

Regression coverage demonstrates the old behavior and the fix:

  • With the old live-context route restored, pnpm exec turbo run test --filter=@bb/app -- src/views/RootComposeView.test.ts failed the two new routing cases: explicit host A resolved as selected environment/host B, and omitted-primary routing resolved as host B (67 passed, 2 failed).
  • pnpm exec turbo run test --filter=@bb/app -- src/components/secondary-panel/useThreadFileTabs.test.ts src/views/RootComposeView.test.ts — 88 passed. This includes persisted-tab reload under a different project/environment, explicit-host retention, primary-host omission, and unchanged native-tab routing.
  • pnpm exec turbo run test --filter=@bb/app --force — 404 files passed; 3,126 tests passed and 3 skipped.
  • pnpm exec turbo run typecheck build --filter=@bb/app — passed.
  • pnpm exec turbo run lint --filter=@bb/app — passed with 0 errors and 156 existing warnings outside the changed lines.

After rebasing onto origin/main at a77a391a48003f364fd4d26bd8cde95e051eee3b, the focused opener/Root Compose/shared-panel set passed (3 files, 101 tests), and the Turbo app typecheck and build passed.

Related to #1979.

AGENT GENERATED: by GPT-5.6-Sol

@ymichael
ymichael force-pushed the bb/post-merge-fix-preserve-file-opener-source-host-thr_evbnkb2vv3 branch from 2681b5b to f2ee10c Compare August 20, 2026 22:20
@ymichael
ymichael merged commit 95f7f7f into main Aug 20, 2026
13 checks passed
@ymichael
ymichael deleted the bb/post-merge-fix-preserve-file-opener-source-host-thr_evbnkb2vv3 branch August 20, 2026 22:30
ymichael added a commit that referenced this pull request Aug 20, 2026
## 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 added a commit that referenced this pull request Aug 20, 2026
## What was wrong

The split right panel rendered the same layout twice: a shared
tab-header tree and a separate pane-body tree. The header copy always
laid its children out horizontally, so stacked splits detached each tab
strip from its pane, and the paired resize handlers could mutate the
mirrored tree on the wrong axis. Tab rendering was also split across
parallel `fileTabs` and `tabModels` representations, while root-compose
and plugin fixed tabs used separate adapters, making pane-local
selection and content inconsistent.

## What changed

- Render each pane's tab strip, controls, divider, and body as one leaf
in a single split tree. Vertical and horizontal splits now resize only
their own axis.
- Preserve #2073’s divider performance fix: resize cursor state stays
container-local, the iframe drag guard is the final container child, and
pointer cancel/unmount restores the temporary flex values without
writing inherited styles to `document.body`.
- Preserve #2083’s file-opener routing contract in every unified
renderer: persisted params own path and route identity, while the owner
record supplies native preview presentation state.
- Remove the mirrored header tree and its resize-peer synchronization,
plus unused sidebar pane maximize/swap/close state.
- Route thread tabs, root/new-thread tabs, plugin nav fixed tabs,
Browser, and Terminal through the same split container and pane-local
renderer.
- Replace the parallel `fileTabs`/`tabModels` join with one renderable
tab descriptor that owns its model, chrome, actions, content renderer,
and layout behavior.
- Document that `navPanel.experimental_fixedTabs` can mount once per
active visible split pane; the updated contract remains covered by the
unpublished plugin SDK `0.4.10` already reserved on main.

There are no host-daemon protocol or other wire changes.

## How you verified

- Reproduced the detached header and cross-axis resize behavior with
dev-browser before the fix, then manually verified thread-panel,
root-compose, plugin fixed-tab, Browser, Terminal, horizontal, and
vertical split combinations after it.
- Added regression coverage for pane-local tab rendering, split
orientation, resizing, persisted-layout reconciliation, plugin fixed
tabs, and root-compose content.
- `pnpm exec turbo run typecheck --filter=@bb/app
--filter=@get-bb/plugin-sdk`
- `pnpm exec turbo run lint --filter=@bb/app
--filter=@get-bb/plugin-sdk` (0 errors; existing warnings only)
- `node packages/plugin-sdk/scripts/check-npm-version-guard.mjs`
- Post-rebase divider tests: 2 files, 22 tests passed.
- Post-#2083 focused app tests: 8 files, 159 tests passed.
- Plugin SDK tests: 13 files, 105 tests passed.
- Full app suite: 403 files, 3,097 tests passed, 3 skipped.

### Before and after

#### Thread panel split

| Before | After |
| --- | --- |
| ![Thread panel split
before](https://github.com/user-attachments/assets/2f54cbe0-e910-4bf3-b9e3-3d7a672b1b93)
| ![Thread panel split
after](https://github.com/user-attachments/assets/ed413ef5-65c6-4f73-83ff-210109064c25)
|

#### Root/new-thread split

| Before | After |
| --- | --- |
| ![Root compose split
before](https://github.com/user-attachments/assets/82d18183-97cf-478a-b09f-8d22a5bfc0ba)
| ![Root compose split
after](https://github.com/user-attachments/assets/aa4c74e4-9302-48cf-aa93-3614a91e284e)
|

Fixes the side-panel split regression introduced by
[`4e13e3f`](4e13e3f).

> AGENT GENERATED: by GPT-5.6
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