fix(tui): single seam for conversation-scoped state on swap - #572
Conversation
Partial clears across /clear, /resume, and task sync left manager-backed subagent rows and in-flight task-output reads attached to the restored session. Centralise the reset in reset_conversation_scoped_state (epoch, todos, staged media, subagent rows, pending task reads) and epoch-gate show_task_output.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17585da8a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.tasks | ||
| .retain(|t| t.source != super::tasks::TaskSource::Subagent); |
There was a problem hiding this comment.
Preserve task state when rewrite commands make no change
When a history-rewriting command fails or is a no-op—such as /resume <missing-id>, a disabled/invalid /snip, or /rewind with unusable arguments—the command handlers leave the engine messages unchanged, but run.rs still calls new_conversation() solely from slash_rewrites_conversation(&slash). This new retention filter then permanently removes completed subagent rows and their captured output, while the same reset also cancels any pending drill-in, even though the user remains in the original conversation; gate this reset on whether the command actually changed the history.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17585da8a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.tasks | ||
| .retain(|t| t.source != super::tasks::TaskSource::Subagent); |
There was a problem hiding this comment.
Keep manager-backed agents eligible for polling
When a bare /clear runs while idle and the only live TaskManager job is a LocalAgent, this filter removes the sole row that makes has_live_manager_tasks() true. The tasks_tick arm in run.rs is guarded by live || app.has_live_manager_tasks(), so the claimed re-entry through sync_background_tasks never occurs until unrelated work starts another turn; the running agent and its drill-in disappear from the pane. Preserve a poll trigger or perform an immediate manager sync after this reset.
Useful? React with 👍 / 👎.
| self.tasks | ||
| .retain(|t| t.source != super::tasks::TaskSource::Subagent); |
There was a problem hiding this comment.
Clamp the task selection after filtering rows
When /clear, /rewind, or /snip removes subagent rows while background rows remain, tasks_selected retains its old positional index. If the selected row moved or was removed, the renderer shows no selection and Enter is a no-op because drill_into_selected_task indexes with that stale value; resume avoids this only because adopt_restored_todos explicitly resets the index. Preserve the selected task or clamp the index as part of this reset.
Useful? React with 👍 / 👎.
Summary
App::reset_conversation_scoped_stateas the single list of conversation-owned state.new_conversation/ resume adopt use it; drops subagent rows and pending task-output reads.show_task_output_for_epochrefuses stale reads after a swap.Fixes #539.
Test plan
reset_conversation_scoped_state_drops_subagent_rows_and_pending_output