Archived
Fix automatic session title generation
This commit is contained in:
@@ -15,7 +15,7 @@ import { BUILTIN_COMMANDS } from "./builtinCommands.js";
|
||||
import { SessionCommandService } from "./sessionCommandService.js";
|
||||
import { SessionArchiveStore } from "./sessionArchiveStore.js";
|
||||
import type { ActiveSession } from "./sessionRuntimeStore.js";
|
||||
import { generateShortSessionName } from "./sessionNameGenerator.js";
|
||||
import { fallbackSessionName, generateShortSessionName } from "./sessionNameGenerator.js";
|
||||
|
||||
function noop(): void {
|
||||
// Intentionally empty default unsubscribe callback.
|
||||
@@ -263,14 +263,18 @@ export class PiSessionService {
|
||||
if (model === undefined) return;
|
||||
|
||||
void generateShortSessionName(this.modelRegistry, model, firstMessage).then((name) => {
|
||||
if (name === undefined || session.sessionName !== undefined) return;
|
||||
session.setSessionName(name);
|
||||
this.publishSessionName(session);
|
||||
this.applyGeneratedSessionName(session, name ?? fallbackSessionName(firstMessage));
|
||||
}).catch(() => {
|
||||
// Session naming is best-effort and must not affect prompt handling.
|
||||
this.applyGeneratedSessionName(session, fallbackSessionName(firstMessage));
|
||||
});
|
||||
}
|
||||
|
||||
private applyGeneratedSessionName(session: AgentSession, name: string | undefined): void {
|
||||
if (name === undefined || session.sessionName !== undefined) return;
|
||||
session.setSessionName(name);
|
||||
this.publishSessionName(session);
|
||||
}
|
||||
|
||||
private publishSessionName(session: AgentSession): void {
|
||||
const event = session.sessionName === undefined
|
||||
? { type: "session.name", sessionId: session.sessionId } as const
|
||||
|
||||
Reference in New Issue
Block a user