Skip to content

Fix H-06: make /clear reset agent and session state#43

Merged
euxaristia merged 4 commits into
Cairn:mainfrom
PierrunoYT:fix/h-06-clear-reset-state
Jul 24, 2026
Merged

Fix H-06: make /clear reset agent and session state#43
euxaristia merged 4 commits into
Cairn:mainfrom
PierrunoYT:fix/h-06-clear-reset-state

Conversation

@PierrunoYT

Copy link
Copy Markdown
Collaborator

Summary

Fixes #19 (audit finding H-06).

/clear previously reset only visible TUI state, leaving the agent's messages, usage, and the shared live mirror intact. The next prompt retained supposedly cleared context, and autosave could copy old history into a new session — a false history/security boundary.

Changes

  • Add Agent::reset_state() to clear messages, usage, and last_input_tokens, then resync the live mirror. (Compaction state lives in messages/tokens, so it is covered.)
  • Route /clear through a new clear command so the agent thread resets atomically; also clear the live mirror from the TUI side.
  • Guard /clear against running turns (like /compact) so the reset is acknowledged only when idle, avoiding a race that could wipe a fresh response.
  • Confirm the clear to the user with a system line.

Testing

  • \cargo build\ clean
  • \cargo test\ — 223 passed, 0 failed

Closes #19

/clear previously reset only visible TUI state, leaving agent messages,
usage, and the live mirror intact. The next prompt retained supposedly
cleared context and autosave could copy old history into a new session.

- Add Agent::reset_state to clear messages, usage, and last_input_tokens
  and resync the live mirror (compaction state lives in messages/tokens).
- Route /clear through a __clear__ command so the agent thread resets
  atomically, and clear the live mirror from the TUI side too.
- Guard /clear against running turns (like /compact) so the reset is
  acknowledged only when idle, and confirm the clear to the user.

Closes Cairn#19
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@euxaristia, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f75d7787-4bb8-40bd-b95b-0c5fde6ba426

📥 Commits

Reviewing files that changed from the base of the PR and between 6fb0c41 and adab810.

📒 Files selected for processing (3)
  • src/agent.rs
  • src/main.rs
  • src/tui.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PierrunoYT added a commit to PierrunoYT/cairn-code that referenced this pull request Jul 23, 2026
@PierrunoYT
PierrunoYT force-pushed the fix/h-06-clear-reset-state branch from 9297f60 to ff417d4 Compare July 23, 2026 00:45

@euxaristia euxaristia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Verified clear resets agent and session state.

@euxaristia

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@euxaristia
euxaristia merged commit 4007538 into Cairn:main Jul 24, 2026
4 checks passed
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.

[High][H-06] Make /clear reset agent and session state

3 participants