Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix(core): publish compaction lifecycle state#16397

Open
neriousy wants to merge 2 commits intoanomalyco:devfrom
neriousy:opencode/crisp-sailor
Open

fix(core): publish compaction lifecycle state#16397
neriousy wants to merge 2 commits intoanomalyco:devfrom
neriousy:opencode/crisp-sailor

Conversation

@neriousy
Copy link
Contributor

@neriousy neriousy commented Mar 6, 2026

Issue for this PR

Closes #16395

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The TUI has logic for a compacting session state, but the compaction flow never sets session.time.compacting.
As a result, running /compact only shows generic busy/working behavior and never a distinct compacting state.

This PR makes the 'compacting' status work.
Also added tests

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

  1. Go into a long session and trigger compaction
  2. Watch that session in the session list / status UI while the compaction pass is running.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Set and clear session compaction timestamps so the TUI can surface its compacting status and regressions stay covered.
Copilot AI review requested due to automatic review settings March 6, 2026 20:38
@neriousy neriousy changed the title fix(session): publish compaction lifecycle state fix(core): publish compaction lifecycle state Mar 6, 2026
@neriousy neriousy marked this pull request as draft March 6, 2026 20:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a long-standing UX gap where running /compact in an OpenCode session never displayed a distinct "compacting" state in the TUI session list — instead only showing generic busy/working behavior. The fix adds a Session.setCompacting function to persist the compacting timestamp into the database and publishes a Session.Updated bus event, then hooks it into SessionCompaction.process so the state is set at the start of compaction and reliably cleared afterward (via async resource disposal), even on failure.

Changes:

  • New Session.setCompacting function that persists the compacting start time to the DB and publishes an Updated event on the bus
  • SessionCompaction.process now sets the compacting state at entry and uses await using defer to clear it on both success and failure paths
  • Tests added for the new setCompacting API (lifecycle events) and for the compaction process state transitions (success and failure)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/opencode/src/session/index.ts Adds setCompacting function following the same setArchived/setTitle pattern, updating time_compacting in the DB and publishing a Session.Updated event
packages/opencode/src/session/compaction.ts Calls setCompacting at the start of process() and uses await using defer to guarantee the state is cleared when the function exits (normally or via exception)
packages/opencode/test/session/session.test.ts Adds a test verifying that setCompacting publishes correct bus events and that the state is cleared afterward
packages/opencode/test/session/compaction.test.ts Adds tests verifying the compacting lifecycle state during process() on success and on error; adds afterEach(() => mock.restore()) and related imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Adjust the compaction processor test stub so package typecheck passes without changing runtime behavior.
@neriousy neriousy marked this pull request as ready for review March 6, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compacting status never appears in TUI

2 participants