Skip to content

fix(desktop): drop stale inflight-journal folds that duplicate answers - #84021

Closed
Nicolas-Formenton wants to merge 1 commit into
NousResearch:mainfrom
Nicolas-Formenton:fix/desktop-stale-inflight-journal-fold
Closed

fix(desktop): drop stale inflight-journal folds that duplicate answers#84021
Nicolas-Formenton wants to merge 1 commit into
NousResearch:mainfrom
Nicolas-Formenton:fix/desktop-stale-inflight-journal-fold

Conversation

@Nicolas-Formenton

@Nicolas-Formenton Nicolas-Formenton commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

A stale inflight-journal fold can re-emit answers already present in the transcript, duplicating messages. Skip folds whose journal state is stale relative to the transcript.

Related Issue

Fixes #85308

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

  • Skip stale inflight-journal folds (apps/desktop/src/lib/inflight-turn-journal.ts)
  • Tests: apps/desktop/src/lib/inflight-turn-journal.test.ts
  • contributors/emails/nformenton@Nicolass-MacBook-Air.local — attribution mapping

How to Test

  1. With the journal fold feature active, trigger a fold whose journal state is older than the transcript.
  2. No duplicate answer is appended.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — no native APIs

Verification

  • npm run test:ui -- src/lib/inflight-turn-journal.test.ts: 22 passed.

@alt-glitch alt-glitch added type/bug Something isn't working comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 11, 2026
The inflight-turn journal can outlive the turn it recorded (reclaim,
reconnect or restart races skip the settle that clears it). On session
resume the fold then re-appends journaled assistant rows to a transcript
that already holds the committed replies, so the conversation ends with
duplicate answers in scrambled order. The fold also carried the stale
entry's streamId onto the resumed state on an idle resume, which kept the
journal entry alive (persistInFlightTurnState only clears when streamId is
null) and re-folded the same tail on every open.

Detect text-level staleness before the append path: when every recoverable
journaled assistant row already exists as committed text in the base
transcript, treat the entry as caught up and clear it. Only keep a stream
target when the resumed session is genuinely running (keepPending), so an
idle resume self-heals instead of re-folding.
@Nicolas-Formenton
Nicolas-Formenton force-pushed the fix/desktop-stale-inflight-journal-fold branch from 416f965 to 40c948d Compare August 13, 2026 13:08
@Nicolas-Formenton Nicolas-Formenton changed the title fix(desktop): skip stale inflight-journal folds that duplicate transcript answers fix(desktop): drop stale inflight-journal folds that duplicate answers Aug 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thank you for this fix! It was salvaged into #86590 (cherry-picked onto current main with your authorship preserved in the commit history) and is now merged. Closing this PR since the work has landed.

@teknium1 teknium1 closed this Aug 15, 2026
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/*) P3 Low — cosmetic, nice to have 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.

bug(desktop): stale inflight-journal folds duplicate transcript answers

3 participants