Files
cobble/src/functions/backend/db/workspaces/grab-workspace-name.ts
T
tbenandClaude Opus 5.5 96d3227bd0 Name the workspace in a bot's task status line
A task running in a workspace shows "Working on a task in <name>
workspace", so the bot's own chat and the main rail say where the work
is. Outside a workspace it stays "Working on a task".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 19:22:25 +01:00

21 lines
609 B
TypeScript

import BunSQLite from "@moduletrace/bun-sqlite";
type Params = {
workspace_id?: number | string | null;
};
/**
* A workspace's name as it is, without an access check, for copy the
* caller already decided to show. Null when there's none.
*/
export default async function grabWorkspaceName({ workspace_id }: Params): Promise<string | null> {
if (!workspace_id) return null;
const res = await BunSQLite.sql<{ name: string | null }>({
sql: `SELECT name FROM workspaces WHERE id = ? LIMIT 1`,
values: [Number(workspace_id)],
});
return res.payload?.[0]?.name || null;
}