Skip to content

Omit a null hostId from thread tabs responses so older mobile builds still sync - #2144

Merged
SawyerHood merged 1 commit into
mainfrom
bb/fix-inaccessible-mobile-images-thr_fs3nw3qdvi
Aug 21, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/fix-inaccessible-mobile-images-thr_fs3nw3qdvi

Conversation

@SawyerHood

Copy link
Copy Markdown
Collaborator

What was wrong

Image links in the mobile app failed with a "Couldn't sync tabs" toast. The links and the image routes were fine. A tap opens a host-file-preview panel tab, and the app then syncs the tab strip with GET/PUT /threads/:id/tabs. #2005 added hostId to host-file-preview tabs with .default(null), so the server now emits hostId: null in every tabs response. Installed mobile builds bundle a .strict() copy of threadTabsResponseSchema that predates the field, so their SDK rejects the whole response (Unrecognized key: hostId), the mutation errors, and the tab never settles. Phones cannot update in step with the server, so the server must stay readable by the shipped schema.

What changed

  • apps/server/src/routes/threads/tabs.ts: the GET and PUT responses omit hostId when it is null, on host-file-preview tabs and on host-file-preview file-opener owners of plugin-panel tabs. A non-null hostId still travels. Current clients parse the omission back to null through the schema default.
  • packages/server-contract: added ThreadTabsWireResponse (z.input of the response schema) and typed both tabs routes with it.

No daemon wire change, so no HOST_DAEMON_PROTOCOL_VERSION bump.

How you verified

  • New test in apps/server/test/public/public-thread-tabs.test.ts that fails before the route change (expected … to not have property "hostId") and passes after it.
  • pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-tabs.test.ts: 3/3 pass. @bb/server-contract tests: 58/58 pass.
  • pnpm exec turbo run typecheck for @bb/server, @bb/sdk, @bb/app, @bb/mobile, @bb/demo-server: pass.
  • Manual: paired the iOS simulator with the live bee.getbb.app server on a current Metro bundle; storage and host-file image links open the panel tab and the lightbox.

Fixes #

AGENT GENERATED: by Claude Opus 5

…still sync

Installed mobile builds parse the tabs routes with a strict copy of the
contract that predates hostId. The server now emits hostId: null, so
those builds reject every response and show "Couldn't sync tabs" when a
host-file link opens a panel tab. Omit the field when it is null; current
clients default it back.

Co-Authored-By: Claude <[email protected]>
@SawyerHood
SawyerHood merged commit 2c0b747 into main Aug 21, 2026
13 checks passed
@SawyerHood
SawyerHood deleted the bb/fix-inaccessible-mobile-images-thr_fs3nw3qdvi branch August 21, 2026 04:32
ymichael added a commit that referenced this pull request Oct 26, 2026
## Human comments

## What was wrong

Plugins could only preview a workspace file's working copy:
`ExperimentalLiveFileTarget` had no way to name a Git revision. Core
already showed deleted changed files at HEAD or the merge base, but
through a bespoke path (`head`/`merge-base` sources plus a `"deleted"`
status label built in `resolveWorkspaceChangedFileOpenTarget`) that
plugins could not use.

## What changed

- **Plugin SDK:** the workspace variant of `ExperimentalLiveFileTarget`
gains optional `experimental_ref` (`"HEAD"` or a 4–40 character commit
SHA, the forms `GET /environments/:id/revisions/:ref/files/*` accepts;
anything else makes the target invalid, so links stay inert and navigate
calls return `false`). SDK bumped 0.6.85 → 0.6.86.
- **Behaviour:** `experimental_openFilePreview` and
`experimental_FileLink` with a ref open a read-only preview of the file
at that revision, labelled with the ref (e.g. `kept.ts (5cf801c)`). The
link menu hides "Open with", because plugin file openers only read the
working copy. `experimental_openFileExternally` ignores the ref and
opens the working copy. A `Markdown` `experimental_document` target with
a ref keeps it on relative links and loads relative images at that
revision.
- **Core uses the same path:** deleted rows in the Info tab and composer
changed-files lists now call `usePanelFiles.openFilePreview` with ref
`HEAD` (uncommitted) or the merge-base SHA (committed). The bespoke
source/status-label path is deleted. Tab and header labels come from the
source ref, so deleted files read `(HEAD)` / `(<sha>)` instead of
`(deleted)`.
- **No wire, server or daemon changes.** Panel tabs persist a ref in the
existing `head`/`merge-base` sources, because shipped mobile builds
parse the synced tab schema strictly (see #2144). `statusLabel` stays on
the wire and new tabs write `null`.
- **Docs:** `docs/api_to_audit.md` entry (Workspace file revisions),
Plugin Guide symbol in `plugins/plugin-api-docs/src/surfaces.ts`, and a
note in the plugin-authoring `frontend-components.md`.

Production code: +111 / −75 (net +36).

## How you verified

- `pnpm exec turbo run typecheck lint test --filter=@bb/app
--filter=@get-bb/plugin-sdk --filter=@bb/client-core
--filter=bb-plugin-plugin-api-docs --filter=bb-plugin-bb-guide`: 20/20
tasks, 0 lint errors.
- `@bb/app` 6403 passed, 1 skipped; `@get-bb/plugin-sdk` 402;
`@bb/client-core` 287; `plugin-api-docs` 75; `bb-guide` 7.
- New tests:
- ref validation, accepted (`HEAD`, a SHA) and rejected (`HEAD~1`,
`origin/main`, empty, `null`, ref on thread storage);
- a ref opens the read-only revision tab on the thread, New thread and
plugin-page surfaces;
- a ref target still resolves to the working-copy path for external
opens;
  - updated expectations for deleted changed files.
- Real run (`pnpm start:worktree`, fixture repo with a deleted `gone.md`
and an edited `kept.ts`, clicked in a browser):
- Clicking the deleted `gone.md` row in the composer changed-files list
opens `gone.md (HEAD)` with the HEAD content.
  - A local test plugin built against the packed 0.6.86 SDK:
- its `experimental_FileLink` with ref `5cf801c` opens `kept.ts
(5cf801c)` with that commit's content;
    - the working-copy link opens the current edit;
- `experimental_openFilePreview` with `HEAD` returns `true` and opens
`gone.md (HEAD)`;
    - `experimental_openFileExternally` returns `true`.
- Not exercised live: hiding "Open with" (no `.ts` file opener
installed), external opening (no local editor targets in headless
Chrome), and the Info-tab rows (they share the composer rows' click
handler).

> AGENT GENERATED

Co-authored-by: Michael Yong <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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