feat(workspace): add context field for AI agent background info

Add a `context` text field to workspaces, allowing users to provide
background information and context for AI agents working in the
workspace. Full stack: migration, sqlc queries, Go handler, TS types,
SDK, and settings page UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
yushen 2026-03-24 15:59:11 +08:00
parent 3293607bef
commit 680668ffdb
11 changed files with 85 additions and 19 deletions

View file

@ -95,6 +95,7 @@ export default function SettingsPage() {
const [description, setDescription] = useState(
workspace?.description ?? "",
);
const [context, setContext] = useState(workspace?.context ?? "");
const [profileName, setProfileName] = useState(user?.name ?? "");
const [avatarUrl, setAvatarUrl] = useState(user?.avatar_url ?? "");
const [saving, setSaving] = useState(false);
@ -115,6 +116,7 @@ export default function SettingsPage() {
useEffect(() => {
setName(workspace?.name ?? "");
setDescription(workspace?.description ?? "");
setContext(workspace?.context ?? "");
}, [workspace]);
useEffect(() => {
@ -130,6 +132,7 @@ export default function SettingsPage() {
const updated = await api.updateWorkspace(workspace.id, {
name,
description: description || undefined,
context: context || undefined,
});
updateWorkspace(updated);
setSaved(true);
@ -330,6 +333,19 @@ export default function SettingsPage() {
placeholder="What does this workspace focus on?"
/>
</div>
<div>
<label className="text-xs font-medium text-muted-foreground">
Context
</label>
<textarea
value={context}
onChange={(e) => setContext(e.target.value)}
rows={4}
disabled={!canManageWorkspace}
className="mt-1 w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-none"
placeholder="Background information and context for AI agents working in this workspace"
/>
</div>
<div>
<label className="text-xs font-medium text-muted-foreground">
Slug

View file

@ -44,6 +44,7 @@ const mockWorkspace: Workspace = {
name: "Test WS",
slug: "test",
description: null,
context: null,
settings: {},
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
@ -322,6 +323,7 @@ describe("AuthContext", () => {
name: "Second WS",
slug: "second",
description: null,
context: null,
settings: {},
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
@ -374,6 +376,7 @@ describe("AuthContext", () => {
name: "New WS",
slug: "new-ws",
description: null,
context: null,
settings: {},
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",
@ -407,6 +410,7 @@ describe("AuthContext", () => {
name: "Second WS",
slug: "second",
description: null,
context: null,
settings: {},
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",

View file

@ -19,6 +19,7 @@ export const mockWorkspace: Workspace = {
name: "Test Workspace",
slug: "test-ws",
description: "A test workspace",
context: null,
settings: {},
created_at: "2026-01-01T00:00:00Z",
updated_at: "2026-01-01T00:00:00Z",