mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-06 23:44:36 +00:00
feat(agent): support clearing session names
This commit is contained in:
parent
c185d41238
commit
7bdb16c28d
12 changed files with 69 additions and 32 deletions
|
|
@ -606,7 +606,7 @@ class SqliteSessionStorage implements SessionStorage<SqliteSessionMetadata> {
|
|||
kind: "fact" as const,
|
||||
seq: row.seq,
|
||||
fact: "name" as const,
|
||||
name: JSON.parse(row.value ?? "null") as string,
|
||||
name: row.value === null ? undefined : (JSON.parse(row.value) as string),
|
||||
};
|
||||
return {
|
||||
kind: "fact" as const,
|
||||
|
|
@ -627,10 +627,10 @@ class SqliteSessionStorage implements SessionStorage<SqliteSessionMetadata> {
|
|||
return row?.value === undefined || row.value === null ? undefined : (JSON.parse(row.value) as string);
|
||||
}
|
||||
|
||||
async setName(name: string): Promise<void> {
|
||||
async setName(name: string | undefined): Promise<void> {
|
||||
return this.enqueueWrite(() => {
|
||||
const seq = getNextSequence(this.db, this.metadata.id);
|
||||
appendFact(this.db, this.metadata.id, seq, "name", null, JSON.stringify(name));
|
||||
appendFact(this.db, this.metadata.id, seq, "name", null, name === undefined ? null : JSON.stringify(name));
|
||||
advanceSequence(this.db, this.metadata.id, seq);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,10 +98,8 @@ export function deleteSessionRow(db: SqliteDatabase, sessionId: string) {
|
|||
sql`DELETE FROM sessions WHERE id = ${sessionId}`.run(db);
|
||||
}
|
||||
|
||||
function parseSessionName(value: string | null, sessionId: string): string {
|
||||
if (value === null) {
|
||||
throw new SessionError("storage", `Invalid SQLite session ${sessionId}: name must be a string`);
|
||||
}
|
||||
function parseSessionName(value: string | null, sessionId: string): string | undefined {
|
||||
if (value === null) return undefined;
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue