Skip to content

fix(j5): a Collaborator on a thread sees its preview tabs - #797

Merged
Jacksondr5 merged 2 commits into
j5/mainfrom
j5code/collaborator-preview-stream
Oct 29, 2026
Merged

Jacksondr5 merged 2 commits into
j5/mainfrom
j5code/collaborator-preview-stream

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Problem

A person who holds Collaborator on a thread or a project, but not the server, saw a preview tab's URL bar and menu and never the page. The page comes on its own socket, /api/preview-stream/ws, which the access gate refused to every narrowed session. Closes #796.

What changed

accessHttpRule now names the preview stream, its downloads and its uploads, and keeps a narrowed session's permissions on them when the person holds Collaborator on the thread the request's threadId names. Tabs are keyed by thread and tab, so that thread is the tab's. A thread rule now carries the level it needs: a thread's loads still need Viewer, the preview routes need Collaborator. Viewers stay refused, since People and access AC21 defers watching to #540.

Checking the tab's thread, rather than letting any Collaborator anywhere through, matches how the preview RPCs are already gated (onThread("collaborator")). Jackson chose it on 2026-10-29.

UI changes

The page a thread-scoped Collaborator sees in the thread's preview tab:

Before After
A thread-scoped Collaborator opens the thread's preview tab A thread-scoped Collaborator opens the thread's preview tab, before A thread-scoped Collaborator opens the thread's preview tab, after

Live testing

Verdict: the change works. A tester agent ran j5-live-test at f39f404 against origin/j5/main, with one real turn on Claude Haiku 5.5 in a new thread.

  • A thread Collaborator and a project Collaborator both see the page, take control, and reach it with clicks and typing. A file upload through <input type=file> and a download (200, the file's contents) work for the thread Collaborator.
  • A Viewer on the thread is refused: the stream fails at upgrade and /download answers 403, with nothing loud. The tab is not listed for them either; "Browser" is greyed out in "Open a surface".
  • The Collaborator is refused on another thread's tab, on the socket and on /download.
  • Way out: lowering the Collaborator to Viewer makes their composer read-only, and the preview disappears within seconds in the web client.

Known gap, tracked in #798: a stream socket opened before the demotion stays usable after it, because upstream's stream route checks the session only when it opens. The tester reproduced it with a Node client holding the socket: it kept streaming and clicking for over two minutes. The web client isn't affected, since it reloads on renewal. The gap is upstream's and already applies to server-wide sessions; this PR extends it to thread and project Collaborators. Fixing it edits an upstream file, so it's a separate change.

Not exercised live: raising a person back from Viewer to Collaborator. The People section of the Owner's thread details panel vanished on selection and saved nothing, three times. That's outside this PR and wasn't checked on base; a person should try it by hand.

Head: b72dac9, after the tested commit, refuses a malformed thread id instead of throwing, and adds unit tests. It changes no path the test exercised, so it wasn't re-tested live.

Not covered by this kind of test: the desktop app, relay and tunnel connections, and mobile.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior (backend changes ship with focused tests)
  • UI changes: before/after screenshots above, and a video for motion or interaction (no motion)
  • Live testing: the section above says what ran live and what did not
  • Upstream-owned files: each one is recorded in FORK.md (case text and file-table row) in this PR. No upstream file is edited; case 69's list of allowed routes is updated.
  • Upstream product: any change to what upstream's product does has a human decision linked above and a register entry in docs/j5/product/upstream.md. Not applicable: J5's own gate.
  • Surfaces: entry points, clients, providers, contracts, reverse states, connection modes (see AGENTS.md). Web and mobile both stream through the same route; no contract change; losing the level refuses the next request.
  • Docs: definitions under docs/j5/product/ and user docs rewritten where this changes them. Not needed: AC14 and AC16 already say a Collaborator uses previews.

Claude Opus 5.5 in Claude Code, running in J5 Code.

🤖 Generated with Claude Code

A person whose access is narrower than the server saw a preview tab's URL
bar and menu but never the page. The page comes on its own WebSocket,
/api/preview-stream/ws, and the access gate kept a narrowed session's
permissions only on /ws, thread loads and the artifact read, so the
stream's upgrade was refused.

The gate now keeps them on the stream, its downloads and its uploads
when the person holds Collaborator on the thread the request names.
Tabs are keyed by thread, so that thread is the tab's. Viewers stay
refused, as People and access AC21 defers watching to #540.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Oct 29, 2026 8:22pm UTC

Request Review

@github-actions github-actions Bot added the vouch:trusted Author is trusted by repo permissions or the VOUCHED list. label Oct 29, 2026
@github-actions github-actions Bot added the size:M 30-99 effective changed lines (test files excluded in mixed PRs). label Oct 29, 2026
From review of #797. A thread id the gate cannot read, such as `%20`,
threw inside the gate and answered 500; it is now refused. Tests add a
Collaborator streaming a thread they only view, a project Collaborator
streaming another project's thread, and the socket's upgrade sign-in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The HTTP access gate now recognizes preview-stream WebSocket, download, and upload routes. It checks the named thread’s access level and retains narrowed-session scopes for Collaborators with access to that thread.

Changes: Preview access rules

Layer / File(s) Summary
Classify preview routes and enforce access levels
apps/server/src/j5/sharing/AccessGate.ts, FORK.md
The route rule parses the full request URL and requires Collaborator access for preview-stream routes with a valid thread ID. Thread-load routes require Viewer access. The HTTP gate checks the level specified by each rule.
Validate route rules and session scopes
apps/server/src/j5/sharing/AccessGate.test.ts
Tests cover supported and refused routes, HTTP and WebSocket authentication, and thread- and project-level Collaborator access to previews.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: bryantderosier

Merge Risk: Minimal · up to b72da

Collaborators can use previews on their accessible threads. No merge-blocking risk was identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names the main change: a Collaborator on a thread gets access to that thread's preview tabs. It follows the fix(j5) convention, is one sentence, and matches the raw summary, the AccessGate c…
Description check Passed The description follows the template. It has Problem, What changed, UI changes, Live testing, Upstream impact, and Checklist sections. Problem states the bug and links #796. What changed explains the …
Linked Issues check Passed Issue #796 requires a narrowed session to keep its permissions on /api/preview-stream/ws, /api/preview-stream/download, and /api/preview-stream/upload when the person holds Collaborator on the t…
Out of Scope Changes check Passed The reviewed changes stay within the preview-stream access gate. AccessGate.ts adds the preview-stream rule, adds a per-rule level, generalizes the level check, and refuses malformed thread ids. T…
Full details: Title check

Explanation

The title names the main change: a Collaborator on a thread gets access to that thread's preview tabs. It follows the fix(j5) convention, is one sentence, and matches the raw summary, the AccessGate changes, and objectives for #796/#797.

Full details: Description check

Explanation

The description follows the template. It has Problem, What changed, UI changes, Live testing, Upstream impact, and Checklist sections. Problem states the bug and links #796. What changed explains the gate change and why thread-scoped checks were chosen. UI changes includes a before/after table. Live testing gives a verdict, tested and untested items, known gap #798, and head commit b72dac9. Upstream impact is missing as a heading: the template asks for a note only when upstream-owned files change, and the checklist says no upstream file is edited, but the section was removed. The checklist is filled in. The description is mostly complete, so it passes. The 'Upstream impact' section could be kept with a short note that no upstream file changed, and the FORK.md case 69 update should be named there.

Full details: Linked Issues check

Explanation

Issue #796 requires a narrowed session to keep its permissions on /api/preview-stream/ws, /api/preview-stream/download, and /api/preview-stream/upload when the person holds Collaborator on the thread the request names. Viewers stay refused (AC21, #540). The diff at apps/server/src/j5/sharing/AccessGate.ts implements this. accessHttpRule now parses the full request target. For the three preview paths it returns { kind: "thread", threadId, level: "collaborator" }, using the threadId query parameter. Uploads require POST. The other two routes require GET. layerGatedEnvironmentAuth checks the rule's level through levelReaches(level, needed), so a Viewer (viewer) does not reach collaborator. The thread-load rule keeps level: "viewer", so existing behavior is unchanged. A blank or malformed thread id is refused through onThreadRoute, which uses Schema.is(ThreadId). The check uses the tab's thread, as the issue requires. The PR tests (AccessGate.test.ts, per its summary) cover thread and project Collaborators, Viewers, out-of-scope threads, and WebSocket upgrade authentication. The live-test results in the PR description are author-reported and were not re-run here. The open-stream demotion gap is tracked in #798. It is not a #796 requirement.

Full details: Out of Scope Changes check

Explanation

The reviewed changes stay within the preview-stream access gate. AccessGate.ts adds the preview-stream rule, adds a per-rule level, generalizes the level check, and refuses malformed thread ids. This is the requested behavior and its hardening. AccessGate.test.ts covers the same behavior. FORK.md case 69 changes one clause to list the preview stream, downloads, and uploads among the routes accessHttpRule allows. That is the repository's required record of the route list, and it matches the code. No unrelated code change was found in the inspected diffs. The PR description's live-test and screenshot material is not code and does not add scope.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Jacksondr5
Jacksondr5 merged commit b306d59 into j5/main Oct 29, 2026
38 checks passed
@Jacksondr5
Jacksondr5 deleted the j5code/collaborator-preview-stream branch October 29, 2026 22:06
Jacksondr5 added a commit that referenced this pull request Oct 30, 2026
Brings in from j5/main:
- #773 publish the Windows x64 CLI archive and installer
- #797 a Collaborator on a thread sees its preview tabs
- #662 Fleet: measured ledger and runtime facts
- #767 bump J5 Code to 0.0.51
- #769 storage cleanup reads Git 2.56's broken-gitfile message
- #765 a shared conversation's note stays off the timeline minimap
- #763 a link for one person always names who it is for
- #764 widen a person to a project or the server from their People row

Adapted to v0.1.3: the minimap's shared-note check lives in J5's
minimapMessages.ts; Fleet's keyboard test is a browser test on the
browser userEvent, so @testing-library/user-event is not added; Fleet's
monitor test follows upstream's awaited-only hold rule; the Windows
build pins Node 26.12.1; memo hooks, an em dash, a long comment and an
unbudgeted effect from main are fixed for the branch's lint rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Jacksondr5 added a commit that referenced this pull request Nov 23, 2026

This branch was successfully deployed

1 active deployment
Preview — b72dac9c Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

People and access: a Collaborator on a thread or project sees its preview tabs

1 participant