Skip to content

Conversation

warpdev
Copy link
Contributor

@warpdev warpdev commented Aug 29, 2025

Fixes #2755
Replaces #2757 to fix root cause.

Summary

Replace fragile string-based detection of user messages with typed metadata and span indices for backtracking. Only User messages are typed in this PR; others remain Other.

Root cause

Backtrack relied on rendered text parsing (“user” header join/trim), which loses type info and misidentifies boundaries.

Fix

  • Add MessageKind and MessageSpan to HistoryCell (defaults keep existing cells unchanged).
  • Introduce UserHistoryCell and return it from new_user_prompt (rendering unchanged).
  • Track absolute user spans in App (user_spans: Vec<(header_abs, end_abs)>). Other spans is not necessary now.
  • Refactor backtrack helpers to use spans (no string parsing).

Before

2025-08-29.2.07.37.mov

After

2025-08-29.2.06.51.mov

@warpdev warpdev force-pushed the fix/user-message-span branch 5 times, most recently from 9026a37 to 25c14d1 Compare September 3, 2025 03:44
@warpdev warpdev changed the title fix(tui): reliably detect UserMessage boundaries via typed spans Bug fix: reliably detect UserMessage boundaries via typed spans Sep 3, 2025
@warpdev
Copy link
Contributor Author

warpdev commented Sep 3, 2025

Update: Here’s the result video after the TUI rework(#2877).

Before

2025-09-03.12.40.25.mov

After

2025-09-03.12.39.21.mov

@warpdev warpdev force-pushed the fix/user-message-span branch from 25c14d1 to 57370c7 Compare September 3, 2025 12:17
@warpdev
Copy link
Contributor Author

warpdev commented Sep 4, 2025

Hi — This PR fixes a bug where Resume may select the wrong user message. When you have a moment, could you please take a look so others don’t run into it? Thank you! @nornagon-openai @easong-openai @bolinfest

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.

Message edit mixes last user message with "stream error … retrying…" text
1 participant