Skip to content

fix(desktop): map branch targets through folded rows - #136209

Open
normaltank wants to merge 1 commit into
NousResearch:mainfrom
normaltank:fix/desktop-branch-authoritative-fallback-136193
Open

normaltank wants to merge 1 commit into
NousResearch:mainfrom
normaltank:fix/desktop-branch-authoritative-fallback-136193

Conversation

@normaltank

Copy link
Copy Markdown

What does this PR do?

Fixes branch-from-message truncation when the clicked renderer bubble corresponds to a later source row inside a folded authoritative assistant message.

The hydrated transcript can fold several persisted assistant/tool rows into one bubble. The bubble keeps the first row as its top-level rowId, while each text part retains its own sourceRowId. selectBranchMessages() previously checked only the top-level ID, so a click on a later folded row could fail both mapping strategies and silently seed the child from the shorter renderer-local prefix.

This change maps the clicked bubble against every durable row represented by both bubbles (top-level rowId plus part sourceRowId). The existing same-role/text ordinal and local-prefix fallbacks remain unchanged.

Related Issue

Fixes #136193

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Update apps/desktop/src/app/session/hooks/use-session-actions/utils.ts to match branch targets through folded part source rows.
  • Add utils.branch.test.ts with a focused regression where the local clicked row is represented only by an authoritative part sourceRowId.
  • Keep the oversized production file at its existing 2,609-line count.

How to Test

  1. Before the implementation, run the new regression test: it fails by returning only the two-message local prefix instead of the four-message authoritative prefix.
  2. Apply the implementation and run npx vitest run --project ui src/app/session/hooks/use-session-actions from apps/desktop.
  3. Confirm all 15 files / 357 tests pass, including the folded-row regression.

Additional validation:

  • npx tsc -p apps/desktop/tsconfig.json --noEmit
  • ESLint on both changed files
  • Prettier check on both changed files
  • git diff --check
  • python scripts/check --only footguns,shebangs,no-tmp,config-writers,os-marker-fakes,case-collisions,profile-archives,ruff --base origin/main (8 checks passed)

The full scripts/check health measurement was attempted, but its unchanged-base git grep scan timed out after 120 seconds in this sparse CI workspace; it did not report a code-health regression. The full Python suite was not run because this is a Desktop TypeScript-only change.

Checklist

Code

  • I've read the Contributing Guide
  • My commit message follows Conventional Commits
  • I searched existing open and closed PRs, including fix(desktop): branch snapshots keep pre-compaction history, isolated from parent (salvage #76286) #86775, for duplicates
  • This PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass (not run; Desktop TypeScript-only change)
  • Full python scripts/check passes (8 applicable checks pass; health measurement timed out as documented above)
  • I've added a regression test
  • Tested in the Linux CI workspace with Node 22

Documentation & Housekeeping

  • Documentation update: N/A
  • cli-config.yaml.example: N/A
  • CONTRIBUTING.md / AGENTS.md: N/A
  • Cross-platform impact considered: pure transcript-selection logic with no platform-specific behavior
  • Tool descriptions/schemas: N/A

Screenshots / Logs

Focused behavior evidence:

  • Before fix: 1 failed, 141 passed; received the two-message local prefix.
  • After fix: 15 test files passed, 357 tests passed.

AI assistance disclosure: Codex investigated the issue, implemented the patch, added the regression test, and ran the validation listed above. No human code review is claimed.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Oct 10, 2026

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

area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) 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.

Desktop: branch-from-message copies a truncated transcript (selectBranchMessages falls back to the local renderer list)

2 participants