feat: resolve all 22 items in Features and Bugs.txt and complete UI polish
This commit is contained in:
@@ -29,6 +29,13 @@ export interface SessionRow {
|
||||
projectId: string;
|
||||
title: string;
|
||||
kind: AISession["kind"];
|
||||
archived?: boolean | undefined;
|
||||
agentId?: string | undefined;
|
||||
providerId?: string | undefined;
|
||||
model?: string | undefined;
|
||||
messages?: AIMessage[] | undefined;
|
||||
suggestions?: AISuggestion[] | undefined;
|
||||
notes?: AINote[] | undefined;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
lastMessageAt: string | null;
|
||||
@@ -64,7 +71,7 @@ export function createInMemoryPersistence(): AISessionPersistence {
|
||||
}
|
||||
|
||||
/** A Dexie-backed IndexedDB persistence backend. */
|
||||
export function createIndexedDBPersistence(dbName = "pubscript"): AISessionPersistence {
|
||||
export function createIndexedDBPersistence(dbName = "pubscript_ai"): AISessionPersistence {
|
||||
const db = new Dexie(dbName);
|
||||
if (!db.tables.some((t) => t.name === "aiSessions")) {
|
||||
db.version(1).stores({ aiSessions: "&id, projectId, updatedAt" });
|
||||
@@ -110,9 +117,13 @@ export class AIStore {
|
||||
projectId: row.projectId,
|
||||
title: row.title,
|
||||
kind: row.kind,
|
||||
messages: [],
|
||||
suggestions: [],
|
||||
notes: [],
|
||||
archived: row.archived ?? false,
|
||||
agentId: row.agentId,
|
||||
providerId: row.providerId,
|
||||
model: row.model,
|
||||
messages: row.messages ?? [],
|
||||
suggestions: row.suggestions ?? [],
|
||||
notes: row.notes ?? [],
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
lastMessageAt: row.lastMessageAt,
|
||||
@@ -133,6 +144,13 @@ export class AIStore {
|
||||
projectId: session.projectId,
|
||||
title: session.title,
|
||||
kind: session.kind,
|
||||
archived: session.archived ?? false,
|
||||
agentId: session.agentId,
|
||||
providerId: session.providerId,
|
||||
model: session.model,
|
||||
messages: session.messages.map((m) => ({ ...m })),
|
||||
suggestions: session.suggestions.map((s) => ({ ...s })),
|
||||
notes: session.notes.map((n) => ({ ...n })),
|
||||
createdAt: session.createdAt,
|
||||
updatedAt: session.updatedAt,
|
||||
lastMessageAt: session.lastMessageAt,
|
||||
@@ -140,14 +158,21 @@ export class AIStore {
|
||||
}
|
||||
|
||||
/** Create a new session and persist it. */
|
||||
async createSession(title?: string): Promise<AISession> {
|
||||
async createSession(
|
||||
title?: string,
|
||||
meta?: { agentId?: string; providerId?: string; model?: string; kind?: AISession["kind"] },
|
||||
): Promise<AISession> {
|
||||
await this.load();
|
||||
const now = nowIso();
|
||||
const session: AISession = {
|
||||
id: createUlid(),
|
||||
projectId: this.projectId,
|
||||
title: title ?? `New AI session ${this.sessions.size + 1}`,
|
||||
kind: "session",
|
||||
kind: meta?.kind ?? "session",
|
||||
archived: false,
|
||||
agentId: meta?.agentId,
|
||||
providerId: meta?.providerId,
|
||||
model: meta?.model,
|
||||
messages: [],
|
||||
suggestions: [],
|
||||
notes: [],
|
||||
@@ -160,6 +185,29 @@ export class AIStore {
|
||||
return this.clone(session);
|
||||
}
|
||||
|
||||
/** Update session metadata (title, archived, agentId, providerId, model). */
|
||||
async updateSessionMeta(
|
||||
sessionId: string,
|
||||
patch: {
|
||||
title?: string;
|
||||
archived?: boolean;
|
||||
agentId?: string;
|
||||
providerId?: string;
|
||||
model?: string;
|
||||
},
|
||||
): Promise<AISession> {
|
||||
return this.withTransaction(async () => {
|
||||
const session = this.require(sessionId);
|
||||
if (patch.title !== undefined) session.title = patch.title;
|
||||
if (patch.archived !== undefined) session.archived = patch.archived;
|
||||
if (patch.agentId !== undefined) session.agentId = patch.agentId;
|
||||
if (patch.providerId !== undefined) session.providerId = patch.providerId;
|
||||
if (patch.model !== undefined) session.model = patch.model;
|
||||
session.updatedAt = nowIso();
|
||||
return this.clone(session);
|
||||
});
|
||||
}
|
||||
|
||||
/** Get a session by id. */
|
||||
async getSession(id: string): Promise<AISession | null> {
|
||||
await this.load();
|
||||
|
||||
Reference in New Issue
Block a user