fix(ui): make prompt history ordering stable and recall just-sent prompts#3059
Open
cak3ninja wants to merge 2 commits into
Open
fix(ui): make prompt history ordering stable and recall just-sent prompts#3059cak3ninja wants to merge 2 commits into
cak3ninja wants to merge 2 commits into
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the Contributor License Agreement (CLA) and hereby sign the CLA. |
|
Does this address the problem of messages sent by main agent to sub-agents appear in prompt history? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2966
Problem 1 — Prompt history could appear in the wrong order
When several prompts were sent close together, navigating prompt history with ↑/↓ could list them out of order.
Root cause: history was sorted only by the message timestamp, which is stored with one-second granularity. Prompts created within the same second shared an identical timestamp and had no further tiebreaker, so their relative order was undefined.
Fix: sort by insertion order (
rowid) as a secondary key in addition to the timestamp. Same-second prompts now keep a deterministic, reverse-send order.Problem 2 — A just-sent prompt was missing from history
After sending a prompt, pressing ↑ — typically while the agent was still generating a response — would not bring back the prompt you had just sent.
Root cause: history was reloaded at the moment of submitting, in parallel with the message being saved. The reload almost always read the database before the new message was persisted, so it picked up a stale list, and nothing refreshed it afterwards.
Fix: reload prompt history when the user message is actually created (on the message-created event), and remove the racy submit-time reload. The just-sent prompt is now immediately available for recall, even mid-generation.
Tests
Unit test covering the navigation/reload behavior after submitting a prompt.
Integration test driving the real update loop to verify the message-created event actually triggers the history reload.
I have read
CONTRIBUTING.md.I have created a discussion that was approved by a maintainer (for new features).