feat(coding-agent): added /fresh to reset provider state while keeping session files
- Added `AgentSession.freshSession()` to rotate provider-facing IDs and prune provider stream state. - Added `/fresh` command handling in the builtin registry and mode command flow. - Kept persisted session metadata intact during `/fresh` and cleared transient IDs on session switches. - Invalidated `appendOnlyContext` and provider caches when refreshing provider state.
This commit is contained in:
@@ -802,6 +802,18 @@ export class CommandController {
|
||||
await this.#runNewSessionFlow();
|
||||
}
|
||||
|
||||
async handleFreshCommand(): Promise<void> {
|
||||
const result = this.ctx.session.freshSession();
|
||||
if (!result) {
|
||||
this.ctx.showWarning("Wait for the current response to finish or abort it before refreshing provider state.");
|
||||
return;
|
||||
}
|
||||
const stateLabel = result.closedProviderSessions === 1 ? "provider state" : "provider states";
|
||||
this.ctx.statusLine.invalidate();
|
||||
this.ctx.updateEditorTopBorder();
|
||||
this.ctx.showStatus(`Fresh provider session started (${result.closedProviderSessions} ${stateLabel} pruned).`);
|
||||
}
|
||||
|
||||
async handleDropCommand(): Promise<void> {
|
||||
if (!this.ctx.sessionManager.getSessionFile()) {
|
||||
this.ctx.showError("Nothing to drop (in-memory session)");
|
||||
|
||||
Reference in New Issue
Block a user