Skip to content

fix: restored sidebar state after session reload - #3003

Open
ljie-PI wants to merge 2 commits into
avante-corp:mainfrom
ljie-PI:showing_generating_when_completed
Open

fix: restored sidebar state after session reload#3003
ljie-PI wants to merge 2 commits into
avante-corp:mainfrom
ljie-PI:showing_generating_when_completed

Conversation

@ljie-PI

@ljie-PI ljie-PI commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • persist sidebar session state in chat history so restored sessions keep their last terminal state
  • stop inferring generating from replayed assistant text messages during history/session restore
  • only allow replayed intermediate states like thinking and active tool calling to override state while a request is actually active

Why

Restoring a previous session could show the wrong sidebar state because current_state was not persisted and was re-inferred from replayed history messages. This was especially visible with ACP providers like opencode, where restored history could incorrectly replace a finished state such as succeeded with generating or thinking.

Changes

  • add last_state to persisted chat history
  • restore current_state from persisted history on reload
  • save state transitions through on_state_change()
  • remove the fallback that treated non-tool, non-thinking messages as generating
  • gate replay-driven intermediate state updates on whether the current state is part of an active request

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Apr 11, 2026
@ljie-PI

ljie-PI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Any feedback on this? @yetone

@github-actions github-actions Bot removed the Stale label Apr 15, 2026
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Apr 29, 2026
@ljie-PI

ljie-PI commented May 2, 2026

Copy link
Copy Markdown
Contributor Author

don't we need this?

@github-actions github-actions Bot removed the Stale label May 3, 2026
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label May 17, 2026
@teto

teto commented May 19, 2026

Copy link
Copy Markdown
Collaborator

I noticed there were issues in master. I will have a look after a few other merges.

@github-actions github-actions Bot removed the Stale label May 20, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Jun 8, 2026
@teto teto removed the Stale label Jun 8, 2026
Comment thread lua/avante/sidebar.lua
if Config.prompt_logger.enabled then PromptLogger.log_prompt(request) end

if self.is_generating then
if is_active_request_state(self.current_state) then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe self.request_pending() ?

@teto

teto commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

persist sidebar session state in chat history so restored sessions keep their last terminal state
stop inferring generating from replayed assistant text messages during history/session restore

I am not familiar with the code and all the states but it seems odd that we would have to store the state.
Inferring state makes sense at first glance, with the caveat that if when loading it from history, one could override it so it doesn't show as pending.
When reloading (or before saving state), I would assume that we can't set something to an active/pending state. That is we shouldn't have a "generating"/"searching"/"thinking" after loading from history but just a final state like "failed"/"cancelled"/"succeeded" ?

Eventually we can look at what other harnesses do and copy their behavior

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Jun 23, 2026
@teto

teto commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

do you have a way to reproduce the issue to check this fixes the issue ?

@github-actions github-actions Bot removed the Stale label Jul 9, 2026
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.

2 participants