mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8565] [MERGED] fix(chats): keep branches under a deleted middle branch in the list #8676
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8676
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8565
Author: @ylli-selmani
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ylli-selmani
Base:
staging← Head:fix/branch-orphan-lineage📝 Commits (5)
607744dfix(chats): keep branches under a deleted middle branch in the liste13d179docs(chats): a deleted source branch still shows under the chat2be96dbdocs(chats): split the branch-list sentence and name the deleted-source casec91fe8cdocs(chats): say the unknown-source rule applies inside the tree42975bftest(chats): pin the all-orphan group and align the ordering comment📊 Changes
3 files changed (+43 additions, -13 deletions)
View changed files
📝
docs/chats/branches.md(+1 -1)📝
packages/client/src/lib/chat-branch-tree.ts(+15 -8)📝
scripts/regressions/chat-branch-tree.regression.ts(+27 -4)📄 Description
Linked issue
Closes #8488
Why this change
Deleting a branch that another branch hangs from takes the whole branch tree out of the chat list. The descendant chat is still there — Chat Branches lists it and the branch graph draws it — but the group's
⑂ Nbadge stops being a toggle: no chevron, no expand, and no way to reach the descendant from the list.Reported on Discord and filed by @SpicyMarinara: "delete middle branch and the branch not viewable as branch." In the screenshot the badge is present but inert.
The cause is one predicate disagreeing with the data. Deleting a chat deliberately leaves its children's
metadata.branchParentChatIdpointing at the removed chat — lineage is history, not a foreign key. ButhasChatBranchLineageonly counted a parent still inside the group, so a group whose middle branch was deleted read as "no lineage at all" and fell back to the single-row list. That fallback exists for legacy branch sets and Game sessions, which record no parent at all. Importing, copying and restoring a chat all stripbranchParentChatId, so a pointer with no chat behind it can only mean the source was deleted — a different thing from "lineage unknown".What changed
chat-branch-tree.ts—hasChatBranchLineagecounts a recorded parent pointer even when the parent chat is gone, so a group keeps its tree after a middle branch is deleted. The orphan hangs directly under the surviving top chat (the builder's existing fallback for a deleted parent), and branches below it keep their own depth.chat-branch-tree.regression.ts— the old expectation ([a, b]with a deleted parent ⇒ no lineage) was this bug written down as a test, so it now asserts the opposite. Adds the issue's 3-chats-minus-the-middle repro (root:0, b1-1:1, b1-1-1:2, b2:1) and keeps the legacy-set / lone-chat / self-reference negatives.docs/chats/branches.md— the branch count now opens the tree "once at least one branch in the group records which chat it was made from". Inside that tree, an unknown or deleted source sits directly under the chat.No server change, no schema change, no migration, no new UI copy. Groups that record no lineage at all keep their single row.
Validation
Local runs on this branch, cut from
origin/stagingaac35cba8:The regression fails on the old predicate: the deleted-source case was asserted
false, and the 3→2 repro produced no tree.pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Worktree stack on port 6980 with a seeded group: root chat → a branch of it → a branch of that branch, then the middle branch deleted with
DELETE /chats/:id?force=true. The chat list then shows the root row with a clickable⑂ 2badge (chevron) that expands to the descendant indented under it with its guide line; collapsing hides it and expanding brings it back, witharia-expandedfollowing. Before the fix the same data rendered the badge as a static pill with no tree.Screenshots are kept locally in the private
.tmprepo, not committed here:.tmp/branches/branch-orphan-lineage/screenshots/2026-10-30-orphan-tree-expanded.png.Local review (CodeRabbit, two runs)
--committed --base origin/staging): 1 minor — the branch-list paragraph was a run-on; split into short sentences, with the deleted-source case stated separately. Fixed in2be96dbb0.--committed --base e13d1798d): 2 minor. One asked the unknown-source rule and the "group with no known lineage" sentence to state the same rule — fixed inc91fe8c97by scoping the first to "Inside that tree", which is the actual behavior. The other asked to rewrite the paragraph for newcomers without internal terminology; declined — that sentence is the precise rule for when the branch count becomes a button, and round 1 already reduced it to three short sentences. Rewriting it further would either drop the condition or misstate when the count is clickable.Docs and release impact
docs/chats/branches.mdchanged by one sentence; the[docs-i18n] docs/chats/branches.mdfollow-up is #8568. No version-bearing files touched, noCHANGELOG.mdentry.UI evidence (if applicable)
The reported screenshot is the before: the
⑂ 2pill with no chevron. After the fix the same group renders⑂ 2 ⌃and expands to the surviving descendant under the root.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.