[PR #8114] [MERGED] feat(chats): show chat branches as a collapsible tree in the chat list #8110

Closed
opened 2026-10-24 04:10:28 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8114
Author: @ylli-selmani
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @ylli-selmani

Base: staging ← Head: feat/chat-list-branch-tree


📝 Commits (10+)

  • d21b583 feat(chat-list): build branch rows for a chat group
  • be29720 feat(chat-list): open a chat's branches as a tree under its row
  • d2583ca docs(branches): describe the branch tree in the chat list
  • 73695ad fix(chat-list): review fixes for the branch tree
  • 81a03db fix(chat-list): Dottore round 1 and simpler branch guides
  • c10eb7f fix(chat-list): show branches as a compact thread list
  • 1775ffb test(chat-list): pin where a legacy sibling sorts among real branches
  • ac82650 fix(chat-list): open a focused chat row with Enter or Space
  • e4bc9ac fix(chat-list): one keypress opens a row once, however long it is held
  • dd6279b fix(chat-list): describe the branch-count toggle by what users see

📊 Changes

5 files changed (+866 additions, -299 deletions)

View changed files

📝 docs/chats/branches.md (+2 -2)
📝 packages/client/src/components/layout/ChatSidebar.tsx (+616 -297)
➕ packages/client/src/lib/chat-branch-tree.ts (+139 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
➕ scripts/regressions/chat-branch-tree.regression.ts (+107 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8025

Why this change

The chat list folds every branch of a chat into one row with a branch-count badge, so a branch can only
be found by opening the chat, opening Chat Settings, and expanding Chat Branches. Branches of
branches are worse: they render as one flat pile, which is why the reporters rename them by hand as
"<parent branch> - <alt name>" just to tell them apart.

The hierarchy already exists in the data — every Engine-created branch records its immediate source
chat in metadata.branchParentChatId, and GET /chats already returns it — but nothing in the list
showed it. Without this change the only way to navigate branches stays a flat modal list, and a branch
that updates in the background is invisible while it is not the active chat.

What changed

A chat's branches now open as a thread list under its row. The chat keeps its row, and its
existing branch-count badge becomes the toggle: it gains a small chevron and opens the branches
beneath, each nested under the branch it was made from. Every branch shares the chat's characters,
so a branch row drops the avatar and keeps only what tells branches apart: its display name, when it
was last active, busy/unread, and a delete button. One compact row style at every depth, so the
indent alone says who belongs to whom.

Shared data (no server, schema, storage or API change)

  • packages/client/src/lib/chat-branch-tree.ts — pure builder turning one group's chats into render
    rows in pre-order: the chat at depth 0, each branch below its own parent, siblings in the caller's
    order.
  • scripts/regressions/chat-branch-tree.regression.ts — nested lineage, sibling ordering,
    parent-before-child ordering, legacy branches with no lineage and where they sort among real ones,
    deleted and self-referencing parents, a parentless cycle, and that every chat in a messy group
    appears exactly once.

Chat list UI

  • The badge is the toggle, a real <button aria-expanded> with a "Show/Hide branches of {name}"
    label. Rows without branches pay nothing: no chevron gutter, no spacer, so every chat name in the
    list stays at the same x. On touch the badge's tap area grows to about 44px without growing the
    pill.
  • The guide line hangs from the chat's avatar centre, branch names start under the chat's name,
    and each nested level's line starts under its parent's name, so a child can never sit left of its
    parent. Past four levels a branch still renders, just without another step of indent.
  • The look reuses what the sidebar already has: the folder children's SmoothFolderContent collapse
    with a border-l guide, and the existing branch badge.
  • The row for a group is its lineage root, so the list does not re-root itself whenever a
    different branch is the most recently active one.
  • Game groups are deliberately excluded: their row has to stay the session
    getCurrentGameGroupRepresentative picks (the newest), and a lineage-rooted tree would demote the
    group to its eldest session.
  • Highlighting is per chat: collapsed, the chat row stands in for the active branch; expanded, only
    the active branch row is highlighted.
  • A branch that becomes active (panel, notification, reload) opens its group, so the list never
    highlights a row it is not rendering.
  • Branch rows follow multi-select (a click selects instead of opening) and get a hover title for a
    truncated name; their delete button deletes that one branch.
  • Search matches a branch's display name, which it could not before (it matched the shared chat
    name), and opens the matching group while a filter is active.
  • A group with no recorded lineage (branches made before lineage existed, imported siblings) keeps
    today's single row and count. Inventing a parent there would be a lie about the data.
  • Keyboard: the chat row is back in the tab order (the first version of this PR had dropped its
    tabIndex), and Enter or Space now opens it. Staging's row was focusable but did nothing on Enter;
    the key goes through the row's click handler, so multi-select and the touch-drag guard apply too.

Docs — docs/chats/branches.md described the old single-row behaviour and now describes the list.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What I ran locally:

  • pnpm check — passed (TypeScript, ESLint, localization, format, build).
  • node scripts/run-regressions.mjs --filter chat-branch-tree — 1/1 passed.
  • Browser walkthrough on a worktree dev server with seeded data (a chat, two branches of it, a branch
    of a branch and a branch of that, plus an unrelated chat): the badge opens and closes the list, the
    rows nest correctly, only the active branch is highlighted, no console errors.
  • Measured in the browser at desktop width: the guide line sits at the avatar's centre (x 40), branch
    names start where the chat's name starts (x 66), and the nested lines sit under their parents'
    names (66, 81).
  • Measured at 375px: branch rows are 44px tall, delete buttons are visible without hover and line up
    with the chat row's, the badge's tap area is 54×47, and the active branch's group opens on reload.
  • Dottore round 1: 3 findings, all repaired (Game groups keep their session representative, compact
    rows follow multi-select, the connector geometry went away). The thread-list redesign came after.
  • Local CodeRabbit on the redesign: 3 findings. One fixed (a regression assertion repeated the one
    above it and is now a real test of where a legacy sibling sorts). Two declined: the unread badge's
    red copies the existing per-chat badge verbatim, and the docs paragraph about message IDs predates
    this PR (only its last sentence is ours).

Left for the maintainer to check by hand:

  • Manually verify the list in both themes, light and dark.
  • Manually verify on a phone that the badge opens the list with one tap and the rows are easy to hit.
  • Manually verify that deleting a branch from the list removes only that branch.
  • Manually verify that Tab reaches the chat rows, the badge and the branch rows; Enter on a row opens it, and
    Enter on the badge only opens or closes the branches.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/chats/branches.md is edited, so it needs a [docs-i18n] docs/chats/branches.md follow-up. I have
not filed it; the text is drafted and waiting for approval.

UI evidence (if applicable)

Before: one row per branched chat, with a ⑂ N badge and no way to see or pick a branch without opening
Chat Settings.

After: the badge opens the branches under the chat as a compact thread list, with the active branch
highlighted; collapsed, the chat row carries the highlight instead.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8114 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/chat-list-branch-tree` --- ### 📝 Commits (10+) - [`d21b583`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d21b58316bd6c3d05c3e677b4a1f4a4386f9bc56) feat(chat-list): build branch rows for a chat group - [`be29720`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be2972045ecb91fdda169e0d3ec840fe6199b7c5) feat(chat-list): open a chat's branches as a tree under its row - [`d2583ca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d2583ca25cf5bde50f9d7133cefd5dc179745e10) docs(branches): describe the branch tree in the chat list - [`73695ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/73695adc71ea98970801652032a36ad20d2f182a) fix(chat-list): review fixes for the branch tree - [`81a03db`](https://github.com/Pasta-Devs/Marinara-Engine/commit/81a03db2d19c10afa1b08c431f022e88366e3e4d) fix(chat-list): Dottore round 1 and simpler branch guides - [`c10eb7f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c10eb7f12a71a02e490fbb7d14ea1cbfed75e668) fix(chat-list): show branches as a compact thread list - [`1775ffb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1775ffb1e2cec4085612fcf9415f2c1c976228c7) test(chat-list): pin where a legacy sibling sorts among real branches - [`ac82650`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ac82650682544c770413777c5a34b34faae0670c) fix(chat-list): open a focused chat row with Enter or Space - [`e4bc9ac`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e4bc9ac409c0ec5a0c4dcf8641f705205194326c) fix(chat-list): one keypress opens a row once, however long it is held - [`dd6279b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dd6279b073de39e83cf6d45ba8a2f49dd9d764c5) fix(chat-list): describe the branch-count toggle by what users see ### 📊 Changes **5 files changed** (+866 additions, -299 deletions) <details> <summary>View changed files</summary> 📝 `docs/chats/branches.md` (+2 -2) 📝 `packages/client/src/components/layout/ChatSidebar.tsx` (+616 -297) ➕ `packages/client/src/lib/chat-branch-tree.ts` (+139 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) ➕ `scripts/regressions/chat-branch-tree.regression.ts` (+107 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8025 ## Why this change The chat list folds every branch of a chat into one row with a branch-count badge, so a branch can only be found by opening the chat, opening Chat Settings, and expanding **Chat Branches**. Branches of branches are worse: they render as one flat pile, which is why the reporters rename them by hand as `"<parent branch> - <alt name>"` just to tell them apart. The hierarchy already exists in the data — every Engine-created branch records its immediate source chat in `metadata.branchParentChatId`, and `GET /chats` already returns it — but nothing in the list showed it. Without this change the only way to navigate branches stays a flat modal list, and a branch that updates in the background is invisible while it is not the active chat. ## What changed **A chat's branches now open as a thread list under its row.** The chat keeps its row, and its existing branch-count badge becomes the toggle: it gains a small chevron and opens the branches beneath, each nested under the branch it was made from. Every branch shares the chat's characters, so a branch row drops the avatar and keeps only what tells branches apart: its display name, when it was last active, busy/unread, and a delete button. One compact row style at every depth, so the indent alone says who belongs to whom. **Shared data** (no server, schema, storage or API change) - `packages/client/src/lib/chat-branch-tree.ts` — pure builder turning one group's chats into render rows in pre-order: the chat at depth 0, each branch below its own parent, siblings in the caller's order. - `scripts/regressions/chat-branch-tree.regression.ts` — nested lineage, sibling ordering, parent-before-child ordering, legacy branches with no lineage and where they sort among real ones, deleted and self-referencing parents, a parentless cycle, and that every chat in a messy group appears exactly once. **Chat list UI** - **The badge is the toggle**, a real `<button aria-expanded>` with a "Show/Hide branches of {name}" label. Rows without branches pay nothing: no chevron gutter, no spacer, so every chat name in the list stays at the same x. On touch the badge's tap area grows to about 44px without growing the pill. - **The guide line hangs from the chat's avatar centre**, branch names start under the chat's name, and each nested level's line starts under its parent's name, so a child can never sit left of its parent. Past four levels a branch still renders, just without another step of indent. - The look reuses what the sidebar already has: the folder children's `SmoothFolderContent` collapse with a `border-l` guide, and the existing branch badge. - The row for a group is its **lineage root**, so the list does not re-root itself whenever a different branch is the most recently active one. - **Game groups are deliberately excluded**: their row has to stay the session `getCurrentGameGroupRepresentative` picks (the newest), and a lineage-rooted tree would demote the group to its eldest session. - Highlighting is per chat: collapsed, the chat row stands in for the active branch; expanded, only the active branch row is highlighted. - A branch that becomes active (panel, notification, reload) opens its group, so the list never highlights a row it is not rendering. - Branch rows follow multi-select (a click selects instead of opening) and get a hover title for a truncated name; their delete button deletes that one branch. - **Search matches a branch's display name**, which it could not before (it matched the shared chat name), and opens the matching group while a filter is active. - A group with **no recorded lineage** (branches made before lineage existed, imported siblings) keeps today's single row and count. Inventing a parent there would be a lie about the data. - **Keyboard:** the chat row is back in the tab order (the first version of this PR had dropped its `tabIndex`), and Enter or Space now opens it. Staging's row was focusable but did nothing on Enter; the key goes through the row's click handler, so multi-select and the touch-drag guard apply too. **Docs** — `docs/chats/branches.md` described the old single-row behaviour and now describes the list. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What I ran locally: - `pnpm check` — passed (TypeScript, ESLint, localization, format, build). - `node scripts/run-regressions.mjs --filter chat-branch-tree` — 1/1 passed. - Browser walkthrough on a worktree dev server with seeded data (a chat, two branches of it, a branch of a branch and a branch of that, plus an unrelated chat): the badge opens and closes the list, the rows nest correctly, only the active branch is highlighted, no console errors. - Measured in the browser at desktop width: the guide line sits at the avatar's centre (x 40), branch names start where the chat's name starts (x 66), and the nested lines sit under their parents' names (66, 81). - Measured at 375px: branch rows are 44px tall, delete buttons are visible without hover and line up with the chat row's, the badge's tap area is 54×47, and the active branch's group opens on reload. - Dottore round 1: 3 findings, all repaired (Game groups keep their session representative, compact rows follow multi-select, the connector geometry went away). The thread-list redesign came after. - Local CodeRabbit on the redesign: 3 findings. One fixed (a regression assertion repeated the one above it and is now a real test of where a legacy sibling sorts). Two declined: the unread badge's red copies the existing per-chat badge verbatim, and the docs paragraph about message IDs predates this PR (only its last sentence is ours). Left for the maintainer to check by hand: - Manually verify the list in both themes, light and dark. - Manually verify on a phone that the badge opens the list with one tap and the rows are easy to hit. - Manually verify that deleting a branch from the list removes only that branch. - Manually verify that Tab reaches the chat rows, the badge and the branch rows; Enter on a row opens it, and Enter on the badge only opens or closes the branches. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/chats/branches.md` is edited, so it needs a `[docs-i18n] docs/chats/branches.md` follow-up. I have not filed it; the text is drafted and waiting for approval. ## UI evidence (if applicable) Before: one row per branched chat, with a `⑂ N` badge and no way to see or pick a branch without opening Chat Settings. After: the badge opens the branches under the chat as a compact thread list, with the active branch highlighted; collapsed, the chat row carries the highlight instead. <!-- screenshots: expanded, collapsed, 375px --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:28 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8110
No description provided.