Skip to content

feat(chat): merge a fork back into its parent chat - #15957

Open
unstablebrainiac wants to merge 1 commit into
kirodotdev:mainfrom
unstablebrainiac:feat/fork-bring-back
Open

unstablebrainiac wants to merge 1 commit into
kirodotdev:mainfrom
unstablebrainiac:feat/fork-bring-back

Conversation

@unstablebrainiac

@unstablebrainiac unstablebrainiac commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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_from link 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

  • Merging raw messages, a three-way merge, or a parent into a fork.
  • Archiving or locking the fork after a merge; it can be merged again.
  • Merge-back for app tokens, agent tools or internal callers.
  • Merging into a closed parent without opening it.
  • Undoing a merge.
  • A fork of a chat whose key is over MAX_FORK_PARENT_KEY_CHARS: it records no parent link, so it is not_a_fork.
  • Counting the parent's newer messages in the gap sentence: the count would go stale while the person edits.
  • Keeping edited text under a new draft after a merge refused as out of date: the new draft can start at a later message than the text describes (another merge landed), and a draft does not say where it starts, so Merge would repeat a summary the parent already has under the new draft's range. The text stays in the box until Replace.
  • Fixing main's name-only slot dedup (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.
  • Delivering the summary as a parent turn, which starts its agent unasked, or a user message, which speaks in the person's name.

What changed (motivation → approach → change)

The merge-back routes are on main since #17165; this PR is the dashboard that calls them.

Part What it does
Session menu Merge into parent… (MergeBackMenuItem) on forks, greyed with its reason: a running turn, an incognito or temporary fork, or a parent outside the dashboard
Dialog MergeBackDialog drafts through POST /api/chat/slots/{slot}/merge-back/draft and 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 to POST /api/chat/slots/{slot}/merge-back. MergeBackDialogHost loads it on first open
Card MergedFromLabel shows "Merged from fork · N messages" above the summary in the parent, and the fork's title opens the fork

The card's link opens the fork it was merged from and no other. useOpenMergedFork always resumes the fork with expected_created_at set to the card's mergedFrom.createdAt, also when a tab is open on its key, since the slot list can lag a delete and a recreate there, and a resume_identity_mismatch says 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 no createdAt (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's forked_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 in utils/mergeBackError.ts. app-sdk/messageRenderers.tsx draws 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.md and 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.tsx and SessionActionsMenu.mergeBackReason.test.tsx: the row shows only on forks and says why it is greyed; mergedFromOf reads a missing createdAt as "" and refuses a present non-string or over-long one. mergeBackErrorMessage words 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 with expected_created_at, never a local switch, and a refused resume opens nothing.
  • ChatPage.transcriptRendering.test.tsx gains the openMergedFork prop and a merged-from card block 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 (MergedFromLabel in MergeBackMenuItem.test.tsx: its fork link, the title as text, the one-message form and an untitled fork).
  • ApiClient.refactor.surface.test.ts is not changed: it reads the client's members directly, so it covers the two new calls without a hand-kept list. switchSlotCallsiteClassification.test.ts is unchanged too: the dialog opens the parent through the pinned resume, never switchSlot.
  • 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.py and three turn goldens gain the key.
  • i18n:check, tsc -p tsconfig.app.json and eslint --max-warnings 0 pass.

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:

Session menu on a fork, with Merge into parent

Merge dialog with the drafted summary and the gap sentence

The card the merge leaves in the parent:

Parent chat showing the merge card

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:

Merge into parent greyed on a running fork, with its reason

Merge dialog while the summary is being drafted

Merge dialog after merging into a parent mid-turn

Merge dialog with a text over the limit, its reason and Merge disabled

Merge dialog asking before Draft again replaces edited text

Merge dialog for a draft that covers the first 4 of 7 messages and leaves the rest 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:

Merge dialog asking before a close loses edited text

Merge dialog with a draft cut to fit the limit, and the line that says where it stops

Merge dialog while the merge is written, with no way to close it

Merge dialog after a refused merge, with the edited text kept and Merge off

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:

Merge dialog after a summary that could not be written, with Draft again

Merge dialog for a fork whose messages the parent already has, in an error notice with Ask the agent, and Close

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).

Merge dialog after a merge that landed but could not open the parent, in a red notice with Ask the agent, and Close

Merge into parent greyed on a fork whose parent runs outside the dashboard, with its full reason

Merge into parent greyed on a fork of a WhatsApp chat, with its full reason

Closed parent, phone width, light theme

Dialog when the parent chat is closed, with Open the parent chat as its one action

Dialog at 390px

Parent card in the 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@unstablebrainiac
unstablebrainiac requested a review from a team October 1, 2026 18:20
@unstablebrainiac
unstablebrainiac requested a review from a team as a code owner October 1, 2026 18:20
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of c5f007a4a83e96b12037292a059af53537461222 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • nothing_to_merge (attachment-18) shows "The parent chat already has everything in this fork." as a red error with "Ask the agent". It is a finished state with nothing to fix. Show it as a muted status line with only Close.
  • edit_hint "The parent gets exactly this text, last sentence included." makes the reader work out which line is meant. Name it: "…including the note about messages the fork didn't see."

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of c5f007a4a83e96b12037292a059af53537461222 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • utils/resumeKey.ts copies the gateway's history_files._safe_key and member-thread rule on the client. The slot list could send the parent's resume key instead, as it already sends forked_from_created_at, so the two rules can't drift apart.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of c5f007a4a83e96b12037292a059af53537461222 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 8 — oversized: mergeBackParent.ts sorts parent_not_dashboard into channel, direct-message, scheduled-job and outside kinds. That is 8 catalog strings × 13 locales for one gateway code, whose fix is the same in every case ("a merge reaches only a dashboard chat"). Subtraction: delete MergeBackParent, mergeBackParentOf and menuParentOf. Keep only components.mergeBackMenuItem.parent_not_dashboard and utils.mergeBackError.parent_not_dashboard, and grey the row on a non-dashboard: key or an origin link.

What this change ships

Inventory (10 items) — 9 justified

Intent: bring a fork's results back into its parent chat as an edited summary the parent's agent reads on its next turn. ADDITION.

  1. A fork's session menu gains Merge into parent…, greyed with an inline reason — justified
  2. The merge dialog drafts, lets you edit and redraft (asking before losing edits), counts characters, then merges — justified
  3. Every merge text opens with a fixed sentence saying the fork did not see the parent's later messages — undeclared
  4. The parent shows a "Merged from fork · N messages" label; its title opens the fork, pinned to the recorded transcript — justified
  5. After a merge, the dashboard switches to the parent and leaves Split View — justified
  6. Open the parent chat appears when the parent is closed, pinned to its transcript — justified
  7. The slot list carries forked_from_created_at for forks — justified
  8. The greyed reason names the parent's kind (a Slack chat, a DM, a scheduled job) — oversized: five kinds for one refusal code
  9. A resume pinned to a transcript is no longer dropped as a repeat of an unpinned one — justified
  10. App-SDK transcripts show the merged-from label with the title as plain text — justified

[FIRST-PRINCIPLES-REVIEWED] c5f007a

Description read

[DESCRIPTION-READ] 1561dae67559a0881b504317916c75dbea371291e12d0930a4bbfe2bc9aff1f4

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed c5f007a4a83e96b12037292a059af53537461222 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c5f007a

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed c5f007a4a83e96b12037292a059af53537461222 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

Notes:

  • temp-screenshots/merge-back/ adds 24 review PNGs at the repository root. They have no runtime effect, but they will stay in the git history permanently.

[OPUS-REVIEWED] c5f007a

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 1, 2026
@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 2, 2026
@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@unstablebrainiac

This comment has been minimized.

@iamwhatever

Copy link
Copy Markdown
Contributor

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 (chat_merge_back.py, chat_runner.py, turn_context.py, slot_buffers.py, write_guards.py, security_posture.py and the rest) is byte-identical to #17165's head 4a666a2, so merging this PR would also merge all of #17165. On head a41b030 I read the PR's own production code under website/src (MergeBackDialog.tsx, MergeBackMenuItem.tsx, useOpenMergedFork.ts, mergeBack.ts, mergeBackError.ts, mergeBackParent.ts, the ChatPage.tsx and messageRenderers.tsx wiring). I tried to break it in three ways. A forged or malformed meta.mergedFrom block: mergedFromOf checks its shape, the backend strips client-sent mergedFrom, and the fork title is rendered as a Trans text value, not HTML. An empty createdAt on a card: it goes through resume with expected_created_at, and the server refuses that. A merge with edited text over a draft that has gone out of date: Merge stays off until a new draft comes. I found no defect in the dashboard part. The UX lane's advisory points (nothing_to_merge and parent_not_open show as red errors with "Ask the agent") are polish, not blockers. Hard blocker, not a defect: the required Sensitive Change Review is red on this head because it is a fork PR that changes security_posture.py, and the gate itself says only a maintainer can take it over on a branch of this repository. On top of that, the Design lane's "Clears when" is that #17165 merges first and this PR is rebased down to its website/docs diff. Question for @bolichen97 / @CrysisDeu: will a maintainer take #17165 over onto an in-repo branch so it can merge first? Once it lands, I would approve this PR's rebased dashboard diff on what I read today. — crew-pr-reviewer (deep re-check)

@github-actions

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🔴 BLOCK (blocking)

Which legitimate operations does f6b516ed6ba251634b95885a644395fede2d3892 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

no leg reported, and this was not the nothing-to-adjudicate short circuit

No [SCOPE-REVIEWED] marker for this head was produced, so the model's text is withheld: it cannot be shown to describe this revision. See the job logs.

@bolichen97

Copy link
Copy Markdown
Contributor

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.

@unstablebrainiac

Copy link
Copy Markdown
Contributor Author

@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.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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 expected_created_at behave exactly as before. A supplied pin fails closed. An app caller gets the same isolation 404 for a missing key and for another owner's transcript, so the pin reveals nothing. The metadata reads run off the event loop. Cards saved before this change still restore. The split of test_chat_merge_back_merge.py keeps every test name. The dialog never drops text the person edited, and its tests wait on signals instead of sleeping.

Optional:

  • This branch carries feat(chat): pin a merged fork's reopen to the transcript it was merged from #34274's commit e114ec7. Merge feat(chat): pin a merged fork's reopen to the transcript it was merged from #34274 first, then rebase this PR so that only the website/ and docs commit remains, as the body plans.
  • useOpenMergedFork.ts:19 switches to an open slot when the projection's created (slot.created_at) matches the card. resume_identity.py says that stamp is not the transcript identity. Always going through the guarded resume would remove the gap. It fails safe in every case we could reach.
  • mergeBackParent.ts:48 sorts the parent key by prefix, which repeats a rule the gateway already enforces (parent_not_dashboard). The two can disagree for a slot named like slack_notes. Separately, parentTakesTurnsOutsideDashboard (mergeBackParent.ts:60, re-exported in MergeBackMenuItem.tsx:16) has no caller.

@bolichen97

Copy link
Copy Markdown
Contributor

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:

  • What it does: the dashboard side of merge-back, whose routes are on main since feat(chat): backend to merge a fork back into its parent chat #17165. A fork gets Merge into parent… in its session menu, greyed with a reason for a running turn, an incognito or temporary fork, or a parent outside the dashboard. MergeBackDialog drafts a summary through merge-back/draft, shows it for editing with the covered message count and a character count, asks before losing edits, and sends exactly that text to merge-back. In the parent, MergedFromLabel shows "Merged from fork · N messages", and its link opens that fork only, pinned by the transcript identity feat(chat): pin a merged fork's reopen to the transcript it was merged from #34274 adds.
  • Pros: a fork that pays off no longer needs a manual copy and paste. The person reviews and edits the summary before it lands. The summary is delivered as a card the parent's agent reads on its next turn, not as a turn that starts the agent unasked or a message in the person's name.
  • Cons and limits: about 4,500 added lines across 79 files, most of it UI, tests and 12 locales. A merge cannot be undone, and the fork is not locked after it, so it can be merged again. Merging into a closed parent first needs that parent opened.
  • Long-term debt: moderate. It is a new user-facing flow with its own dialog, card and error mapping to keep in step with the merge-back routes. Its backend changes are feat(chat): pin a merged fork's reopen to the transcript it was merged from #34274's, so this PR should land after it.

No regex in product code. The pinned-reopen 409 applies only when a caller sends the new expected_created_at, so it refuses nothing main allows.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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 3cff2427c5 · 3758 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful split and the thorough dialog tests. One thing in the new dialog needs a change before this can move on.

  1. 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 with already_merged, which is in DRAFT_OUTDATED (line 102). If the person picks keep, keepEditsUnderNewDraft calls draftNow(phase.draft, { keepText: true }). That skips setText (line 157) but takes the new draft, so merge() sends the old text with the new draft's through and digest (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's merge_draft_stale refusal is there to prevent. The same thing can happen in one tab: a merge lands but the client sees a network error, the retry gets already_merged, and the draft was partial. Smallest fix: do not offer keep after already_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.tsx only gains a props stub. A test that renders a system message carrying meta.mergedFrom through transcriptRendering.tsx:407 (and one for messageRenderers.tsx) would pin the card, its open link and the cron and app label precedence.
  • No test follows expectedCreatedAt from the real resumeFromHistory thunk to the expected_created_at field in the POST body, including the empty value for an older card.
  • The "Open the parent" click (MergeBackDialog.tsx:281) is pinned as gesture: 0, so the parent's cron notes are not marked read when it opens. Either pass gesture: true or say why in the ratchet entry's reason.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Keep-text after already_merged sending old text under a new draft's range: fixed on this head. The keep path is gone. A new draft always replaces the text, and Merge stays off after any outdated refusal. MergeBackDialog.test.tsx covers both sides.
  • Design sign-off: still stands. This is a maintainer decision, and nothing in the code can change it.

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:

  • The Tests section says ChatPage.transcriptRendering.test.tsx renders the card label. That file only gains a props stub. A render test for a row carrying meta.mergedFrom, through transcriptRendering.tsx and messageRenderers.tsx, would pin the label, its link and the label precedence. If you do not add one, drop that line from the Tests section.
  • When the draft summary is empty, the dialog opens with only the gap sentence and Merge is enabled. Consider opening with an empty text box so the placeholder asks for a note.
  • "Open the parent" still switches without gesture: true, so the parent's cron notes are not marked read. Either pass it or say why in the ratchet entry's reason.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: fixed on this head. The keep path is gone. After any outdated refusal, Merge stays off until a new draft replaces the text.
  • Design sign-off: still stands. A maintainer decides this, and no code change can clear it.

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 forked_from_created_at slot field, and a test covers both branches of it. The new tests wait on signals and use no sleeps or clocks. A good choice: every link the card or dialog offers goes through the identity-pinned resume, so a deleted and recreated key cannot open the wrong transcript.

Optional:

  • No test checks the POST bodies this PR adds. If website/src/api/client/chat.ts:248 checked truthiness instead of !== undefined, an older card with an empty createdAt would resume unpinned, and every test would stay green. Extending the resumeChatSlot case in ApiClient.coverage.construction.test.tsx (three arguments, '', and none) and asserting the mergeBack body would pin it.
  • MergeBackDialog.tsx:187: if the parent is already being reopened from History within the resume lease, the pinned resume is dropped as a duplicate. .unwrap() then throws, and the dialog shows a reopen failure while the parent opens behind it. You could treat a condition rejection as "already opening" instead of a failure.
  • The two parent switches (goToParent and the switch after Merge) still run without gesture: true, so the parent's cron notes stay unread. Either pass it or explain why in the ratchet entry's reason.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: still fixed on this head. Every new draft replaces the text. After any outdated refusal, Merge stays off until a new draft arrives.
  • Design sign-off: still pending. A maintainer decides this, and no code change can clear it.

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 forked_from_created_at slot field, and a test covers both of its branches. The resume repeat guard now keys on the transcript pin, and its tests cover both orders plus a true repeat. A good choice: every link the card or dialog offers goes through the identity-pinned resume, so a deleted and recreated key cannot open the wrong transcript.

Optional:

  • website/src/pages/chat/useOpenMergedFork.ts:20: a card with an empty createdAt draws a fork link that the gateway always refuses. You could pass onOpen only when createdAt is set, so the title shows as plain text. Also, no test checks the resume POST body (expected_created_at set, empty, and absent), so a truthiness check at website/src/api/client/chat.ts:262 would go unnoticed.
  • website/src/components/MergeBackDialog.tsx:258: if the parent closes while the person edits, Merge fails with parent_not_open in the ready phase, and "Open the parent" only appears in the refused phase. You could offer the reopen action for that failure too.
  • website/src/utils/mergeBackParent.ts:50: the client sorts parents into several kinds, with 6 extra strings in each catalog. The gateway already refuses all of them with one parent_not_dashboard code. One generic reason for the menu row and the dialog would cover the same cases with less code.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: still fixed on this head. The dialog no longer keeps edited text across a redraft. After any outdated refusal, Merge stays off until a new draft arrives.
  • Design sign-off: still pending. A maintainer decides this. No code change can clear it.

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 forked_from_created_at slot field, and a test covers both of its branches. The resume repeat guard keys on the transcript pin, and its tests cover both orders plus a true repeat. One thing done well: every link the card or dialog offers goes through the identity-pinned resume, so a key that was deleted and created again cannot open the wrong transcript.

Optional:

  • website/src/pages/chat/useOpenMergedFork.ts:21: a card with an empty createdAt still shows a fork link, and the gateway always refuses it with a 400. You could pass onOpen only when createdAt is set, so the title shows as plain text.
  • website/src/api/client/chat.ts:335: no test reads the resume POST body. A test that sends expected_created_at with a value, with an empty string, and leaves it out would catch a dropped field or a truthiness check that drops the empty value.
  • website/src/utils/mergeBackParent.ts:31: the client sorts parents into five kinds and adds extra strings to every catalog. The gateway refuses all of them with one parent_not_dashboard code. One generic reason for the menu row and the dialog would cover the same cases with less code.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: still fixed on this head. The dialog has no keep-text path. After any outdated refusal, Merge stays off until a new draft replaces the text.
  • Design sign-off: still pending. A maintainer decides this. No code change can clear it.

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 forked_from_created_at slot field, and a test covers both of its branches. The resume repeat guard keys on the transcript pin, and its tests cover both orders plus a true repeat. One thing done well: every link the card or dialog offers goes through the identity-pinned resume, so a key that was deleted and created again cannot open the wrong transcript.

Optional:

  • website/src/pages/ChatPage.tsx:1015: the added comment says the fork link switches to an open tab. useOpenMergedFork.ts and its tests say it never does and always resumes with the pinned identity. Rewording the comment would keep the next editor from adding that local switch back.
  • website/src/api/client/chat.ts:340: no test reads the request body. Extending the resumeChatSlot case in ApiClient.coverage.construction.test.tsx would catch a dropped field or a truthiness check. It needs three calls: a set expected_created_at, an empty string that must still be sent, and none. Asserting the mergeBack and mergeBackDraft bodies would pin those too.
  • website/src/pages/chat/page/transcriptRendering.tsx:417: a card with an empty createdAt still shows a fork link that the gateway always refuses. You could pass onOpen only when createdAt is set, as the dialog already does for its own reopen paths.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: still fixed on this head. The dialog has no keep-text path. After any outdated refusal, Merge stays off until a new draft replaces the text.
  • Design sign-off: still pending. A maintainer decides this. No code change can clear it.

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 forked_from_created_at slot field. The goldens and the facade contract test are updated with it, and a test covers both of its branches. The resume repeat guard keys on the transcript pin, and its tests cover both orders plus a true repeat. The new tests wait on signals and use no sleeps or clocks. One thing done well: both links this feature offers go through the identity-pinned resume. A key that was deleted and created again therefore cannot open the wrong transcript.

Optional:

  • website/src/pages/chat/page/transcriptRendering.tsx:417: a card with an empty createdAt still shows a fork link. The resume route refuses an empty expected_created_at with 400, so every click shows the generic could-not-open notice. You could pass onOpen only when createdAt is set, the way the dialog gates its own reopen buttons.
  • website/src/components/MergeBackDialog.tsx:307: for a closed parent that was born in a channel (a slack_ key), the dialog offers "Open the parent chat". That reopens the parent, and the redraft is then refused with parent_not_dashboard. Checking mergeBackParentOf(parentSession).kind === 'dashboard' before showing the button would avoid the extra step.
  • website/src/pages/ChatPage.tsx:1015: the comment says an open fork is switched to. useOpenMergedFork always resumes through the pinned route. Rewording the comment would stop the next editor from adding a local switch back.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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 forked_from_created_at slot field, and a test covers both of its branches. The new tests wait on signals and use no sleeps or clocks. One thing done well: both links this feature offers go through the identity-pinned resume, and the repeat guard now keys on the pin, so a key that was deleted and created again cannot open the wrong transcript.

Optional:

  • website/src/api/client/chat.ts:340: no test reads the expected_created_at key in the resume POST body. If it were dropped, renamed or gated on truthiness, the gateway would resume without the identity check and every test would stay green. A case in ApiClient.coverage.construction.test.tsx for a set pin, an empty pin and no pin would pin it.
  • website/src/store/chat/lifecycle.ts:796: the pin argument to newestResumeOf in the rejected reducer can be removed with no test failing. A test that starts an unpinned and a pinned resume of the same key, repeats the pinned one, and then checks which answer opens the chat would cover it.
  • website/src/pages/ChatPage.tsx:1023: the comment still says an open fork is switched to. useOpenMergedFork always resumes through the pinned route. Rewording it would stop a later edit from adding the local switch back.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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 forked_from_created_at slot field, and a test reds if its fork guard is removed. The new tests wait on signals and use no sleeps. Done well: the card link and both parent reopens always resume pinned to a recorded transcript, and the repeat guard now keys on that pin. A chat recreated on the same key is refused, not opened.

Optional:

  • website/src/api/client/chat.ts:340: no test reads the expected_created_at key in the resume request body. A misspelled key would make every pinned reopen unpinned with all tests green. One client test for a set pin and one for no pin would cover it.
  • website/src/utils/mergeBackParent.ts:31: the gateway refuses every non-dashboard parent with one code, parent_not_dashboard. The five-kind classifier and its six extra keys in each catalog could become one check and one message, unless users need the parent's kind named.
  • website/src/pages/ChatPage.tsx:1032: the comment says an open fork is switched to. useOpenMergedFork always resumes through the pinned route, so the comment should say that.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: still fixed on this head. draftNow always replaces the text with the new draft. The "keep" answer only cancels the redraft, so no path sends old text with a new through and digest.
  • Design sign-off: still pending. The 2026-11-10 comment here is a design brief for a maintainer, not a decision. Nobody has said on Enhancement: merge-back a forked session (compact fork and fold summary into parent) #3816 or here whether the earlier answer on outside pull requests for this feature still stands.

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 forked_from_created_at slot field, and its test has a decoy row that checks the fork guard. The fork title renders as a React text child in every catalog, never as markup. The new tests wait on signals and use no sleeps. Done well: a chat recreated on the same key is refused, not opened, and the dialog never drops text the person edited without asking first.

Optional:

  • website/src/api/client/chat.ts:352: no test reads the expected_created_at key in the resume request body. A misspelled key would make every pinned reopen unpinned while all tests stay green. One case for a set pin, one for the empty pin and one for no pin in ApiClient.coverage.construction.test.tsx would cover it. Request-body cases for mergeBackDraft and mergeBack would help too.
  • website/src/utils/mergeBackParent.ts:71: the gateway refuses every non-dashboard parent with one code, parent_not_dashboard. The client classifier and its extra keys in each catalog could become one check and one message, unless users need the parent's kind named before they open the dialog.
  • website/src/pages/ChatPage.tsx:1032: the comment says an open fork is switched to. useOpenMergedFork always resumes through the pinned route, so the comment should say that.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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):

  • Old text sent under a new draft's range after already_merged: fixed on this head. draftNow (MergeBackDialog.tsx:152) always swaps in the new draft's text along with the draft itself. So no path sends old text with a new through and digest.
  • Design sign-off: still pending. Nobody has posted a decision on Enhancement: merge-back a forked session (compact fork and fold summary into parent) #3816 or here. That includes whether the earlier answer on outside pull requests for this feature still stands now that the backend routes are on main.

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 forked_from_created_at slot field. Its test has a decoy row that is not a fork, which checks the fork guard. The fork title renders as a React text child in all 13 catalogs, never as markup. The new tests wait on signals and do not sleep. Done well: if a chat is recreated on the same key, the reopen is refused rather than opening the wrong transcript.

Optional:

  • website/src/api/client/chat.ts:352: no test reads the expected_created_at key in the resume request body. A misspelled key would turn every pinned reopen into an unpinned one, and all tests would stay green. Add one case each for a set pin, an empty pin and no pin in ApiClient.coverage.construction.test.tsx, next to the existing resumeChatSlot body test.
  • website/src/pages/ChatPage.tsx:1032: the comment says an open fork is switched to. useOpenMergedFork always resumes through the pinned route, so the comment should say that instead.
  • The ## Tests section of the body makes two claims the diff does not match. It says ApiClient.refactor.surface.test.ts changed, but that file is not in the diff. It also says the transcript test gains only a prop, but it adds a merged-from card block with four tests.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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 forked_from_created_at slot field. Its test has a decoy row that is not a fork, which checks the fork guard. The fork title renders as a React text child, never as markup. The new tests wait on signals and do not sleep. Done well: if a chat is recreated on the same key, the reopen is refused instead of opening the wrong transcript.

Optional:

  • website/src/api/client/chat.ts:352: no test reads the expected_created_at key in the resume request body. The gateway runs the identity check only when that key is present. So if the key were dropped or renamed, pinned reopens would go out unpinned and every test would still pass. One client test that checks the body with a pin and without one would cover it.
  • website/src/pages/ChatPage.tsx:1032: the comment still says an open fork is switched to. useOpenMergedFork always resumes through the pinned route, so the comment should say that.
  • temp-screenshots/merge-back/ commits 18 images (about 2.1 MB) that stay in main's history after a squash. The evidence guidance asks for two or three. Keep the few that show the core flow, and attach the rest in the PR body.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping this current. One thing is still missing on this head before a maintainer can judge it.

  1. 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-203 pins bg-danger-subtle and role=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.

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 verification section. 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 the expected_created_at key 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". useOpenMergedFork always resumes through the pinned route, so the comment should say that.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: merge-back a forked session (compact fork and fold summary into parent)

4 participants