Repository navigation
feat(chat): merge a fork back into its parent chat - #15957
unstablebrainiac wants to merge 1 commit into
Conversation
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The 21 committed screenshots cover the menu row, the dialog's states and the card in both themes. This fork lane has no blind read, so nobody without context has read these labels yet. Notes
[UX-REVIEWED] c5f007a Description read[DESCRIPTION-READ] 23c0f99766aea40944dfd6501f41ae711939063d29d9dc83cc56f101830038b4 That sha256 names everything this verdict read: the PR description, plus the 24 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: this is a UI over merge-back routes already on main, it adds one slot-list field, and screenshots of this revision are committed. Notes
[DESIGN-REVIEWED] c5f007a Description read[DESCRIPTION-READ] 3c390678bb61a095cd76b5f1d7d8d5e62da36c35459399c99409587225f5a374 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the merge-back routes already exist on main (#17165), and every item is UI those routes need. One note: the menu and dialog explain a single refusal with a five-kind parent classifier. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: bring a fork's results back into its parent chat as an edited summary the parent's agent reads on its next turn. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] c5f007a Description read[DESCRIPTION-READ] 1561dae67559a0881b504317916c75dbea371291e12d0930a4bbfe2bc9aff1f4 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] c5f007a |
70864d3 to
1836fa6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1836fa6 to
cf61083
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR adds the dashboard half of "merge a fork back into its parent": the "Merge into parent…" menu row, the draft/edit/merge dialog, the "Merged from" label on the parent's card, and the link that reopens the exact fork. It is stacked on #17165, the backend. I checked that every backend file in this diff ( |
Security Scope Review (fork) — 🔴 BLOCK (blocking)Which legitimate operations does no leg reported, and this was not the nothing-to-adjudicate short circuit No |
|
Thanks for this PR. It now conflicts with main. Could you rebase onto the latest main and resolve the conflicts? We will review it again once it is rebased and CI is green. |
|
@bolichen97 This PR is stacked on #17165 (the backend), which is now rebased on current main (22e7630, MERGEABLE, CI running). Rebasing this one now would re-carry #17165's commit and conflict again on every #17165 re-sync. Once #17165 merges, this PR gets rebased onto main so only the dashboard commit remains. |
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). The linked issue #3816 still says the team will not take an outside pull request for this concept. The backend half (#17165) is already on main, so a maintainer needs to say on #3816 or here whether that answer still stands. Review result on ee349c2: no blocking defect found. The checks covered correctness, security and tests. Callers that send no Optional:
|
|
Thanks for the rebase. ee349c2 merges cleanly with main and all 94 checks are green. This is a large dashboard feature, so I am leaving a design brief for a maintainer's sign-off rather than an approval. Design brief:
No regex in product code. The pinned-reopen 409 applies only when a caller sends the new |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. This is the dashboard client for merge-back routes already on main (#17165, #34274), plus one additive slot-list field, forked_from_created_at. Verified against the code: the gateway writes mergedFrom.createdAt; the resume route refuses an empty, malformed or mismatched expected_created_at before opening anything; resumeKeyFor's dashboard_ stem is stripped again by _normalize_slot_key, so an open slot is found rather than opened twice. The repeat guard's new pin-aware match is applied consistently by every reader of pendingResumes. The card's link is plain text when it has no identity, in session-bound embeds and in app-SDK transcripts. The dialog host is always mounted under ChatPage. Backend and frontend tests cover each changed behaviour. Nothing blocks. Tier: 2, held for a person: design-doc-gate: D. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the careful split and the thorough dialog tests. One thing in the new dialog needs a change before this can move on.
website/src/components/MergeBackDialog.tsx:228("Draft again, keep my text"). Say two tabs draft the same fork and tab A merges first. Tab B's Merge is then refused withalready_merged, which is inDRAFT_OUTDATED(line 102). If the person picks keep,keepEditsUnderNewDraftcallsdraftNow(phase.draft, { keepText: true }). That skipssetText(line 157) but takes the new draft, somerge()sends the old text with the new draft'sthroughanddigest(line 255). The gateway checks only the range, so it accepts the merge. The parent gets a second card that repeats the summary of messages it already has, labelled with the new draft's message count. The newer fork messages are marked merged without ever being summarized, so later merges skip them. This is the same overlap the gateway'smerge_draft_stalerefusal is there to prevent. The same thing can happen in one tab: a merge lands but the client sees a network error, the retry getsalready_merged, and the draft was partial. Smallest fix: do not offer keep afteralready_merged, or more generally whenever the new draft starts at a different point than the old one. Keep can stay for a refusal where the range is unchanged. Removing the keep path entirely also works. Would one of these fit what the UX feedback asked for?
Separately, this adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/).
Otherwise the review found no blocking defect in correctness, security or tests. The card link always goes through the identity-checked resume, refusal codes map to localized copy, and the edit protection is consistent and well tested.
Optional:
ChatPage.transcriptRendering.test.tsxonly gains a props stub. A test that renders a system message carryingmeta.mergedFromthroughtranscriptRendering.tsx:407(and one formessageRenderers.tsx) would pin the card, its open link and the cron and app label precedence.- No test follows
expectedCreatedAtfrom the realresumeFromHistorythunk to theexpected_created_atfield in the POST body, including the empty value for an older card. - The "Open the parent" click (
MergeBackDialog.tsx:281) is pinned asgesture: 0, so the parent's cron notes are not marked read when it opens. Either passgesture: trueor say why in the ratchet entry's reason.
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on this head. The PR only changes the dashboard. It calls the merge-back routes and the identity-pinned resume that are already on main. The draft and merge request and response shapes match the gateway. The 4000-character limit is counted in code points on both sides. The card title renders as text and never as markup. Every refusal code maps to localized copy. The tests wait on signals and do not use sleeps or clocks. A good choice: the card's fork link always goes through the identity-checked resume. So a deleted and recreated key cannot open the wrong transcript. Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on head 7cdeb79. The draft and merge calls match the merge-back routes already on main, in request shape, response shape and refusal codes. The 4000-character limit is counted in code points on both sides. The card title renders as text, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on head 407bddc. The draft and merge calls match the merge-back routes already on main in request shape, response shape and refusal codes. The summary limit is counted in code points on both sides. The card title renders as text, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on head 141588a. The draft and merge calls match the merge-back routes on main in request shape, response shape and refusal codes. The summary limit is counted in code points on both sides. The card title renders as text, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on head 29390d1. The draft and merge calls match the merge-back routes on main in request shape, response shape and refusal codes. The summary limit is counted in code points on both sides. The card title renders as text, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on head cb0a9db. The draft and merge calls match the merge-back routes on main in request shape, response shape and refusal codes. The card title renders as a React child, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Follow-up on the earlier review (3c8efb7):
This review found no blocking defect on head 517abc8. The draft and merge calls match the merge-back routes on main in request shape, response shape, limits and refusal codes. The fork title on the card renders as a React child, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Earlier review (3c8efb7):
This review found no blocking defect on head a8adb18. The draft, merge and resume calls match the routes on main in request fields, response fields, limits and refusal codes. The fork title renders as a React child in every catalog, never as markup. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Earlier review (3c8efb7):
This review found no blocking defect on head 343a05d. Every move to another chat goes through the resume route with a recorded transcript pin. That covers the card's fork link and both parent reopens, and no path sends an empty pin. The repeat guard compares the pin as well as the key, and the tests cover both sides of that change. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Earlier review (3c8efb7):
This review found no blocking defect on head 65304ae. Every move to another chat uses the resume route with a recorded transcript pin. That covers the card's fork link and both reopens of the parent, and no path sends an empty pin. The repeat guard compares the pin as well as the key. Tests cover both directions of that change and the drop of a same-pin repeat. The only backend change is the additive Optional:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Earlier review (3c8efb7):
This review found no blocking defect on head 6811d32. Since 65304ae this head is a rebase only, with no product code changes. Every move to another chat goes through the resume route with a recorded transcript pin. That covers the card's fork link, the reopen of a closed parent and the move after a merge. The repeat guard compares the pin as well as the key, and tests cover both orders and the drop of a same-pin repeat. The only backend change is the additive Optional:
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for keeping this current. One thing is still missing on this head before a maintainer can judge it.
- Missing evidence for two new states (
website/src/components/MergeBackDialog.tsx:454-462,website/src/components/MergeBackMenuItem.tsx:34-46). The UX review on 3cff242 says it cannot evaluate these, and it published PASS only because its BLOCK had no Trigger and no Outcome line. A review that cannot reach a verdict because evidence is missing does not count as a pass.- If the merge lands but the parent chat cannot be opened, the dialog shows "Merged. The parent chat could not be opened." inside the red danger notice. The test at
website/src/test/MergeBackDialog.test.tsx:202-203pinsbg-danger-subtleandrole=alert. Nobody has seen whether a person reads this success as a failure and merges again. - The greyed "Merge into parent" row shows longer reasons in a
ml-auto text-[10px]span: "parent runs outside the dashboard", the channel, direct message and scheduled job reasons, and incognito and temporary. Only "turn running" is shown (frame 07), and that frame already truncates the label. temp-screenshots/merge-back/at this head holds frames 01-14, 16, 17, 21 and 22. None of them shows either state.- Smallest fix: attach two stills of this head to the PR description with GitHub drag and drop, which does not count toward the 1 MB diff cap. One should show the dialog in its merged-but-parent-not-opened phase. The other should show the greyed row with "parent runs outside the dashboard" and at least one longer channel reason. Then re-run the UX review. No code change is needed. If you think red is the right level for this notice, say why in the description.
- If the merge lands but the parent chat cannot be opened, the dialog shows "Merged. The parent chat could not be opened." inside the red danger notice. The test at
Earlier review (3c8efb7): the old text sent under a new draft's range after already_merged is still fixed on this head. draftNow always replaces the text with the new draft's text.
Separately, the linked issue #3816 adds a new concept and still needs a design sign-off from a maintainer. A maintainer will post that decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/).
Optional:
- The description has no
## Real-machine verificationsection. The screenshots come from fixture-backed API calls. A run against an isolated real gateway would show the client and gateway path working: fork, merge, the card in the parent, and the pinned reopen. website/src/api/client/chat.ts:352: no test checks theexpected_created_atkey in the resume request body. If it were dropped or renamed, pinned reopens would go out unpinned and every test would still pass.website/src/pages/ChatPage.tsx:1032: the comment says an open fork is "switched to".useOpenMergedForkalways resumes through the pinned route, so the comment should say that.
Problem / Motivation
Goal: Bring a fork's results back into the chat it was forked from, as a summary that chat's agent reads on its next turn.
A fork is a one-way door today: when it pays off, nothing lands the outcome in the original chat, and its
forked_fromlink is display-only.Why it matters
Every fork that pays off now costs a manual copy and paste, and every skipped one leaves the parent without context you already paid for.
Not a goal
MAX_FORK_PARENT_KEY_CHARS: it records no parent link, so it isnot_a_fork.api_chat_slot_create,api_chat) first, or refusing a parent open in two slots: main opens one transcript twice on purpose (a create by name, the hooked resume), so a turn takes its session's cards from whichever slot holds them.What changed (motivation → approach → change)
The merge-back routes are on main since #17165; this PR is the dashboard that calls them.
MergeBackMenuItem) on forks, greyed with its reason: a running turn, an incognito or temporary fork, or a parent outside the dashboardMergeBackDialogdrafts throughPOST /api/chat/slots/{slot}/merge-back/draftand shows the editable draft, how many messages it covers, where a cut draft stops, and a character count. Draft again or closing asks before losing edits, and Merge sends exactly that text toPOST /api/chat/slots/{slot}/merge-back.MergeBackDialogHostloads it on first openMergedFromLabelshows "Merged from fork · N messages" above the summary in the parent, and the fork's title opens the forkThe card's link opens the fork it was merged from and no other.
useOpenMergedForkalways resumes the fork withexpected_created_atset to the card'smergedFrom.createdAt, also when a tab is open on its key, since the slot list can lag a delete and a recreate there, and aresume_identity_mismatchsays the fork is gone. The resume repeat guard (store/chat/lifecycle.ts) now keys on the pin as well as the session key, so a pinned resume is never dropped as a repeat of an unpinned one already on its way, which would open whatever chat now holds the key. A card with nocreatedAt(written before #34274) reads as an empty identity, as the gateway reads it: its label shows, and its link is refused rather than opening a fork it cannot confirm. Open the parent chat is pinned the same way. The slot list now carries a fork'sforked_from_created_at(slot_projection.py), and the dialog resumes the parent with it, so a chat created on the parent's key after a delete is refused rather than opened. A fork with no recorded parent identity gets Draft again instead, and the parent is opened from History. Refusals from both routes are worded inutils/mergeBackError.ts.app-sdk/messageRenderers.tsxdraws a card's "Merged from" title as plain text, since that registry also draws transcripts with no session navigation.The 13 i18n catalogs carry the new strings with translator notes in
en.context.json. The feature map row,src/kiro_crew/docs/dashboard.mdand the dashboard module spec describe the menu row, the dialog and the card.Backwards compatibility
Compatible: the diff adds UI on routes main already serves, plus one additive slot-list field,
forked_from_created_at, which an older client ignores. No request or stored shape changes beyond #34274's optional fields.Removes nothing: no route, key, component or record is removed or tightened.
Tests
MergeBackDialog.test.tsx: the dialog sends exactly the approved text with the draft's fingerprint, opens the parent after the merge pinned to its recorded transcript, leaves Split View to show it, and says the merge landed when that open is refused, pins Open the parent chat to the fork's recorded parent identity and says so when that resume is refused, offers Draft again on a fork with no identity, asks before Draft again or a close loses edits, names every refusal (parent outside the dashboard, deleted, unconfirmed, held merge, stale draft, over-long text), says where a cut draft stops and how many messages are left, drafts once under StrictMode, and counts characters as the gateway does. The host draws nothing until a fork's dialog opens.MergeBackMenuItem.test.tsxandSessionActionsMenu.mergeBackReason.test.tsx: the row shows only on forks and says why it is greyed;mergedFromOfreads a missingcreatedAtas""and refuses a present non-string or over-long one.mergeBackErrorMessagewords a summary refused as credential-shaped (context_secret_shaped) as text to remove, not a retry.resumeRespectsSwitchAway.test.ts: a pinned resume is sent while an unpinned resume of the same key is on its way, and the other way round; a repeat of the same pinned resume is still dropped.useOpenMergedFork.test.ts: an open fork, a closed one and one with an empty identity all go through the guarded resume withexpected_created_at, never a local switch, and a refused resume opens nothing.ChatPage.transcriptRendering.test.tsxgains theopenMergedForkprop and amerged-from cardblock of four tests. The card opens the fork from the dashboard chat and from a popped-out chat. Its title is plain text in a session-bound embed, and when the card recorded no fork identity. The label is also tested as a component (MergedFromLabelinMergeBackMenuItem.test.tsx: its fork link, the title as text, the one-message form and an untitled fork).ApiClient.refactor.surface.test.tsis not changed: it reads the client's members directly, so it covers the two new calls without a hand-kept list.switchSlotCallsiteClassification.test.tsis unchanged too: the dialog opens the parent through the pinned resume, neverswitchSlot.test_dashboard_chat_fork.py: the slot list names the parent transcript for a fork and""for any other chat.test_chat_slot_facade_contract.pyand three turn goldens gain the key.i18n:check,tsc -p tsconfig.app.jsonandeslint --max-warnings 0pass.Manual verification
The screenshots come from the real built dashboard (
MergeBackDialog.tsx,useMergeBackDialog.tsx,MergedFromLabel.tsx,api/client/chat.ts,types/mergeBack.ts,mergeBackError.ts) with every API call answered from fixtures, by a Playwright capture script kept out of this PR so its diff stays under the review lanes' 1 MB cap. Looking at them caught a counter showing a raw placeholder, which is fixed and now covered by the dialog test. A reader given no context read the previous round's 22 frames at high confidence, with two medium answers: frame 18's "runs outside the dashboard" and frame 21's "Ask the agent".Screenshots / video
The fork's session menu, and the dialog with its draft:
The card the merge leaves in the parent:
The menu row on a fork still running a turn, the dialog while it drafts, a merge held until the parent's turn ends, a text over the limit, Draft again asking before it replaces edited text, and a draft that leaves newer messages for the next merge:
Closing over edited text, a draft cut to fit the limit, a merge being written, and a merge refused because the fork changed:
A summary that could not be written, with Draft again, and a fork the parent already has in full. The row is greyed with its reason on an incognito fork, a temporary fork and a fork of a channel thread, as on a running fork above. Those three rows and the card for a fork with no title were dropped from the screenshots to keep the diff under the 1 MB review cap:
A merge that landed while the parent chat could not be opened, and the greyed row's longer reasons for a parent that runs outside the dashboard and a parent in a WhatsApp chat. The notice uses the red error level on purpose: the person pressed Merge to land in the parent, and that move failed. Close is its only action, and the dialog cannot merge the same messages twice: drafting again on that fork is refused because the parent already has them (frame 22).
Closed parent, phone width, light theme
Related Issues
Design: #3816 (comment)
The backend routes landed in #17165, and the transcript identity the card's link checks landed in #34274.
Fixes #3816
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)