mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
Rename /clear to /new, update hook events to before_new/new
Closes #305 - took direct rename approach instead of alias system Thanks @mitsuhiko for the nudge!
This commit is contained in:
parent
0427445242
commit
454ea1d36a
11 changed files with 56 additions and 35 deletions
|
|
@ -517,14 +517,14 @@ export class AgentSession {
|
|||
const previousSessionFile = this.sessionFile;
|
||||
const entries = this.sessionManager.getEntries();
|
||||
|
||||
// Emit before_clear event (can be cancelled)
|
||||
// Emit before_new event (can be cancelled)
|
||||
if (this._hookRunner?.hasHandlers("session")) {
|
||||
const result = (await this._hookRunner.emit({
|
||||
type: "session",
|
||||
entries,
|
||||
sessionFile: this.sessionFile,
|
||||
previousSessionFile: null,
|
||||
reason: "before_clear",
|
||||
reason: "before_new",
|
||||
})) as SessionEventResult | undefined;
|
||||
|
||||
if (result?.cancel) {
|
||||
|
|
@ -539,7 +539,7 @@ export class AgentSession {
|
|||
this._queuedMessages = [];
|
||||
this._reconnectToAgent();
|
||||
|
||||
// Emit session event with reason "clear" to hooks
|
||||
// Emit session event with reason "new" to hooks
|
||||
if (this._hookRunner) {
|
||||
this._hookRunner.setSessionFile(this.sessionFile);
|
||||
await this._hookRunner.emit({
|
||||
|
|
@ -547,12 +547,12 @@ export class AgentSession {
|
|||
entries: [],
|
||||
sessionFile: this.sessionFile,
|
||||
previousSessionFile,
|
||||
reason: "clear",
|
||||
reason: "new",
|
||||
});
|
||||
}
|
||||
|
||||
// Emit session event to custom tools
|
||||
await this._emitToolSessionEvent("clear", previousSessionFile);
|
||||
await this._emitToolSessionEvent("new", previousSessionFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ export interface SessionEvent {
|
|||
entries: SessionEntry[];
|
||||
/** Current session file path, or null in --no-session mode */
|
||||
sessionFile: string | null;
|
||||
/** Previous session file path, or null for "start" and "clear" */
|
||||
/** Previous session file path, or null for "start" and "new" */
|
||||
previousSessionFile: string | null;
|
||||
/** Reason for the session event */
|
||||
reason: "start" | "switch" | "branch" | "clear";
|
||||
reason: "start" | "switch" | "branch" | "new";
|
||||
}
|
||||
|
||||
/** Rendering options passed to renderResult */
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ interface SessionEventBase {
|
|||
entries: SessionEntry[];
|
||||
/** Current session file path, or null in --no-session mode */
|
||||
sessionFile: string | null;
|
||||
/** Previous session file path, or null for "start" and "clear" */
|
||||
/** Previous session file path, or null for "start" and "new" */
|
||||
previousSessionFile: string | null;
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ interface SessionEventBase {
|
|||
* Lifecycle:
|
||||
* - start: Initial session load
|
||||
* - before_switch / switch: Session switch (e.g., /resume command)
|
||||
* - before_clear / clear: Session clear (e.g., /clear command)
|
||||
* - before_new / new: New session (e.g., /new command)
|
||||
* - before_branch / branch: Session branch (e.g., /branch command)
|
||||
* - before_compact / compact: Before/after context compaction
|
||||
* - shutdown: Process exit (SIGINT/SIGTERM)
|
||||
|
|
@ -120,7 +120,7 @@ interface SessionEventBase {
|
|||
*/
|
||||
export type SessionEvent =
|
||||
| (SessionEventBase & {
|
||||
reason: "start" | "switch" | "clear" | "before_switch" | "before_clear" | "shutdown";
|
||||
reason: "start" | "switch" | "new" | "before_switch" | "before_new" | "shutdown";
|
||||
})
|
||||
| (SessionEventBase & {
|
||||
reason: "branch" | "before_branch";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue