feat(webui): add lightweight session messaging via mentions
This commit is contained in:
1 parent
2bdb11eeba
commit
0e184965e8
76 files changed
+8297
-658
No files matched your search
+34
-11
@@ -23,6 +23,7 @@ import type {
|
||||
ProviderOAuthLoginResult,
|
||||
ProviderSettingsUpdate,
|
||||
SessionDeleteResult,
|
||||
SessionListHandle,
|
||||
SessionAutomationsPayload,
|
||||
SettingsPayload,
|
||||
SettingsUpdate,
|
||||
@@ -166,6 +167,22 @@ function splitKey(key: string): { channel: string; chatId: string } {
|
||||
return { channel: key.slice(0, idx), chatId: key.slice(idx + 1) };
|
||||
}
|
||||
|
||||
function normalizeSessionListHandle(value: unknown): SessionListHandle | null {
|
||||
if (!value || typeof value !== "object") return null;
|
||||
const handle = value as Partial<SessionListHandle>;
|
||||
const id = typeof handle.id === "string" ? handle.id.trim() : "";
|
||||
const name = typeof handle.name === "string" ? handle.name.trim() : "";
|
||||
if (
|
||||
!/^handle_[a-f0-9]{32}$/i.test(id)
|
||||
|| !name
|
||||
|| !/^[\p{L}\p{N}_-]+$/u.test(name)
|
||||
|| !Number.isInteger(handle.color_slot)
|
||||
|| (handle.color_slot ?? -1) < 0
|
||||
|| (handle.color_slot ?? 8) >= 8
|
||||
) return null;
|
||||
return { id, name, color_slot: handle.color_slot as number };
|
||||
}
|
||||
|
||||
export async function listSessions(
|
||||
token: string,
|
||||
base: string = "",
|
||||
@@ -179,6 +196,7 @@ export async function listSessions(
|
||||
model_preset?: string | null;
|
||||
run_started_at?: number | null;
|
||||
workspace_scope?: WorkspaceScopePayload | null;
|
||||
handle?: SessionListHandle | null;
|
||||
};
|
||||
const body = await request<{ sessions: Row[] }>(
|
||||
`${base}/api/sessions`,
|
||||
@@ -186,17 +204,22 @@ export async function listSessions(
|
||||
undefined,
|
||||
API_READ_TIMEOUT_MS,
|
||||
);
|
||||
return body.sessions.map((s) => ({
|
||||
key: s.key,
|
||||
...splitKey(s.key),
|
||||
createdAt: s.created_at,
|
||||
updatedAt: s.updated_at,
|
||||
title: s.title ?? "",
|
||||
preview: s.preview ?? "",
|
||||
modelPreset: s.model_preset ?? null,
|
||||
runStartedAt: s.run_started_at ?? null,
|
||||
workspaceScope: s.workspace_scope ?? null,
|
||||
}));
|
||||
return body.sessions.map((s) => {
|
||||
const rawSession = normalizeSessionListHandle(s.handle);
|
||||
const handle = rawSession ? { ...rawSession, session_key: s.key } : null;
|
||||
return {
|
||||
key: s.key,
|
||||
...splitKey(s.key),
|
||||
createdAt: s.created_at,
|
||||
updatedAt: s.updated_at,
|
||||
title: s.title ?? "",
|
||||
preview: s.preview ?? "",
|
||||
modelPreset: s.model_preset ?? null,
|
||||
runStartedAt: s.run_started_at ?? null,
|
||||
workspaceScope: s.workspace_scope ?? null,
|
||||
handle,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** Disk-backed WebUI display thread snapshot (separate from agent session). */
|
||||
|
||||
Reference in new issue
Block a user