Skip to content

fix(desktop): branch snapshots keep pre-compaction history, isolated from parent (salvage #76286) - #86775

Merged
teknium1 merged 3 commits into
mainfrom
salvage/w2-res-branchsnap
Aug 15, 2026
Merged

teknium1 merged 3 commits into
mainfrom
salvage/w2-res-branchsnap

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Salvages the separable branch-snapshot half of PR #76286 (@DannyFengTianYu): branches now snapshot the complete pre-compaction display transcript, and branch transcripts are isolated from parent turns added after the fork. The PR's competing display-dedupe scheme (excluded by #86595) is NOT carried.

Changes (cherry-picked, authorship preserved)

57c51cc401 — isolate branch transcripts from parent updates

  • hermes_state.py: explicit /branch sessions (durable _branched_from marker) own a copied transcript, so lineage walks (get_messages_as_conversation(include_ancestors=True), get_resume_conversations, get_ancestor_display_prefix) no longer pull the live parent's rows into the branch — messages written to the original after the fork stop leaking into the branch view. Compression continuations keep full lineage reads.
  • Conflict resolved toward main: the function bodies were rebased onto today's _read_ctx() connection pattern (the PR predated that refactor); _is_explicit_branch_session uses _read_ctx too.

cb671285ee (from c3d2d759ae) — preserve complete history when branching

  • tui_gateway/methods_session.py (session.branch): the live in-memory history is the model projection — after compaction it holds only a summary + protected tail. The branch seed now reads the persisted display projection (get_resume_conversations), reconciled with the live tail via main's existing _reconcile_display_with_live, so the child no longer permanently loses every turn archived before the fork. Falls back to the in-memory history when the DB read fails.
  • Conflict resolutions toward main + contributor intent:
  • apps/desktop/.../use-session-actions/: whole-chat branch prefers the authoritative persisted transcript; branching from a clicked bubble maps it by durable row id first, same-role/text ordinal as fallback, and keeps the local prefix when unmappable; context-drift abort if the route/selection/runtime changes during hydration.

Excluded from #76286 (per #86595's exclusion notes)

Validation

Check Result
tests/test_tui_gateway_server.py + tests/test_hermes_state.py 806 passed, 1 pre-existing failure (test_search_projection_skips_context_enrichment_queries) reproduced identically on clean origin/main
Desktop vitest: use-session-actions.test.tsx, use-session-actions/utils.test.ts 152 passed
npx tsc --noEmit (apps/desktop) clean
scripts/audit_pr_attribution.py all contributor emails mapped

Credit: @DannyFengTianYu (#76286) — both commits cherry-picked with authorship preserved.

Infographic

branch snapshot

Nous Research

DannyFengTianYu and others added 3 commits August 14, 2026 23:10
Read the durable display transcript when creating a branch instead of copying the compacted model projection. Hydrate the Desktop branch boundary from persisted history, avoid stale whole-chat counts, and seed the new tile from the backend snapshot. Add regression coverage for compacted histories, visible-message counts, selected prefixes, and hydration races.

(cherry picked from commit c3d2d75)
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) comp/tui Terminal UI (ui-tui/ + tui_gateway/) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 15, 2026
@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on c9a5fe1 — chore: map contributor email (audit_pr_attribution)

⚠️ Warnings

OSV vulnerability scan · View job

5 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 16m35s vs 15m19s (+8.3%). 16 job(s) slower, 17 faster, 4 unchanged.

  • Python tests / Run tests slice 11/12: +23.0s
  • Python tests / Run tests slice 3/12: +17.0s
  • Python tests / Run tests slice 4/12: +16.0s
  • Python tests / Run tests slice 2/12: -14.0s
  • Python tests / Run tests slice 12/12: +14.0s

@teknium1
teknium1 merged commit 8a22220 into main Aug 15, 2026
60 checks passed
@teknium1
teknium1 deleted the salvage/w2-res-branchsnap branch August 15, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants