Skip to content

Comments

fix: chat stop/retry/branch bug fixes#16

Open
ProfSynapse wants to merge 9 commits intomainfrom
fix/chat-stop-retry-branch-bugs
Open

fix: chat stop/retry/branch bug fixes#16
ProfSynapse wants to merge 9 commits intomainfrom
fix/chat-stop-retry-branch-bugs

Conversation

@ProfSynapse
Copy link
Owner

Summary

  • Fix stop button to preserve tool calls instead of wiping them
  • Fix retry to clear old content and stream fresh (not overlay)
  • Wire stop button to cancel retry streaming (separate AbortController)
  • Clean up continuation messages after retried AI message
  • Clear tool accordions on retry (prevent old+new tool accumulation)
  • Implement incremental DOM reconciliation for message display
  • Fix branch data loading, navigator memory leak, repository serialization
  • Add 142 unit tests across 7 test files

Test plan

  • Stop during normal streaming preserves tool calls in place
  • Retry clears old content, streams fresh response with tool calls
  • Branch arrows appear after retry to navigate between old/new
  • Stop during retry actually stops streaming
  • Tool accordions clear on retry (no old+new accumulation)
  • Continuation messages after tool calls are cleaned up on retry
  • Branch navigation works correctly between alternatives
  • npm run test passes (142 tests)

🤖 Generated with Claude Code

ProfSynapse and others added 9 commits February 5, 2026 17:47
Phase 1 of chat stop/retry/branch bug fixes:

- AbortHandler: filter completed tool calls instead of wiping all (Bug #1)
- MessageAlternativeService: stop clearing toolCalls at retry start (Bug #2)
- MessageRepository: persist full tool call metadata in branch alternatives (Bug #5)
- MessageBranchNavigator: remove dead removeEventListener calls (Bug #6)
- New toolCallUtils.ts: shared filterCompletedToolCalls() utility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 2 of chat stop/retry/branch bug fixes:

- MessageDisplay: replace full re-render with incremental reconciliation
  - messageBubbles changed from array to Map<string, MessageBubble>
  - setConversation() reconciles incrementally for same conversation,
    full render for conversation switches
  - New reconcile() method: remove stale, update existing, create new
  - Proper cleanup/unload on removed bubbles (Bug #7)
  - Preserves live progressive tool accordions during updates (Bug #12)
- MessageBubble: cleanup() now calls unload() with double-call guard

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 3 of chat stop/retry/branch bug fixes:

- MessageAlternativeService: full refactor with staging pattern
  - Stream into cloned conversation (never mutate live object) (Bug #8)
  - CSS overlay instead of clearing content during retry (Bug #9)
  - Remove Object.assign reload after branch creation (Bug #3)
  - Concurrent retry guard via retryInProgress Set
  - Custom abort handler now uses filterCompletedToolCalls
  - Removed [Retry] debug console.log statements
- styles.css: added .message-retrying overlay with pulse animation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 4 of chat stop/retry/branch bug fixes:

- MessageBubble: dynamically create branch navigator when message
  gains branches during updateWithNewMessage() (Bug #4)
- BranchManager: return empty/undefined instead of falling through
  to original data when active branch has unloaded messages (Bug #10)
- ChatView: navigateToBranch() prefers in-memory conversation over
  stale storage load when branch is current conversation (Bug #11)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
136 tests (95 new + 41 existing), all passing:
- toolCallUtils: 14 tests (100% coverage)
- AbortHandler: 14 tests (100% coverage)
- MessageAlternativeService: 16 tests (91% stmt coverage)
- MessageRepository: 9 tests (serialization fidelity)
- BranchManager: 26 tests (branch data resolution)
- MessageBranchNavigator: 9 tests (lifecycle cleanup)
- MessageDisplay: 6 tests (reconciliation basics)

New infrastructure: fixtures/chatBugs.ts, mocks/chatService.ts,
updated obsidian.ts mock, manual E2E test plan

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
User feedback: overlay approach was wrong. New retry flow:
1. Save original content to branch FIRST (preserves old response)
2. Clear current message, show loading state
3. Stream new response directly (live conversation, not clone)
4. Branch arrows navigate between old and new responses

Fixes:
- Stop button works during retry (abort controller properly wired)
- No text leaking through overlay (overlay removed entirely)
- Content clears and restreams fresh as expected
- Removed .message-retrying CSS overlay styles
- Updated tests to match new flow (142 tests pass)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cancelCurrentGeneration() now calls alternativeService.cancel() to
abort the separate AbortController used during retry streaming.
Previously, stop only aborted MessageManager's own controller,
leaving retry streaming running.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When retrying an AI message that had tool calls with follow-up
responses, splice continuation messages out of the conversation
and preserve them in the branch. Prevents stale content from
appearing below the new streamed response.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MessageBubble.updateWithNewMessage() now destroys progressive tool
accordions and removes the tool/image bubble DOM when the updated
message has no tool calls. Prevents old tool calls from persisting
alongside new ones during retry streaming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ProfSynapse added a commit that referenced this pull request Feb 5, 2026
…rage (#16)

Fix 12 bugs in chat system's stop, retry, and branch navigation:
- Preserve tool calls on stop (AbortHandler filter fix)
- Fix serialization of tool call results (MessageRepository)
- Fix navigator memory leak (proper Component lifecycle)
- Implement incremental message reconciliation (Map-based)
- Clear-and-restream retry pattern (save original to branch first)
- Wire stop button to cancel retry/alternative streaming
- Clean up continuation messages on retry
- Clear tool accordions when message cleared during retry
- Ensure branch data loading and prevent stale messages
- 142 unit tests across 7 new test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant