Adds the "Who's using Ask?" picker (GET /api/ask/users), actor
resolution via x-ask-user (src/lib/agent/context.ts), and thread
persistence (src/lib/chat/threads.ts, /api/chat/threads routes).
/api/chat now accepts { threadId?, message, display?, images? } and
persists each turn as its own append-only ask_messages row; the old
{ history } body still works for one release. chat-view.tsx gained the
picker, a thread sidebar (new/select/rename/archive), and ?thread=<id>
in the URL.
Live browser check skipped: ask_threads/ask_messages/ask_log don't
exist yet in the target PocketBase (Task 1's schema is dry-run only,
pending the user's --apply). Covered by mocked unit tests instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
830 B
TypeScript
25 lines
830 B
TypeScript
/**
|
|
* GET /api/ask/users — the "Who's using Ask?" picker list.
|
|
*
|
|
* There are no logins yet, so Ask identifies people by having them pick
|
|
* their name from the existing `users` collection. Only records with a
|
|
* non-empty `name` are offered, and only `id`/`name` are sent — never
|
|
* email, which `users` also carries.
|
|
*/
|
|
import { pbAdmin } from "@/lib/pb";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET() {
|
|
const pb = await pbAdmin();
|
|
const rows = (await pb
|
|
.collection("users")
|
|
.getFullList({ sort: "name", fields: "id,name" })) as { id: string; name?: string }[];
|
|
|
|
const users = rows
|
|
.filter((r) => !!r.name && r.name.trim().length > 0)
|
|
.map((r) => ({ id: r.id, name: r.name!.trim() }))
|
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
|
|
return Response.json({ users });
|
|
}
|