Skip to content

fix(web): Merge back is disabled where the server would refuse it - #861

Merged
Jacksondr5 merged 2 commits into
j5/mainfrom
fix/merge-back-follows-level
Nov 1, 2026
Merged

Jacksondr5 merged 2 commits into
j5/mainfrom
fix/merge-back-follows-level

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Problem

Upstream offers "Merge back to " on a fork whenever there is a run to merge, but J5's server admits thread.merge_back only to someone who holds Collaborator or Owner over the fork's project. So a Viewer, a Collaborator on the fork only, or a Collaborator on both threads but not the project was offered a button the server refuses. Closes #730.

What changed

canMerge in upstream's ThreadRelationshipsControl.tsx also asks a new J5 hook, useCanMergeBack (apps/web/src/j5/sharing/access.ts), for the open fork. It is #729's Fork rule, useCanForkThread, which reads the fork's project, exactly what the server's admission checks (projectOfThread(sourceThreadId), where sourceThreadId is the fork), plus upstream's "Operate tasks" permission, which the merge's dispatchCommand needs and upstream's button never asked. Upstream's merge command has no permissionAtom, so the hook reads the permission as useCanOperateThread and useCanAddProject do. The button is disabled, not hidden, because its row also shows where the fork came from. Until the server says who the connection is, nothing is withheld, as #729 does.

No new test: the decision is sharingAllowsStart, already covered in packages/client-runtime/src/j5/sharing.test.ts; this PR only calls it from one more control.

The agent-facing t3_thread_merge_back path needs nothing: agents' MCP sessions are not a person's and are not narrowed (D33), and a person's own command is refused by the server's admission either way. Mobile is out of scope, with the rest of sharing on mobile (#609). Desktop wraps web and gets the change.

UI changes

Before is j5/main (f5822cde4d), after is this PR, each on its own test server with the same steps. Each person views the fork's Lineage section, whose first row is the source conversation, and the merge icon to the right of that row. A disabled icon is fainter (opacity 0.64). The thread titles are model-generated, so they differ between the two servers.

Before After
Owner on the fork: Merge back enabled, unchanged (tooltip shown) Owner on the fork, Merge back, before Owner on the fork, Merge back, after
Viewer of the whole project, who reads both threads: enabled before, disabled after Project Viewer, Merge back, before Project Viewer, Merge back, after
Collaborator on the fork thread only: enabled before, disabled after Collaborator on the fork only, Merge back, before Collaborator on the fork only, Merge back, after
Viewer of the fork thread only: enabled before, disabled after Viewer of the fork only, Merge back, before Viewer of the fork only, Merge back, after
Collaborator over the whole project: enabled on both sides Project Collaborator, Merge back, before Project Collaborator, Merge back, after

After only:

After
The project Viewer raised to project Collaborator in Settings > People: enabled again within seconds, without a reload Project Viewer raised to Collaborator, Merge back enabled again, after

Not captured: a Collaborator on both threads but not the project. The test script's guest gives a new person one scope, and the People dialog changes only the level within a scope. That person is held by the same project rule as the thread-only Collaborator. A one-thread person's source row reads as an id and "Unknown" on both sides, because the source isn't shared with them. The project Viewer pair shows the change most clearly.

Live testing

Pass, by a Claude Sonnet 5.5 tester on live-test servers for base and head (report: artifacts/test-reports/fix/merge-back-follows-level/5762bd5d0f.md). Tested commit 5762bd5d0f. The head, 2407d4eb43, adds the "Operate tasks" check from review. It was not re-tested live: every person captured holds that permission, or lacks it and was already disabled by the level rule, so nothing they see changes. A device paired with a ceiling that leaves the permission out was not reproduced on the test server. Base f5822cde4d, the head's parent: origin/j5/main moved to 68a9f69229 during setup and doesn't touch this control. On each server one real Claude Haiku 5.5 turn ran in a source thread and one in its fork, through the UI. Enabled and disabled were read from the DOM in every tab, not only from the images.

Person on the fork Before After
Owner enabled enabled; clicking merged back and opened the source thread
Collaborator on the fork thread only enabled; a click is refused ("not shared with you on this server") disabled
Viewer of the fork thread only enabled disabled
Viewer of the whole project enabled; a click is refused ("missing scope orchestration:operate") disabled
Collaborator over the whole project enabled enabled
Project Viewer raised to project Collaborator (the way back) not run enabled again with no reload

Found on base too, so not caused by this PR:

  • A refused merge says nothing on screen, only a console warning. With this PR, the people who were refused no longer get an enabled button.
  • A disabled Merge back shows no tooltip, because disabled buttons take no pointer events. The disabled state is the fainter icon, as with upstream's other disabled controls.

Not exercised: a Collaborator on both threads but not the project (see UI changes); desktop (wraps web); mobile (out of scope, #609); relay and tunnel (client-side presentation only, no new requests). Rows of the skill's "What to cover" judged not to apply: turn path, adapters and MCP tools (untouched); stored state, migrations, startup and peering (untouched).

Upstream impact

Upstream-owned file edited: apps/web/src/components/chat/ThreadRelationshipsControl.tsx (one import, one hook call, one condition), recorded in FORK.md case 90 (the #729 case; a bullet and a file-table row). This changes what upstream's product does; Jackson approved it on 2026-10-31. Register: divergence D33 in docs/j5/product/upstream.md gains "a merge back" in its bullet and a history entry.

Checklist

  • One concern: the description has no "also"
  • Tests cover the changed behavior: no new test, the rule is sharingAllowsStart, covered by sharing.test.ts; this adds one call site
  • UI changes: before/after screenshots above (no motion to record)
  • 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
  • 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
  • Surfaces: entry points (the relationships control is the only door to Merge back for a person; agents go through MCP, see above), clients (web and desktop; mobile out of scope, Share links: sharing on mobile #609), reverse states (a level raised brings the button back, as it reads the live level)
  • Docs: register D33 updated; People and access AC14 already says a thread-scope Collaborator can't merge one back

Built by Claude Opus 5.5 in J5 Code (Claude Code harness).

🤖 Generated with Claude Code

A Viewer, or a Collaborator on the fork or on both threads but not the
project, was offered Merge back, which the server admits only by the
fork's project. The button now asks the same J5 rule as Fork.

Closes #730

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 1, 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 Nov 1, 2026 2:38am UTC

Request Review

@github-actions github-actions Bot added size:S 10-29 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Nov 1, 2026
Jacksondr5 added a commit that referenced this pull request Nov 1, 2026
@Jacksondr5
Jacksondr5 marked this pull request as ready for review November 1, 2026 02:34
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 26 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 55 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 68a9f69 and 2407d4e.

Files selected for processing: 4
  • FORK.md
  • apps/web/src/components/chat/ThreadRelationshipsControl.tsx
  • apps/web/src/j5/sharing/access.ts
  • docs/j5/product/upstream.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…needs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jacksondr5
Jacksondr5 merged commit a52613e into j5/main Nov 1, 2026
33 checks passed
@Jacksondr5
Jacksondr5 deleted the fix/merge-back-follows-level branch November 1, 2026 02:53
Jacksondr5 added a commit that referenced this pull request Nov 23, 2026

This branch was successfully deployed

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

Labels

size:S 10-29 effective changed lines (test files excluded in mixed PRs). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A thread-scope Collaborator is offered Merge back, which the server refuses

1 participant