⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
feat: rework the agent chat as a right side panel with session tabs (#204)
Croffe1f68be54f40
diff --git a/apps/api/src/modules/agents/chat/__tests__/integration/agent-chat.test.ts b/apps/api/src/modules/agents/chat/__tests__/integration/agent-chat.test.tsindex 68aa37d7..3680d787 100644--- a/apps/api/src/modules/agents/chat/__tests__/integration/agent-chat.test.ts+++ b/apps/api/src/modules/agents/chat/__tests__/integration/agent-chat.test.ts@@ -151,7 +151,7 @@ describe('external agent chat', () => {});const threads = await chatOf(asOwner, agent.id).threads.get();- expect(threads.data!.find((t) => t.id === sent.data!.threadId)!.cliSessionId).toBe(+ expect(threads.data!.items.find((t) => t.id === sent.data!.threadId)!.cliSessionId).toBe('sess-first',);});@@ -161,7 +161,7 @@ describe('external agent chat', () => {const sent = await send(asOwner, agent.id, 'Status?');const before = await chatOf(asOwner, agent.id).threads.get();- expect(before.data!.find((t) => t.id === sent.data!.threadId)!.cliSessionId).toBeNull();+ expect(before.data!.items.find((t) => t.id === sent.data!.threadId)!.cliSessionId).toBeNull();const answer = (await asRunner['agent-chats'].claim.post()).data!.message!;await asRunner['agent-chats']({ messageId: answer.id }).events.post({@@ -170,7 +170,9 @@ describe('external agent chat', () => {});const after = await chatOf(asOwner, agent.id).threads.get();- expect(after.data!.find((t) => t.id === sent.data!.threadId)!.cliSessionId).toBe('sess-abc');+ expect(after.data!.items.find((t) => t.id === sent.data!.threadId)!.cliSessionId).toBe(+ 'sess-abc',+ );});it('hands a claimed answer to no one else until its lease expires', async () => {@@ -387,17 +389,35 @@ describe('external agent chat', () => {).toBe(404);});+ it("renames an external agent's conversation", async () => {+ const { asOwner, agent } = await setup();+ const sent = await send(asOwner, agent.id, 'First question');++ expect(+ (+ await chatOf(asOwner, agent.id)+ .threads({ threadId: sent.data!.threadId })+ .patch({ title: 'Release plan' })+ ).status,+ ).toBe(204);+ expect((await chatOf(asOwner, agent.id).threads.get()).data!.items[0].title).toBe(+ 'Release plan',+ );+ });+it('lists and deletes the conversations of an external agent', async () => {const { asOwner, agent } = await setup();const sent = await send(asOwner, agent.id, 'First question');const threads = await chatOf(asOwner, agent.id).threads.get();- expect(threads.data!).toMatchObject([{ id: sent.data!.threadId, title: 'First question' }]);+ expect(threads.data!.items).toMatchObject([+ { id: sent.data!.threadId, title: 'First question' },+ ]);expect((await chatOf(asOwner, agent.id).threads({ threadId: sent.data!.threadId }).delete()).status,).toBe(204);- expect((await chatOf(asOwner, agent.id).threads.get()).data!).toEqual([]);+ expect((await chatOf(asOwner, agent.id).threads.get()).data!.items).toEqual([]);});it("refuses another member's thread and another agent's answer", async () => {diff --git a/apps/api/src/modules/agents/chat/service.ts b/apps/api/src/modules/agents/chat/service.tsindex 861029b2..03b70dad 100644--- a/apps/api/src/modules/agents/chat/service.ts+++ b/apps/api/src/modules/agents/chat/service.ts@@ -4,9 +4,9 @@ import { setTimeout as sleep } from 'node:timers/promises';import { iso } from '#shared/lib';import { appendTextPart } from '../chat-parts';import { intEnv } from '../core/helpers/env';-import { projectPreamble } from '../core/prompt/framing';+import { chartPreamble, projectPreamble } from '../core/prompt/framing';import { peoplePreamble, type Person } from '../core/prompt/run-context';-import type { ChatMessagePage, ChatPart, ChatThreadSummary } from '../model';+import type { ChatMessagePage, ChatPart, ChatThreadPage } from '../model';import { newChatThreadId } from '../core/runtime/thread-ids';import { touchRunner, type RunnerAgent } from '../runner/service';import type { AgUiEventBody, ChatMessageStatus } from './model';@@ -48,20 +48,28 @@ const EVENT_PAGE = 500;// these take events, heartbeats and a result.const LIVE_STATUSES = ['pending', 'streaming'];-// The caller's conversations with one external agent, newest first.-export async function listThreads(userId: string, agentId: number): Promise<ChatThreadSummary[]> {+// One page of the caller's conversations with one external agent, newest first.+export async function listThreads(+ userId: string,+ agentId: number,+ page = 0,+): Promise<ChatThreadPage> {const rows = await db.select().from(agentChatThread).where(and(eq(agentChatThread.agentId, agentId), eq(agentChatThread.userId, userId)))- .orderBy(desc(agentChatThread.updatedAt));- return rows.map((r) => ({+ .orderBy(desc(agentChatThread.updatedAt))+ .limit(PAGE_SIZE + 1)+ .offset(page * PAGE_SIZE);+ const hasMore = rows.length > PAGE_SIZE;+ const items = (hasMore ? rows.slice(0, PAGE_SIZE) : rows).map((r) => ({id: r.id,title: r.title && r.title.length > 0 ? r.title : null,cliSessionId: r.cliSessionId,createdAt: iso(r.createdAt),updatedAt: iso(r.updatedAt),}));+ return { items, nextPage: hasMore ? page + 1 : null };}// One page of a thread's transcript, oldest first within the page, page 0 being the@@ -169,6 +177,21 @@ async function readAnswerParts(messageIds: number[]): Promise<Map<number, ChatPareturn parts;}+// Renames one of the caller's conversations. False when it is not theirs, which the+// route maps to a 404.+export async function renameThread(+ threadId: string,+ userId: string,+ title: string,+): Promise<boolean> {+ const rows = await db+ .update(agentChatThread)+ .set({ title: title.slice(0, TITLE_LIMIT), updatedAt: new Date() })+ .where(and(eq(agentChatThread.id, threadId), eq(agentChatThread.userId, userId)))+ .returning({ id: agentChatThread.id });+ return rows.length > 0;+}+export async function deleteThread(threadId: string, userId: string): Promise<boolean> {const rows = await db.delete(agentChatThread)@@ -398,6 +421,7 @@ function buildSystemPrompt(agent: RunnerAgent, requester: Person): string {return (projectPreamble({ key: agent.projectKey, name: agent.projectName }) +chatModePreamble() ++ chartPreamble() +peoplePreamble({ requester }) +(instructions ? `## Instructions\n${instructions}\n` : ''));diff --git a/apps/api/src/modules/agents/core/__tests__/integration/agent-threads.test.ts b/apps/api/src/modules/agents/core/__tests__/integration/agent-threads.test.tsindex 864b7f9a..e3ea1e5f 100644--- a/apps/api/src/modules/agents/core/__tests__/integration/agent-threads.test.ts+++ b/apps/api/src/modules/agents/core/__tests__/integration/agent-threads.test.ts@@ -9,6 +9,7 @@ import { ensureThread, buildMemory } from '../../runtime/memory';// GET /projects/:key/ai-agents/:agentId/threads — the caller's own chat// threads with the agent// GET .../ai-agents/:agentId/threads/:threadId/messages — one thread's transcript+// PATCH .../ai-agents/:agentId/threads/:threadId — rename one conversation// DELETE .../ai-agents/:agentId/threads/:threadId — delete one conversation//// plus the thread scoping of a chat run: the thread id names the agent and the user it@@ -100,7 +101,7 @@ describe('agent chat history', () => {const res = await agents(asOwner)({ agentId: agent.id }).threads.get();expect(res.status).toBe(200);- expect(res.data).toEqual([]);+ expect(res.data!.items).toEqual([]);});it("lists the caller's threads for the agent, newest first, with the title", async () => {@@ -112,8 +113,8 @@ describe('agent chat history', () => {const res = await agents(asOwner)({ agentId: agent.id }).threads.get();expect(res.status).toBe(200);- expect(res.data!.map((t) => t.id)).toEqual(['t-new', 't-old']);- expect(res.data![0]).toMatchObject({ id: 't-new', title: 'newer question' });+ expect(res.data!.items.map((t) => t.id)).toEqual(['t-new', 't-old']);+ expect(res.data!.items[0]).toMatchObject({ id: 't-new', title: 'newer question' });});it('scopes threads to the requesting user', async () => {@@ -124,7 +125,25 @@ describe('agent chat history', () => {await seedThread('theirs', 'another-user-id', agent, 'theirs');const res = await agents(asOwner)({ agentId: agent.id }).threads.get();- expect(res.data!.map((t) => t.id)).toEqual(['mine']);+ expect(res.data!.items.map((t) => t.id)).toEqual(['mine']);+ });++ it('hands out the threads a page at a time, newest first', async () => {+ const { owner, asOwner } = await setup();+ const agent = await createInternalAgent(asOwner, 'Design Bot', 'design');+ // One more than a page holds, so the last one falls onto the second page.+ for (let i = 0; i < 26; i++) await seedThread(`t-${i}`, owner.userId, agent, `question ${i}`);++ const first = await agents(asOwner)({ agentId: agent.id }).threads.get();+ expect(first.data!.items).toHaveLength(25);+ expect(first.data!.nextPage).toBe(1);++ const second = await agents(asOwner)({ agentId: agent.id }).threads.get({ query: { page: 1 } });+ expect(second.data!.items).toHaveLength(1);+ expect(second.data!.nextPage).toBeNull();+ // No thread is on both pages.+ const ids = new Set([...first.data!.items, ...second.data!.items].map((t) => t.id));+ expect(ids.size).toBe(26);});it('scopes threads to the requested agent', async () => {@@ -134,9 +153,9 @@ describe('agent chat history', () => {await seedThread('for-a', owner.userId, a, 'for a');const res = await agents(asOwner)({ agentId: b.id }).threads.get();- expect(res.data).toEqual([]);+ expect(res.data!.items).toEqual([]);const resA = await agents(asOwner)({ agentId: a.id }).threads.get();- expect(resA.data!.map((t) => t.id)).toEqual(['for-a']);+ expect(resA.data!.items.map((t) => t.id)).toEqual(['for-a']);});it('404s the thread list for an agent that does not exist', async () => {@@ -285,6 +304,31 @@ describe('agent chat history', () => {expect(res.status).toBe(404);});+ it("renames the caller's thread", async () => {+ const { owner, asOwner } = await setup();+ const agent = await createInternalAgent(asOwner, 'Design Bot', 'design');+ await seedThread('mine', owner.userId, agent, 'Untitled');++ const res = await agents(asOwner)({ agentId: agent.id })+ .threads({ threadId: 'mine' })+ .patch({ title: 'Release plan' });+ expect(res.status).toBe(204);++ const list = await agents(asOwner)({ agentId: agent.id }).threads.get();+ expect(list.data!.items[0].title).toBe('Release plan');+ });++ it("404s renaming another user's thread", async () => {+ const { asOwner } = await setup();+ const agent = await createInternalAgent(asOwner, 'Design Bot', 'design');+ await seedThread('theirs', 'another-user-id', agent, 'theirs');++ const res = await agents(asOwner)({ agentId: agent.id })+ .threads({ threadId: 'theirs' })+ .patch({ title: 'Mine now' });+ expect(res.status).toBe(404);+ });+it("deletes the caller's thread with its messages", async () => {const { owner, asOwner } = await setup();const agent = await createInternalAgent(asOwner, 'Design Bot', 'design');@@ -294,7 +338,7 @@ describe('agent chat history', () => {expect(res.status).toBe(204);const list = await agents(asOwner)({ agentId: agent.id }).threads.get();- expect(list.data).toEqual([]);+ expect(list.data!.items).toEqual([]);const messages = await agents(asOwner)({ agentId: agent.id }).threads({ threadId: 'mine' }).messages.get();diff --git a/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.ts b/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.tsindex cca0913c..7eec7244 100644--- a/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.ts+++ b/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.ts@@ -609,6 +609,7 @@ describe('ai agents', () => {'POST /projects/:projectKey/ai-agents/:agentId/run/stream','GET /projects/:projectKey/ai-agents/:agentId/threads','GET /projects/:projectKey/ai-agents/:agentId/threads/:threadId/messages',+ 'PATCH /projects/:projectKey/ai-agents/:agentId/threads/:threadId','DELETE /projects/:projectKey/ai-agents/:agentId/threads/:threadId','POST /projects/:projectKey/ai-agents/:agentId/chat','GET /projects/:projectKey/ai-agents/:agentId/chat/:messageId/events',diff --git a/apps/api/src/modules/agents/core/index.ts b/apps/api/src/modules/agents/core/index.tsindex 8445f1d9..aef7fa51 100644--- a/apps/api/src/modules/agents/core/index.ts+++ b/apps/api/src/modules/agents/core/index.ts@@ -22,26 +22,34 @@ import {ChatMessagesResponse,ChatThreadListResponse,CreateAgentResponse,+ renameThreadBody,RegenerateKeyResponse,RunAgentResponse,agentParams,createAgentBody,runBody,runsQuery,- threadMessagesQuery,+ threadPageQuery,threadParams,updateAgentBody,} from './model';import { runAgent, streamAgent, type AgentRunEvent, type RunOpts } from './runtime';import { peoplePreamble } from './prompt/run-context';+import { chartPreamble } from './prompt/framing';import type { SessionUser } from '#shared/auth-context';import { listAgentRuns } from './run-queue';-import { listChatThreads, getChatThreadMessages, deleteChatThread } from './runtime/memory';+import {+ listChatThreads,+ getChatThreadMessages,+ deleteChatThread,+ renameChatThread,+} from './runtime/memory';import { isOwnChatThread } from './runtime/thread-ids';import {listThreads as listExternalThreads,getThreadMessages as getExternalThreadMessages,deleteThread as deleteExternalThread,+ renameThread as renameExternalThread,} from '../chat/service';// Run options for an interactive chat run (the test chat): the caller owns the memory@@ -56,9 +64,14 @@ function chatRunOpts(user: SessionUser | null, agentId: number, threadId?: strinreturn {callerUserId: caller.id,threadId: threadId ?? null,- contextPreamble: peoplePreamble({- requester: { name: user?.name ?? caller.email ?? 'User', username: user?.username ?? null },- }),+ contextPreamble:+ chartPreamble() ++ peoplePreamble({+ requester: {+ name: user?.name ?? caller.email ?? 'User',+ username: user?.username ?? null,+ },+ }),};}@@ -74,9 +87,15 @@ function threadStore(kind: AgentKind) {? {list: listExternalThreads,messages: getExternalThreadMessages,+ rename: renameExternalThread,remove: deleteExternalThread,}- : { list: listChatThreads, messages: getChatThreadMessages, remove: deleteChatThread };+ : {+ list: listChatThreads,+ messages: getChatThreadMessages,+ rename: renameChatThread,+ remove: deleteChatThread,+ };}export const aiAgentRoutes = new Elysia({ name: 'ai-agents', detail: { tags: ['AI Agents'] } })@@ -284,18 +303,20 @@ export const aiAgentRoutes = new Elysia({ name: 'ai-agents', detail: { tags: ['A},)- // The caller's own chat threads with this agent, newest first. Scoped to the- // caller (the thread's owner), so a user only sees their own conversations.+ // The caller's own chat threads with this agent, newest first, a page at a time.+ // Scoped to the caller (the thread's owner), so a user only sees their own+ // conversations..get('/projects/:projectKey/ai-agents/:agentId/threads',- async ({ params, project, user }) => {+ async ({ params, project, query, user }) => {const caller = requireUser(user);const agent = await getAgentById(params.agentId, project.id);if (!agent) throw new HttpError(404, 'Agent not found');- return threadStore(agent.kind).list(caller.id, params.agentId);+ return threadStore(agent.kind).list(caller.id, params.agentId, query.page);},{params: agentParams,+ query: threadPageQuery,permission: ['ai_agents', 'read'],response: { 200: ChatThreadListResponse, ...commonErrors },detail: { summary: 'List chat threads' },@@ -320,13 +341,34 @@ export const aiAgentRoutes = new Elysia({ name: 'ai-agents', detail: { tags: ['A},{params: threadParams,- query: threadMessagesQuery,+ query: threadPageQuery,permission: ['ai_agents', 'read'],response: { 200: ChatMessagesResponse, ...commonErrors },detail: { summary: 'Get thread messages' },},)+ // Renames one of the caller's chat threads. Scoped the same way as reading it: a+ // thread owned by another user is a 404.+ .patch(+ '/projects/:projectKey/ai-agents/:agentId/threads/:threadId',+ async ({ params, project, body, user }) => {+ const caller = requireUser(user);+ const agent = await getAgentById(params.agentId, project.id);+ if (!agent) throw new HttpError(404, 'Agent not found');+ const renamed = await threadStore(agent.kind).rename(params.threadId, caller.id, body.title);+ if (!renamed) throw new HttpError(404, 'Thread not found');+ return noContent();+ },+ {+ params: threadParams,+ body: renameThreadBody,+ permission: ['ai_agents', 'read'],+ response: { 204: t.Void(), ...commonErrors },+ detail: { summary: 'Rename a chat thread' },+ },+ )+// Deletes one of the caller's chat threads with its messages. Scoped the same way as// reading it: a thread owned by another user is a 404..delete(diff --git a/apps/api/src/modules/agents/core/model.ts b/apps/api/src/modules/agents/core/model.tsindex 267b8ad9..420f67d8 100644--- a/apps/api/src/modules/agents/core/model.ts+++ b/apps/api/src/modules/agents/core/model.ts@@ -219,7 +219,11 @@ export const ChatMessagesResponse = t.Object({export const AiAgentListResponse = t.Array(AiAgentResponse);-export const ChatThreadListResponse = t.Array(ChatThreadResponse);+// One page of a caller's chat threads with an agent (ChatThreadPage).+export const ChatThreadListResponse = t.Object({+ items: t.Array(ChatThreadResponse),+ nextPage: t.Nullable(t.Number()),+});export const createAgentBody = t.Object({name: t.String({ minLength: 1, description: 'Display name.' }),@@ -241,4 +245,9 @@ export const runsQuery = t.Object({limit: t.Optional(t.Numeric()),});-export const threadMessagesQuery = t.Object({ page: t.Optional(t.Numeric({ minimum: 0 })) });+export const renameThreadBody = t.Object({+ title: t.String({ minLength: 1, maxLength: 80, description: 'New title of the conversation.' }),+});++// Both the thread list and a thread's transcript are read a page at a time.+export const threadPageQuery = t.Object({ page: t.Optional(t.Numeric({ minimum: 0 })) });diff --git a/apps/api/src/modules/agents/core/prompt/framing.ts b/apps/api/src/modules/agents/core/prompt/framing.tsindex 5c2162e7..8115d0a9 100644--- a/apps/api/src/modules/agents/core/prompt/framing.ts+++ b/apps/api/src/modules/agents/core/prompt/framing.ts@@ -140,6 +140,18 @@ export function projectPreamble(project: { key: string; name: string }): string].join('\n');}+// Only the chat paths carry this: a chart is drawn where the answer is read in the+// app, while an autonomous run writes its answer into a comment, which draws none.+export function chartPreamble(): string {+ return [+ '## Charts',+ 'When the person asks for a chart or a graph, build it with the create_chart tool',+ 'and put the block it gives back into your answer instead of drawing one as text.',+ '',+ '',+ ].join('\n');+}+export function peopleContext(run: RunForPrompt): string {const requester: Person | null = run.requesterName? { name: run.requesterName, username: run.requesterUsername ?? null }diff --git a/apps/api/src/modules/agents/core/runtime/memory.ts b/apps/api/src/modules/agents/core/runtime/memory.tsindex 61834e83..030e3157 100644--- a/apps/api/src/modules/agents/core/runtime/memory.ts+++ b/apps/api/src/modules/agents/core/runtime/memory.ts@@ -2,7 +2,7 @@ import { Memory } from '@mastra/memory';import { PostgresStore } from '@mastra/pg';import { toIso } from '../helpers/dates';import { appendTextPart, toolArgsText, toolText } from '../../chat-parts';-import type { ChatMessageDTO, ChatMessagePage, ChatPart, ChatThreadSummary } from '../../model';+import type { ChatMessageDTO, ChatMessagePage, ChatPart, ChatThreadPage } from '../../model';// Conversation memory for internal agents. Threads and their messages are// persisted in a Postgres-backed store (Mastra manages its own tables), reusing@@ -21,6 +21,11 @@ import type { ChatMessageDTO, ChatMessagePage, ChatPart, ChatThreadSummary } fro// Default recency window when an agent has memory enabled but no count set.export const DEFAULT_LAST_MESSAGES = 20;+const THREAD_PAGE_SIZE = 25;+// The length a title is cut to, the same for one the agent was given and one a member+// typed.+const TITLE_LIMIT = 80;+let store: PostgresStore | null = null;function getStore(): PostgresStore {@@ -74,12 +79,26 @@ export async function ensureThread(await memory.createThread({threadId,resourceId,- title: title.slice(0, 80),+ title: title.slice(0, TITLE_LIMIT),metadata: meta,saveThread: true,});}+// Renames one of the caller's chat threads. Returns false when the thread does not+// exist or belongs to someone else, so the caller maps it to a 404.+export async function renameChatThread(+ threadId: string,+ resourceId: string,+ title: string,+): Promise<boolean> {+ const memory = getReadMemory();+ const thread = await memory.getThreadById({ threadId, resourceId });+ if (!thread) return false;+ await memory.updateThread({ id: threadId, title: title.slice(0, TITLE_LIMIT) });+ return true;+}+// Deletes one of the caller's chat threads with its messages. Returns false when the// thread does not exist or belongs to someone else, so the caller maps it to a 404.export async function deleteChatThread(threadId: string, resourceId: string): Promise<boolean> {@@ -102,25 +121,28 @@ export async function deleteThreadsWhere(return threads.length;}-// Lists a user's chat threads with one agent, newest first. Scoped by resourceId+// One page of a user's chat threads with one agent, newest first. Scoped by resourceId// (the caller) and the agent binding in metadata, so a caller only ever sees their// own conversations with that agent.export async function listChatThreads(resourceId: string,agentId: number,-): Promise<ChatThreadSummary[]> {+ page = 0,+): Promise<ChatThreadPage> {const res = await getReadMemory().listThreads({filter: { resourceId, metadata: { agentId, kind: 'chat' } },orderBy: { field: 'updatedAt', direction: 'DESC' },- perPage: false,+ perPage: THREAD_PAGE_SIZE,+ page,});- return res.threads.map((t) => ({+ const items = res.threads.map((t) => ({id: t.id,title: t.title && t.title.length > 0 ? t.title : null,cliSessionId: null,createdAt: toIso(t.createdAt),updatedAt: toIso(t.updatedAt),}));+ return { items, nextPage: res.hasMore ? page + 1 : null };}// Loads the transcript of one chat thread for the given owner. Returns null whendiff --git a/apps/api/src/modules/agents/model.ts b/apps/api/src/modules/agents/model.tsindex 2d2a2970..8c02d078 100644--- a/apps/api/src/modules/agents/model.ts+++ b/apps/api/src/modules/agents/model.ts@@ -60,3 +60,8 @@ export type ChatMessagePage = {items: ChatMessageDTO[];nextPage: number | null;};++export type ChatThreadPage = {+ items: ChatThreadSummary[];+ nextPage: number | null;+};diff --git a/apps/api/src/modules/user-preferences/model.ts b/apps/api/src/modules/user-preferences/model.tsindex 83fdc218..bed8a604 100644--- a/apps/api/src/modules/user-preferences/model.ts+++ b/apps/api/src/modules/user-preferences/model.ts@@ -15,7 +15,6 @@ const StartPage = t.Union([t.Literal('dashboard'),t.Literal('work-items'),t.Literal('initiatives'),- t.Literal('ai-chat'),]);const IssueStatsView = t.Union([t.Literal('compact'), t.Literal('timeline')]);const IssueActivityView = t.Union([t.Literal('flat'), t.Literal('grouped')]);diff --git a/apps/api/src/modules/user-preferences/service.ts b/apps/api/src/modules/user-preferences/service.tsindex 5c1449c0..73c712b2 100644--- a/apps/api/src/modules/user-preferences/service.ts+++ b/apps/api/src/modules/user-preferences/service.ts@@ -12,7 +12,7 @@ export const DEFAULT_TIMEZONE = 'UTC';export const THEMES = ['light', 'dark', 'system'] as const;export const ISSUE_OPEN_MODES = ['panel', 'page'] as const;-export const START_PAGES = ['inbox', 'dashboard', 'work-items', 'initiatives', 'ai-chat'] as const;+export const START_PAGES = ['inbox', 'dashboard', 'work-items', 'initiatives'] as const;export const ISSUE_STATS_VIEWS = ['compact', 'timeline'] as const;export const ISSUE_ACTIVITY_VIEWS = ['flat', 'grouped'] as const;diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex bc649be6..536b2556 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -95,6 +95,9 @@ next-intl, language from the `NEXT_LOCALE` cookie — no `[locale]` route segmenoutside `@layer`: Tailwind orders its layers `theme, base, components, utilities`, so anythingin `@layer components` loses to the utility classes on the element. When the change is a propthe component already exposes (`Sidebar side`), pass it from the caller rather than writing CSS.+ One prop reaches neither the caller nor CSS and has to be re-applied after a re-add:+ `chart.tsx` passes `debounce` to recharts' `ResponsiveContainer`, without which a chart in a+ container that resizes itself loops until React reports "Maximum update depth exceeded".- Tailwind v4: no `tailwind.config`; tokens live in `src/app/globals.css` (`@theme`, CSS vars).- `NEXT_PUBLIC_*` are build-time — set them in `apps/web/.env` before `next build`, or asweb Dockerfile build args.diff --git a/apps/web/messages/ar/account.json b/apps/web/messages/ar/account.jsonindex f2b359ad..2fe3fa5f 100644--- a/apps/web/messages/ar/account.json+++ b/apps/web/messages/ar/account.json@@ -128,8 +128,7 @@"work-items": "عناصر العمل","inbox": "صندوق الوارد","dashboard": "لوحات المعلومات",- "initiatives": "المبادرات",- "ai-chat": "محادثة الذكاء الاصطناعي"+ "initiatives": "المبادرات"},"showStats": "إظهار الإحصاءات","showStatsDescription": "قسم الإحصاءات يبدأ مفتوح ولا مقفول لما تفتح مهمة.",@@ -148,6 +147,6 @@"autoWatch": "متابعة المهام تلقائيًا","autoWatchDescription": "المهام اللي تنشئها أو تتسند ليك أو تعلّق عليها أو يتذكر اسمك فيها.","showChatByDefault": "إظهار المحادثة افتراضيًا",- "showChatByDefaultDescription": "زر المحادثة هيفضل ظاهر في المشروع، ونافذة المحادثة مش هتتفتح غير لما تدوس عليه."+ "showChatByDefaultDescription": "تفتح لوحة المحادثة مع صفحة المشروع. أغلقها في أي وقت من رأسها أو من أيقونة المحادثة."}}diff --git a/apps/web/messages/ar/aiChat.json b/apps/web/messages/ar/aiChat.jsonindex e83cca20..ca863fd9 100644--- a/apps/web/messages/ar/aiChat.json+++ b/apps/web/messages/ar/aiChat.json@@ -1,22 +1,18 @@{- "noAccess": "مالكش صلاحية توصل لوكلاء الذكاء الاصطناعي في المشروع ده.",+ "chatPanel": "محادثة الذكاء الاصطناعي",+ "pushMode": "تثبيت اللوحة",+ "overlayMode": "إلغاء تثبيت اللوحة",+ "resizePanel": "تغيير عرض لوحة المحادثة","emptyTitle": "لا يوجد وكلاء للمحادثة","emptyDescription": "اتكلم مع وكيل من وكلاء المشروع: وكيل داخلي، أو وكيل خارجي من خلال الرانر بتاعه.","createAgent": "إنشاء وكيل","agents": "الوكلاء",- "agentsAvailable": "{count, plural, zero {مفيش وكلاء متاحين} one {وكيل واحد متاح} two {وكيلين متاحين} few {# وكلاء متاحين} many {# وكيل متاح} other {# وكيل متاح}}",- "chats": "المحادثات","newChat": "محادثة جديدة",- "memoryOff": "الذاكرة معطّلة",- "noAgents": "لا يوجد وكلاء",- "addAgent": "إضافة وكيل",- "noAgentsYet": "لا يوجد وكلاء للمحادثة بعد.",+ "closeTab": "إغلاق علامة التبويب",+ "renameThread": "إعادة تسمية المحادثة",+ "renameHint": "انقر نقرًا مزدوجًا لإعادة التسمية",+ "moreTabs": "محادثات أخرى ({count})","history": "السجلّ",- "backToChat": "العودة إلى المحادثة",- "minimize": "تصغير",- "minimizeChat": "تصغير المحادثة",- "openChat": "فتح المحادثة",- "hideChat": "إخفاء المحادثة","untitledThread": "محادثة جديدة","deleteThread": "حذف المحادثة","deleteThreadConfirm": "سيُحذف «{title}» ورسائله نهائيًا.",diff --git a/apps/web/messages/ar/common.json b/apps/web/messages/ar/common.jsonindex a06847be..d14f8bc6 100644--- a/apps/web/messages/ar/common.json+++ b/apps/web/messages/ar/common.json@@ -58,6 +58,9 @@"sidebar": {"toggle": "إظهار الشريط الجانبي أو إخفاؤه"},+ "chat": {+ "toggle": "إظهار محادثة الذكاء الاصطناعي أو إخفاؤها"+ },"issue": {"new": "مهمة جديدة"},@@ -78,6 +81,7 @@"messagePlaceholder": "راسل {agent}…","reset": "إعادة تعيين المحادثة","send": "إرسال",+ "sendHint": "اضغط Enter للإرسال، وCtrl/⌘+Enter لسطر جديد","stop": "إيقاف","stopped": "أُوقف","loadingEarlier": "جارٍ تحميل الرسائل السابقة…",diff --git a/apps/web/messages/ar/nav.json b/apps/web/messages/ar/nav.jsonindex 0017c3fa..6c4b7056 100644--- a/apps/web/messages/ar/nav.json+++ b/apps/web/messages/ar/nav.json@@ -7,8 +7,6 @@"cycles": "الدورات (cycles)","notes": "الملاحظات","aiTeam": "فريق الذكاء الاصطناعي",- "chat": "المحادثة",- "chatWithAiTeam": "محادثة فريق الذكاء الاصطناعي","configure": "تهيئة","aiAgents": "وكلاء الذكاء الاصطناعي (AI agents)","configuration": "التهيئة",@@ -34,7 +32,7 @@"search": "ابحث أو نفّذ أمرًا…","searchHint": "ابحث أو نفّذ أمرًا ({key})","newIssueHint": "مهمة جديدة ({key})",- "aiChat": "محادثة الذكاء الاصطناعي",+ "aiChatHint": "الدردشة مع فريق الذكاء الاصطناعي ({key})","sections": "الأقسام","doubleClickToRename": "انقر نقرًا مزدوجًا لإعادة التسمية","groups": {diff --git a/apps/web/messages/ar/palette.json b/apps/web/messages/ar/palette.jsonindex e43f31a2..3d8be493 100644--- a/apps/web/messages/ar/palette.json+++ b/apps/web/messages/ar/palette.json@@ -6,6 +6,7 @@"selectAllIssues": "تحديد كل المهام","newIssue": "مهمة جديدة","newProject": "مشروع جديد",+ "toggleChat": "إظهار محادثة الذكاء الاصطناعي أو إخفاؤها","board": "اللوحة","commands": "الأوامر","switchProject": "تبديل المشروع"diff --git a/apps/web/messages/en/account.json b/apps/web/messages/en/account.jsonindex 63071e1a..46031556 100644--- a/apps/web/messages/en/account.json+++ b/apps/web/messages/en/account.json@@ -128,8 +128,7 @@"work-items": "Work items","inbox": "Inbox","dashboard": "Dashboards",- "initiatives": "Initiatives",- "ai-chat": "AI chat"+ "initiatives": "Initiatives"},"showStats": "Show stats","showStatsDescription": "Whether the stats section starts expanded when you open an issue.",@@ -147,7 +146,7 @@},"autoWatch": "Watch issues automatically","autoWatchDescription": "The ones you create, get assigned, comment on, or are mentioned in.",- "showChatByDefault": "Show chat by default",- "showChatByDefaultDescription": "The chat button stays on screen in a project. The chat window opens only when you click it."+ "showChatByDefault": "Show the chat by default",+ "showChatByDefaultDescription": "The chat panel opens with a project page. Close it any time from its header or the chat icon."}}diff --git a/apps/web/messages/en/aiChat.json b/apps/web/messages/en/aiChat.jsonindex 0327617c..979d2355 100644--- a/apps/web/messages/en/aiChat.json+++ b/apps/web/messages/en/aiChat.json@@ -1,22 +1,18 @@{- "noAccess": "You do not have access to AI agents in this project.",+ "chatPanel": "AI chat",+ "pushMode": "Dock the panel",+ "overlayMode": "Float the panel",+ "resizePanel": "Resize the chat panel","emptyTitle": "No agents to chat with","emptyDescription": "Chat with an agent of this project: an internal one, or an external one through its runner.","createAgent": "Create an agent","agents": "Agents",- "agentsAvailable": "{count, plural, one {# agent} other {# agents}} available",- "chats": "Chats","newChat": "New chat",- "memoryOff": "Memory off",- "noAgents": "No agents",- "addAgent": "Add an agent",- "noAgentsYet": "No agents to chat with yet.",+ "closeTab": "Close the tab",+ "renameThread": "Rename chat",+ "renameHint": "Double-click to rename",+ "moreTabs": "More chats ({count})","history": "History",- "backToChat": "Back to chat",- "minimize": "Minimize",- "minimizeChat": "Minimize chat",- "openChat": "Open chat",- "hideChat": "Hide chat","untitledThread": "New conversation","deleteThread": "Delete conversation","deleteThreadConfirm": "“{title}” and its messages are deleted permanently.",diff --git a/apps/web/messages/en/common.json b/apps/web/messages/en/common.jsonindex fe95fcdd..26594abc 100644--- a/apps/web/messages/en/common.json+++ b/apps/web/messages/en/common.json@@ -58,6 +58,9 @@"sidebar": {"toggle": "Show or hide the sidebar"},+ "chat": {+ "toggle": "Show or hide the AI chat"+ },"issue": {"new": "New issue"},@@ -78,6 +81,7 @@"messagePlaceholder": "Message {agent}…","reset": "Reset conversation","send": "Send",+ "sendHint": "Enter to send, ⌘/Ctrl+Enter for a new line","stop": "Stop","stopped": "Stopped","loadingEarlier": "Loading earlier messages…",diff --git a/apps/web/messages/en/nav.json b/apps/web/messages/en/nav.jsonindex 38d5ef5b..09bfa861 100644--- a/apps/web/messages/en/nav.json+++ b/apps/web/messages/en/nav.json@@ -7,8 +7,6 @@"cycles": "Cycles","notes": "Notes","aiTeam": "AI Team",- "chat": "Chat",- "chatWithAiTeam": "Chat with AI Team","configure": "Configure","aiAgents": "AI agents","configuration": "Configuration",@@ -34,7 +32,7 @@"search": "Search or run a command…","searchHint": "Search or run a command ({key})","newIssueHint": "New issue ({key})",- "aiChat": "AI chat",+ "aiChatHint": "Chat with your AI teammates ({key})","sections": "Sections","doubleClickToRename": "Double-click to rename","groups": {diff --git a/apps/web/messages/en/palette.json b/apps/web/messages/en/palette.jsonindex 23c8c263..0b690048 100644--- a/apps/web/messages/en/palette.json+++ b/apps/web/messages/en/palette.json@@ -6,6 +6,7 @@"selectAllIssues": "Select all issues","newIssue": "New issue","newProject": "New project",+ "toggleChat": "Show or hide the AI chat","board": "Board","commands": "Commands","switchProject": "Switch project"diff --git a/apps/web/messages/ru/account.json b/apps/web/messages/ru/account.jsonindex 4b3923ad..8a353e67 100644--- a/apps/web/messages/ru/account.json+++ b/apps/web/messages/ru/account.json@@ -128,8 +128,7 @@"work-items": "Задачи","inbox": "Входящие","dashboard": "Дашборды",- "initiatives": "Инициативы",- "ai-chat": "AI-чат"+ "initiatives": "Инициативы"},"showStats": "Показывать статистику","showStatsDescription": "Развёрнут ли блок статистики, когда вы открываете задачу.",@@ -147,7 +146,7 @@},"autoWatch": "Автоматически следить за задачами","autoWatchDescription": "За теми, которые вы создаёте, получаете, комментируете или где вас упоминают.",- "showChatByDefault": "Показывать чат по умолчанию",- "showChatByDefaultDescription": "Кнопка чата остаётся на экране в проекте. Окно чата открывается только по клику."+ "showChatByDefault": "Показывать чат сразу",+ "showChatByDefaultDescription": "Панель чата открывается вместе со страницей проекта. Закрыть её можно в её шапке или иконкой чата."}}diff --git a/apps/web/messages/ru/aiChat.json b/apps/web/messages/ru/aiChat.jsonindex 4cb6ae9f..32cb8c8b 100644--- a/apps/web/messages/ru/aiChat.json+++ b/apps/web/messages/ru/aiChat.json@@ -1,22 +1,18 @@{- "noAccess": "У вас нет доступа к AI-агентам в этом проекте.",+ "chatPanel": "ИИ-чат",+ "pushMode": "Закрепить панель",+ "overlayMode": "Открепить панель",+ "resizePanel": "Изменить ширину панели чата","emptyTitle": "Нет агентов для чата","emptyDescription": "Общайтесь с агентом проекта: внутренним или внешним через его раннер.","createAgent": "Создать агента","agents": "Агенты",- "agentsAvailable": "Доступно: {count, plural, one {# агент} few {# агента} many {# агентов} other {# агента}}",- "chats": "Чаты","newChat": "Новый чат",- "memoryOff": "Память выключена",- "noAgents": "Нет агентов",- "addAgent": "Добавьте агента",- "noAgentsYet": "Агентов для чата пока нет.",+ "closeTab": "Закрыть вкладку",+ "renameThread": "Переименовать чат",+ "renameHint": "Двойной клик, чтобы переименовать",+ "moreTabs": "Ещё чаты ({count})","history": "История",- "backToChat": "Назад к чату",- "minimize": "Свернуть",- "minimizeChat": "Свернуть чат",- "openChat": "Открыть чат",- "hideChat": "Скрыть чат","untitledThread": "Новый разговор","deleteThread": "Удалить разговор","deleteThreadConfirm": "«{title}» и его сообщения будут удалены навсегда.",diff --git a/apps/web/messages/ru/common.json b/apps/web/messages/ru/common.jsonindex 7b377117..8296d5e9 100644--- a/apps/web/messages/ru/common.json+++ b/apps/web/messages/ru/common.json@@ -58,6 +58,9 @@"sidebar": {"toggle": "Показать или скрыть боковую панель"},+ "chat": {+ "toggle": "Показать или скрыть ИИ-чат"+ },"issue": {"new": "Новая задача"},@@ -78,6 +81,7 @@"messagePlaceholder": "Сообщение для {agent}…","reset": "Сбросить разговор","send": "Отправить",+ "sendHint": "Enter — отправить, ⌘/Ctrl+Enter — новая строка","stop": "Остановить","stopped": "Остановлено","loadingEarlier": "Загрузка предыдущих сообщений…",diff --git a/apps/web/messages/ru/nav.json b/apps/web/messages/ru/nav.jsonindex 1392d4a6..5df91ee9 100644--- a/apps/web/messages/ru/nav.json+++ b/apps/web/messages/ru/nav.json@@ -7,8 +7,6 @@"cycles": "Циклы","notes": "Заметки","aiTeam": "AI-команда",- "chat": "Чат",- "chatWithAiTeam": "Чат с AI-командой","configure": "Настроить","aiAgents": "AI-агенты","configuration": "Конфигурация",@@ -34,7 +32,7 @@"search": "Поиск или команда…","searchHint": "Поиск или команда ({key})","newIssueHint": "Новая задача ({key})",- "aiChat": "AI-чат",+ "aiChatHint": "Чат с ИИ-командой ({key})","sections": "Разделы","doubleClickToRename": "Двойной клик, чтобы переименовать","groups": {diff --git a/apps/web/messages/ru/palette.json b/apps/web/messages/ru/palette.jsonindex d8ab44db..616699c4 100644--- a/apps/web/messages/ru/palette.json+++ b/apps/web/messages/ru/palette.json@@ -6,6 +6,7 @@"selectAllIssues": "Выбрать все задачи","newIssue": "Новая задача","newProject": "Новый проект",+ "toggleChat": "Показать или скрыть ИИ-чат","board": "Доска","commands": "Команды","switchProject": "Сменить проект"diff --git a/apps/web/messages/uk/account.json b/apps/web/messages/uk/account.jsonindex ea70393b..7fd642fa 100644--- a/apps/web/messages/uk/account.json+++ b/apps/web/messages/uk/account.json@@ -128,8 +128,7 @@"work-items": "Задачі","inbox": "Вхідні","dashboard": "Дашборди",- "initiatives": "Ініціативи",- "ai-chat": "AI-чат"+ "initiatives": "Ініціативи"},"showStats": "Показувати статистику","showStatsDescription": "Чи розгорнутий блок статистики, коли ви відкриваєте задачу.",@@ -147,7 +146,7 @@},"autoWatch": "Автоматично стежити за задачами","autoWatchDescription": "За тими, які ви створюєте, отримуєте, коментуєте або де вас згадують.",- "showChatByDefault": "Показувати чат за замовчуванням",- "showChatByDefaultDescription": "Кнопка чату залишається на екрані в проєкті. Вікно чату відкривається лише за кліком."+ "showChatByDefault": "Показувати чат одразу",+ "showChatByDefaultDescription": "Панель чату відкривається разом зі сторінкою проєкту. Закрити її можна в її шапці або іконкою чату."}}diff --git a/apps/web/messages/uk/aiChat.json b/apps/web/messages/uk/aiChat.jsonindex f50107d1..b18f2b83 100644--- a/apps/web/messages/uk/aiChat.json+++ b/apps/web/messages/uk/aiChat.json@@ -1,22 +1,18 @@{- "noAccess": "У вас немає доступу до AI-агентів у цьому проєкті.",+ "chatPanel": "ШІ-чат",+ "pushMode": "Закріпити панель",+ "overlayMode": "Відкріпити панель",+ "resizePanel": "Змінити ширину панелі чату","emptyTitle": "Немає агентів для чату","emptyDescription": "Спілкуйтеся з агентом проєкту: внутрішнім або зовнішнім через його раннер.","createAgent": "Створити агента","agents": "Агенти",- "agentsAvailable": "Доступно: {count, plural, one {# агент} few {# агенти} many {# агентів} other {# агента}}",- "chats": "Чати","newChat": "Новий чат",- "memoryOff": "Памʼять вимкнена",- "noAgents": "Немає агентів",- "addAgent": "Додайте агента",- "noAgentsYet": "Агентів для чату ще немає.",+ "closeTab": "Закрити вкладку",+ "renameThread": "Перейменувати чат",+ "renameHint": "Подвійний клік, щоб перейменувати",+ "moreTabs": "Ще чати ({count})","history": "Історія",- "backToChat": "Назад до чату",- "minimize": "Згорнути",- "minimizeChat": "Згорнути чат",- "openChat": "Відкрити чат",- "hideChat": "Сховати чат","untitledThread": "Нова розмова","deleteThread": "Видалити розмову","deleteThreadConfirm": "«{title}» та її повідомлення буде видалено назавжди.",diff --git a/apps/web/messages/uk/common.json b/apps/web/messages/uk/common.jsonindex 0164850f..2999b52b 100644--- a/apps/web/messages/uk/common.json+++ b/apps/web/messages/uk/common.json@@ -58,6 +58,9 @@"sidebar": {"toggle": "Показати або сховати бічну панель"},+ "chat": {+ "toggle": "Показати або сховати ШІ-чат"+ },"issue": {"new": "Нова задача"},@@ -78,6 +81,7 @@"messagePlaceholder": "Повідомлення для {agent}…","reset": "Скинути розмову","send": "Надіслати",+ "sendHint": "Enter — надіслати, ⌘/Ctrl+Enter — новий рядок","stop": "Зупинити","stopped": "Зупинено","loadingEarlier": "Завантаження попередніх повідомлень…",diff --git a/apps/web/messages/uk/nav.json b/apps/web/messages/uk/nav.jsonindex d66b218b..ed0522b9 100644--- a/apps/web/messages/uk/nav.json+++ b/apps/web/messages/uk/nav.json@@ -7,8 +7,6 @@"cycles": "Цикли","notes": "Нотатки","aiTeam": "AI-команда",- "chat": "Чат",- "chatWithAiTeam": "Чат з AI-командою","configure": "Налаштувати","aiAgents": "AI-агенти","configuration": "Конфігурація",@@ -34,7 +32,7 @@"search": "Пошук або команда…","searchHint": "Пошук або команда ({key})","newIssueHint": "Нова задача ({key})",- "aiChat": "AI-чат",+ "aiChatHint": "Чат зі ШІ-командою ({key})","sections": "Розділи","doubleClickToRename": "Подвійний клік, щоб перейменувати","groups": {diff --git a/apps/web/messages/uk/palette.json b/apps/web/messages/uk/palette.jsonindex bacc51e1..85ceb674 100644--- a/apps/web/messages/uk/palette.json+++ b/apps/web/messages/uk/palette.json@@ -6,6 +6,7 @@"selectAllIssues": "Вибрати всі задачі","newIssue": "Нова задача","newProject": "Новий проєкт",+ "toggleChat": "Показати або сховати ШІ-чат","board": "Дошка","commands": "Команди","switchProject": "Змінити проєкт"diff --git a/apps/web/messages/zh-CN/account.json b/apps/web/messages/zh-CN/account.jsonindex 625f9b97..0f6b2360 100644--- a/apps/web/messages/zh-CN/account.json+++ b/apps/web/messages/zh-CN/account.json@@ -128,8 +128,7 @@"work-items": "工作项","inbox": "收件箱","dashboard": "仪表盘",- "initiatives": "计划",- "ai-chat": "AI 聊天"+ "initiatives": "计划"},"showStats": "显示统计","showStatsDescription": "打开工作项时是否默认展开统计区域。",@@ -147,7 +146,7 @@},"autoWatch": "自动关注工作项","autoWatchDescription": "自动关注你创建、获指派、评论或被提及的工作项。",- "showChatByDefault": "默认显示聊天入口",- "showChatByDefaultDescription": "在项目中始终显示聊天按钮,点击后才打开聊天窗口。"+ "showChatByDefault": "默认显示聊天",+ "showChatByDefaultDescription": "打开项目页面时同时打开聊天面板。可随时通过面板标题栏或聊天图标关闭。"}}diff --git a/apps/web/messages/zh-CN/aiChat.json b/apps/web/messages/zh-CN/aiChat.jsonindex 748a34d2..28a4b544 100644--- a/apps/web/messages/zh-CN/aiChat.json+++ b/apps/web/messages/zh-CN/aiChat.json@@ -1,22 +1,18 @@{- "noAccess": "你无权访问此项目的 AI 代理。",+ "chatPanel": "AI 聊天",+ "pushMode": "固定面板",+ "overlayMode": "浮动面板",+ "resizePanel": "调整聊天面板宽度","emptyTitle": "暂无可对话的代理","emptyDescription": "与本项目的代理对话:内置代理,或通过运行器连接的外部代理。","createAgent": "新建代理","agents": "代理",- "agentsAvailable": "{count, plural, other {# 个代理可用}}",- "chats": "对话","newChat": "新建对话",- "memoryOff": "记忆已关闭",- "noAgents": "暂无代理",- "addAgent": "添加代理",- "noAgentsYet": "暂无可对话的代理。",+ "closeTab": "关闭标签页",+ "renameThread": "重命名对话",+ "renameHint": "双击重命名",+ "moreTabs": "更多聊天({count})","history": "历史记录",- "backToChat": "返回对话",- "minimize": "最小化",- "minimizeChat": "最小化聊天窗口",- "openChat": "打开聊天",- "hideChat": "隐藏聊天","untitledThread": "新对话","deleteThread": "删除对话","deleteThreadConfirm": "将永久删除“{title}”及其中的消息。",diff --git a/apps/web/messages/zh-CN/common.json b/apps/web/messages/zh-CN/common.jsonindex c384356f..21c3f8bd 100644--- a/apps/web/messages/zh-CN/common.json+++ b/apps/web/messages/zh-CN/common.json@@ -58,6 +58,9 @@"sidebar": {"toggle": "显示或隐藏侧边栏"},+ "chat": {+ "toggle": "显示或隐藏 AI 聊天"+ },"issue": {"new": "新建工作项"},@@ -78,6 +81,7 @@"messagePlaceholder": "给 {agent} 发送消息…","reset": "重置对话","send": "发送",+ "sendHint": "Enter 发送,⌘/Ctrl+Enter 换行","stop": "停止","stopped": "已停止","loadingEarlier": "正在加载更早的消息…",diff --git a/apps/web/messages/zh-CN/nav.json b/apps/web/messages/zh-CN/nav.jsonindex 632f8c70..41b520b6 100644--- a/apps/web/messages/zh-CN/nav.json+++ b/apps/web/messages/zh-CN/nav.json@@ -7,8 +7,6 @@"cycles": "周期","notes": "便签","aiTeam": "AI 团队",- "chat": "聊天",- "chatWithAiTeam": "与 AI 团队聊天","configure": "配置","aiAgents": "AI 代理","configuration": "配置",@@ -34,7 +32,7 @@"search": "搜索或运行命令…","searchHint": "搜索或运行命令({key})","newIssueHint": "新建工作项({key})",- "aiChat": "AI 聊天",+ "aiChatHint": "与 AI 队友聊天({key})","sections": "功能区","doubleClickToRename": "双击重命名","groups": {diff --git a/apps/web/messages/zh-CN/palette.json b/apps/web/messages/zh-CN/palette.jsonindex a32412f7..e14455e5 100644--- a/apps/web/messages/zh-CN/palette.json+++ b/apps/web/messages/zh-CN/palette.json@@ -6,6 +6,7 @@"selectAllIssues": "选择所有工作项","newIssue": "新建工作项","newProject": "新建项目",+ "toggleChat": "显示或隐藏 AI 聊天","board": "看板","commands": "命令","switchProject": "切换项目"diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.cssindex b91d8938..37ec4d05 100644--- a/apps/web/src/app/globals.css+++ b/apps/web/src/app/globals.css@@ -123,7 +123,13 @@--kanban-card-selected: oklch(0.925 0.04 265);--overlay-shadow: 0 12px 28px -8px rgb(0 0 0 / 0.18), 0 4px 10px -4px rgb(0 0 0 / 0.1);--pinned-column-shadow: 0 0 18px 2px rgb(0 0 0 / 0.16);+ /* A panel on a side edge casts to the side, so the glow has no offset. */+ --side-panel-shadow: 0 0 28px 6px rgb(0 0 0 / 0.16);--modal-shadow: 0 32px 64px -16px rgb(0 0 0 / 0.28), 0 12px 24px -12px rgb(0 0 0 / 0.16);+ /* The chat tab row casts down on the transcript under it; the composer is a+ rounded surface the transcript scrolls up to, so it casts all round. */+ --chat-tabs-shadow: 0 10px 16px -6px rgb(0 0 0 / 0.28);+ --chat-composer-shadow: 0 -2px 20px 2px rgb(0 0 0 / 0.22);}.dark {@@ -176,7 +182,10 @@--kanban-card-selected: oklch(0.31 0.07 266);--overlay-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.7), 0 6px 16px -6px rgb(0 0 0 / 0.55);--pinned-column-shadow: 0 0 20px 4px rgb(0 0 0 / 0.6);+ --side-panel-shadow: 0 0 28px 8px rgb(0 0 0 / 0.65);--modal-shadow: 0 40px 80px -20px rgb(0 0 0 / 0.85), 0 16px 32px -16px rgb(0 0 0 / 0.7);+ --chat-tabs-shadow: 0 12px 18px -6px rgb(0 0 0 / 0.75);+ --chat-composer-shadow: 0 -2px 22px 4px rgb(0 0 0 / 0.7);}/* Every floating surface lifts off the page with the same shadow. It is set here@@ -201,6 +210,22 @@box-shadow: var(--modal-shadow);}+/* The composer's own box casts the shadow, not the row around it. Set here because+ the input group is a generated component carrying a `shadow-xs` of its own, which+ tailwind-merge does not drop for a `shadow-[var(…)]` utility — it reads that as a+ shadow colour. */+.chat-composer [data-slot='input-group'] {+ box-shadow: var(--chat-composer-shadow);+}++/* The class the generated message scroller puts on its viewport, with no rule of+ its own. A message the composer cuts at the bottom edge fades out there instead+ of ending mid-glyph; the transcript's own bottom padding is deeper than the fade,+ so the last message is whole once it is scrolled to. */+.scroll-fade-b {+ mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5rem), transparent);+}+/* Kanban card surface — it sits on --kanban-column, so it is lighter than thecolumn in both themes, and it changes its own background on hover instead ofhighlighting the border. */diff --git a/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsx b/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsxindex 6c819318..c8dd9f75 100644--- a/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsx+++ b/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsx@@ -1,5 +1,10 @@-import AiChatPage from '@/features/ai-chat/AiChatPage';+import { redirect } from 'next/navigation';+import { aiTeamPath } from '@/utils/paths';+import { AI_TEAM_SECTIONS } from '@/utils/settingsSections';-export default function Page() {- return <AiChatPage />;+// The chat is a panel now, so its old path has no page of its own and sends the+// viewer to the first AI Team section.+export default async function Page({ params }: { params: Promise<{ projectKey: string }> }) {+ const { projectKey } = await params;+ redirect(aiTeamPath(projectKey, AI_TEAM_SECTIONS[0].slug));}diff --git a/apps/web/src/components/common/agent-chat/AgentChatMessage.tsx b/apps/web/src/components/common/agent-chat/AgentChatMessage.tsxindex 79d62c28..fc41256d 100644--- a/apps/web/src/components/common/agent-chat/AgentChatMessage.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatMessage.tsx@@ -1,6 +1,7 @@'use client';import type { ChatMessage } from '@/hooks/useAgentChat';+import { cn } from '@/lib/utils';import type { AiChatPart, AiChatToolPart } from '@/lib/api';import { formatLongDate, formatTime } from '@/utils/dates';import Markdown from '@/components/common/Markdown';@@ -52,12 +53,12 @@ export default function AgentChatMessage({)}<Message align={isUser ? 'end' : 'start'}><MessageContent>- <Bubble variant={isUser ? 'muted' : 'ghost'} className="gap-2">+ <Bubble variant={isUser ? 'muted' : 'ghost'} className={cn('gap-2', !isUser && 'w-full')}>{blocksOf(message.parts).map((block, index) =>'tools' in block ? (<AgentChatToolCalls key={index} tools={block.tools} />) : (- <BubbleContent key={index}>+ <BubbleContent key={index} className={cn(!isUser && 'w-full')}>{isUser ? (<span className="whitespace-pre-wrap">{block.text}</span>) : (@@ -67,6 +68,7 @@ export default function AgentChatMessage({),)}</Bubble>+ {message.error && <p className="text-xs text-destructive">{message.error}</p>}<MessageFooter>{message.stopped? `${t('stopped')} · ${formatTime(message.createdAt)}`diff --git a/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx b/apps/web/src/components/common/agent-chat/AgentChatPanel.tsxindex 3833a832..7657c893 100644--- a/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx@@ -1,6 +1,6 @@'use client';-import { useState } from 'react';+import { useState, type ReactNode } from 'react';import { ArrowUp, Bot, RotateCw, Square } from 'lucide-react';import type { AiAgent } from '@/lib/api';import type { ChatMessage, ChatStatus, PendingMessage } from '@/hooks/useAgentChat';@@ -39,6 +39,7 @@ export function AgentChatPanel({onStop,onRemovePending,onReset,+ composerStart,hasEarlierMessages,isLoadingEarlier,onLoadEarlier,@@ -52,6 +53,9 @@ export function AgentChatPanel({onStop: () => void;onRemovePending: (id: string) => void;onReset?: () => void;+ // Rendered at the start of the composer's button row, before the panel's own+ // buttons.+ composerStart?: ReactNode;hasEarlierMessages?: boolean;isLoadingEarlier?: boolean;onLoadEarlier?: () => void;@@ -62,10 +66,11 @@ export function AgentChatPanel({// in the queue with nothing to take it. The composer says so instead of accepting it.// A message typed while the agent is answering is not refused — it waits its turn.const runnerOffline = agent.kind === 'external' && !isRunnerOnline(agent);+ const canSend = input.trim().length > 0 && !runnerOffline;function submit() {const text = input.trim();- if (!text || runnerOffline) return;+ if (!canSend) return;setInput('');onSend(text);}@@ -98,7 +103,7 @@ export function AgentChatPanel({)}</div>- <div className="p-4 pt-2">+ <div className="chat-composer px-3 pt-2 pb-3">{runnerOffline && (<div className="mx-auto mb-2 flex w-full max-w-3xl flex-wrap items-center gap-x-2 gap-y-0.5"><AgentRunnerStatus agent={agent} />@@ -112,19 +117,28 @@ export function AgentChatPanel({submit();}}>- <InputGroup className="rounded-xl">+ <InputGroup className="rounded-2xl border-transparent bg-muted has-[[data-slot=input-group-control]:focus-visible]:border-transparent has-[[data-slot=input-group-control]:focus-visible]:ring-0 dark:bg-muted/50"><InputGroupTextarea// `auto` once there is something to read, so a message keeps the// script it was typed in. An empty box has nothing to read from.dir={input ? 'auto' : undefined}- className="max-h-40 min-h-10 py-2.5"+ className="max-h-[calc(5lh+1.25rem)] min-h-9 px-3.5 py-2.5"value={input}onChange={(e) => setInput(e.target.value)}onKeyDown={(e) => {- if (e.key === 'Enter' && !e.shiftKey) {+ if (e.key !== 'Enter') return;+ if (e.metaKey || e.ctrlKey) {e.preventDefault();- submit();+ // Written into the field rather than appended to the state, so the+ // break lands where the caret is and the browser keeps its undo.+ const field = e.currentTarget;+ field.setRangeText('\n', field.selectionStart, field.selectionEnd, 'end');+ setInput(field.value);+ return;}+ if (e.shiftKey) return;+ e.preventDefault();+ submit();}}placeholder={runnerOffline@@ -134,13 +148,23 @@ export function AgentChatPanel({disabled={runnerOffline}rows={1}/>- <InputGroupAddon align="block-end">+ <InputGroupAddon+ align="block-end"+ className="gap-1 px-2.5 pb-2"+ // The row carries a text cursor, and its own handler focuses an+ // `input` — this group holds a textarea.+ onClick={(e) => {+ if ((e.target as HTMLElement).closest('button')) return;+ e.currentTarget.parentElement?.querySelector('textarea')?.focus();+ }}+ >+ {composerStart}{onReset && (<InputGroupButtontype="button"variant="ghost"- size="icon-sm"- className="rounded-lg text-muted-foreground hover:text-foreground"+ size="icon-xs"+ className="rounded-md text-muted-foreground hover:text-foreground"title={t('reset')}disabled={status !== 'ready' || messages.length === 0}onClick={onReset}@@ -155,7 +179,7 @@ export function AgentChatPanel({type="button"variant="outline"size="icon-sm"- className="rounded-lg"+ className="rounded-full"title={t('stop')}onClick={onStop}>@@ -165,10 +189,13 @@ export function AgentChatPanel({)}<InputGroupButtontype="submit"- variant="default"+ // Solid only once the message can go, so the button reads as the+ // state of the composer and not as an always-armed action.+ variant={canSend ? 'default' : 'secondary'}size="icon-sm"- className="rounded-lg"- disabled={!input.trim() || runnerOffline}+ className="rounded-full"+ title={t('sendHint')}+ disabled={!canSend}><ArrowUp /><span className="sr-only">{t('send')}</span>diff --git a/apps/web/src/components/common/agent-chat/AgentChatTranscript.tsx b/apps/web/src/components/common/agent-chat/AgentChatTranscript.tsxindex d7a431ed..05a96075 100644--- a/apps/web/src/components/common/agent-chat/AgentChatTranscript.tsx+++ b/apps/web/src/components/common/agent-chat/AgentChatTranscript.tsx@@ -89,7 +89,7 @@ export function AgentChatTranscript({><MessageScrollerContentaria-busy={status !== 'ready' || isLoadingEarlier}- className="mx-auto w-full max-w-3xl gap-6 p-4"+ className="mx-auto w-full max-w-3xl gap-6 p-4 pb-10">{messages.map((message, index) => {const previous = messages[index - 1];diff --git a/apps/web/src/components/common/chart/ChartBlock.tsx b/apps/web/src/components/common/chart/ChartBlock.tsxindex 09803221..5b48a410 100644--- a/apps/web/src/components/common/chart/ChartBlock.tsx+++ b/apps/web/src/components/common/chart/ChartBlock.tsx@@ -184,12 +184,18 @@ function radar(spec: ChartSpec) {// The stages of a funnel, widest first. Recharts draws no legend for it, so the name// of every stage is written into the trapezoid it belongs to — white, because it sits-// on the slice color in either theme.+// on the slice color in either theme. The last stage is a trapezoid like the rest:+// recharts otherwise runs it into a point, which reads as a stage that ends at zero.function funnel(spec: ChartSpec, legend: ChartLegendEntry[]) {return (<FunnelChart><ChartTooltip content={<ChartTooltipContent nameKey={spec.x} />} />- <Funnel dataKey={spec.series[0].key} nameKey={spec.x} data={spec.data}>+ <Funnel+ dataKey={spec.series[0].key}+ nameKey={spec.x}+ data={spec.data}+ lastShapeType="rectangle"+ >{legend.map((entry, index) => (<Cell key={index} fill={entry.color} />))}diff --git a/apps/web/src/components/layout/AppHeader.tsx b/apps/web/src/components/layout/AppHeader.tsxindex 77e74ccc..20beebb6 100644--- a/apps/web/src/components/layout/AppHeader.tsx+++ b/apps/web/src/components/layout/AppHeader.tsx@@ -31,6 +31,7 @@ export default function AppHeader({const { can } = usePermissions();const paletteKey = useHotkeyLabel('palette.toggle');const newIssueKey = useHotkeyLabel('issue.new');+ const chatKey = useHotkeyLabel('chat.toggle');const canCreateIssue = hasProject && can('work_items', 'create');const canUseChat = hasProject && can('ai_agents', 'read');return (@@ -72,7 +73,7 @@ export default function AppHeader({variant={chatActive ? 'default' : 'outline'}size="icon"className="size-8 shrink-0"- title={t('aiChat')}+ title={t('aiChatHint', { key: chatKey ?? '' })}aria-pressed={chatActive}onClick={onToggleChat}>diff --git a/apps/web/src/components/layout/CommandLayer.tsx b/apps/web/src/components/layout/CommandLayer.tsxindex 03a8d8e4..bae4282c 100644--- a/apps/web/src/components/layout/CommandLayer.tsx+++ b/apps/web/src/components/layout/CommandLayer.tsx@@ -29,6 +29,7 @@ export default function CommandLayer({onSelectProject,onOpenIssue,onIssueDeleted,+ onToggleChat,}: {open: boolean;onOpenChange: (open: boolean) => void;@@ -45,6 +46,7 @@ export default function CommandLayer({onSelectProject: (key: string) => void;onOpenIssue: (sequenceNumber: number) => void;onIssueDeleted: () => void;+ onToggleChat: () => void;}) {const { project } = useShell();const hasProject = !!project;@@ -61,6 +63,7 @@ export default function CommandLayer({onSelectAll,onNewProject,onSelectProject,+ onToggleChat,});const navigation = useNavigationCommands(currentProjectKey);diff --git a/apps/web/src/components/layout/Shell.tsx b/apps/web/src/components/layout/Shell.tsxindex 99d0e1f7..3ae99314 100644--- a/apps/web/src/components/layout/Shell.tsx+++ b/apps/web/src/components/layout/Shell.tsx@@ -8,6 +8,7 @@ import { useAccountPreferences } from '@/services/preferences.service';import type { IssueOpenMode } from '@/lib/api';import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts';import { useOverlays } from '@/hooks/useOverlays';+import { usePermissions } from '@/hooks/usePermissions';import { useSettingsNavGroups } from '@/hooks/useSettingsNavGroups';import { useShellProject } from '@/hooks/useShellProject';import { useShellRoute } from '@/hooks/useShellRoute';@@ -22,6 +23,8 @@ import CommandLayer from '@/components/layout/CommandLayer';import ShellBody from '@/components/layout/ShellBody';import ShellHeaderTitle from '@/components/layout/ShellHeaderTitle';import ShellOverlays from '@/components/layout/ShellOverlays';+import { ChatPanel } from '@/features/ai-chat/components/panel/ChatPanel';+import { useChatPanel } from '@/features/ai-chat/hooks/useChatPanel';import { useTranslations } from 'next-intl';// The layout for /project/:projectKey and its children (the work items view and the@@ -55,7 +58,12 @@ export default function Shell({const initiativeOptions = useInitiativeOptionsQuery(projectKey).data ?? [];const { issueOpenMode, showChatByDefault } = useAccountPreferences();- const overlays = useOverlays(showChatByDefault);+ const overlays = useOverlays();+ const chatPanel = useChatPanel(projectKey, showChatByDefault);+ // The Shell renders the context provider, so its own permission check reads the+ // project it loaded rather than the context.+ const { can } = usePermissions(project);+ const chatAvailable = !!projectKey && can('ai_agents', 'read');const issueQuery = useIssueBySeqQuery(projectKey, routeIssueSeq);useProjectRouteSync({ projects, projectsLoaded, projectKey });@@ -89,6 +97,7 @@ export default function Shell({useKeyboardShortcuts({hasProject: !!project,+ hasChat: chatAvailable,projects,overlayOpen: overlays.anyOpen,onToggleCommand: () => overlays.setShowCommand((v) => !v),@@ -97,6 +106,7 @@ export default function Shell({onNewIssue: () => canCreateIssue && openNewIssue(),onNewProject: () => overlays.setShowNewProject(true),onSettings: () => firstSettingsHref && router.push(firstSettingsHref),+ onToggleChat: chatPanel.toggle,});// Every view opens an issue through this one callback, so the user's choice@@ -149,8 +159,8 @@ export default function Shell({hasProject={!!project}onOpenCommand={() => overlays.setShowCommand(true)}onNewIssue={openNewIssue}- chatActive={overlays.chatEnabled}- onToggleChat={overlays.toggleChat}+ chatActive={chatPanel.open}+ onToggleChat={chatPanel.toggle}/>{errorMsg && !forbidden && (@@ -159,16 +169,30 @@ export default function Shell({</div>)}- <div className="relative flex min-h-0 flex-1 flex-col overflow-hidden">- <ShellBody- forbidden={forbidden}- hasProject={!!project}- hasError={!!errorMsg}- projectsLoaded={projectsLoaded}- projectCount={projects.length}- >- {children}- </ShellBody>+ <div className="relative flex min-h-0 flex-1 overflow-hidden">+ <div className="relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">+ <ShellBody+ forbidden={forbidden}+ hasProject={!!project}+ hasError={!!errorMsg}+ projectsLoaded={projectsLoaded}+ projectCount={projects.length}+ >+ {children}+ </ShellBody>+ </div>++ {chatAvailable && projectKey && (+ <ChatPanel+ projectKey={projectKey}+ open={chatPanel.open}+ mode={chatPanel.mode}+ fullscreen={chatPanel.fullscreen}+ onToggleMode={chatPanel.toggleMode}+ onToggleFullscreen={chatPanel.toggleFullscreen}+ onClose={chatPanel.toggle}+ />+ )}</div></SidebarInset>@@ -189,6 +213,7 @@ export default function Shell({onSelectProject={(key) => router.push(projectPath(key))}onOpenIssue={(seq) => projectKey && router.push(issuePath(projectKey, seq))}onIssueDeleted={onIssueDeleted}+ onToggleChat={chatPanel.toggle}/><ShellOverlays project={project} projectKey={projectKey} overlays={overlays} />diff --git a/apps/web/src/components/layout/ShellHeaderTitle.tsx b/apps/web/src/components/layout/ShellHeaderTitle.tsxindex 9dd92f5a..b02a03a4 100644--- a/apps/web/src/components/layout/ShellHeaderTitle.tsx+++ b/apps/web/src/components/layout/ShellHeaderTitle.tsx@@ -24,7 +24,7 @@ export default function ShellHeaderTitle({const sectionText = useSettingsSectionText();// The label on the pages that are not an issue, initiative or cycle detail. An- // /ai-team route names its section, except the chat, which has no section entry.+ // /ai-team route names its section.function pageLabel(): string {const { sub, section, aiTeamSection } = route;const known = (slug: string) => SETTINGS_SECTIONS.some((s) => s.slug === slug);@@ -33,7 +33,6 @@ export default function ShellHeaderTitle({if (sub === 'dashboard') return t('dashboards');if (sub === 'initiatives') return t('initiatives');if (sub === 'cycles') return t('cycles');- if (aiTeamSection === 'chat') return t('chatWithAiTeam');if (aiTeamSection) return known(aiTeamSection) ? sectionText(aiTeamSection).label : t('aiTeam');if (sub === 'ai-agents') return t('aiAgents');if (sub === 'api') return t('api');diff --git a/apps/web/src/components/layout/ShellOverlays.tsx b/apps/web/src/components/layout/ShellOverlays.tsxindex 043a2e9f..3c91f732 100644--- a/apps/web/src/components/layout/ShellOverlays.tsx+++ b/apps/web/src/components/layout/ShellOverlays.tsx@@ -7,11 +7,10 @@ import type { useOverlays } from '@/hooks/useOverlays';import NewProjectModal from '@/components/layout/NewProjectModal';import NewIssueModal from '@/features/issue/components/create/NewIssueModal';import IssueDetail from '@/features/issue/components/detail/IssueDetail';-import { FloatingChat } from '@/features/ai-chat/components/floating/FloatingChat';// The project-level overlays the Shell mounts above its content: the new-project-// modal, the new-issue modal, the issue detail panel and the floating AI chat.-// Each renders only while its overlay state says it is open.+// modal, the new-issue modal and the issue detail panel. Each renders only while its+// overlay state says it is open.export default function ShellOverlays({project,projectKey,@@ -60,10 +59,6 @@ export default function ShellOverlays({}}/>)}-- {project && overlays.chatEnabled && (- <FloatingChat open={overlays.chatOpen} onOpenChange={overlays.setChatOpen} />- )}</>);}diff --git a/apps/web/src/components/layout/SidebarAiTeamNav.tsx b/apps/web/src/components/layout/SidebarAiTeamNav.tsxindex b5783dc3..c2b4c578 100644--- a/apps/web/src/components/layout/SidebarAiTeamNav.tsx+++ b/apps/web/src/components/layout/SidebarAiTeamNav.tsx@@ -1,7 +1,7 @@import { usePathname } from 'next/navigation';-import { MessagesSquare, SlidersHorizontal } from 'lucide-react';+import { SlidersHorizontal } from 'lucide-react';import { useTranslations } from 'next-intl';-import { aiChatPath, aiSectionPath, aiTeamPath } from '@/utils/paths';+import { aiSectionPath, aiTeamPath } from '@/utils/paths';import { AI_SECTIONS, AI_TEAM_SECTIONS } from '@/utils/settingsSections';import { usePermissions } from '@/hooks/usePermissions';import { useSettingsSectionText } from '@/hooks/useSectionLabels';@@ -14,9 +14,9 @@ import {import SidebarNavItem from '@/components/layout/SidebarNavItem';import SidebarNavSubmenu from '@/components/layout/SidebarNavSubmenu';-// The AI Team sidebar group: the chat, the AI Team sections the viewer may read,-// and the "Configure" item holding the AI configuration sections. Renders nothing-// when none of them are readable.+// The AI Team sidebar group: the AI Team sections the viewer may read, and the+// "Configure" item holding the AI configuration sections. Renders nothing when none+// of them are readable.export default function SidebarAiTeamNav({ projectKey }: { projectKey: string | null }) {const t = useTranslations('nav');const sectionText = useSettingsSectionText();@@ -32,23 +32,13 @@ export default function SidebarAiTeamNav({ projectKey }: { projectKey: string |label: sectionText(s.slug).label,active: pathname.endsWith(`/${s.slug}`),}));- const canChat = can('ai_agents', 'read');- if (!canChat && sections.length === 0 && configureItems.length === 0) return null;+ if (sections.length === 0 && configureItems.length === 0) return null;return (<SidebarGroup><SidebarGroupLabel>{t('aiTeam')}</SidebarGroupLabel><SidebarGroupContent><SidebarMenu>- {canChat && (- <SidebarNavItem- href={projectKey ? aiChatPath(projectKey) : '#'}- icon={MessagesSquare}- label={t('chat')}- active={pathname.endsWith('/ai-team/chat')}- disabled={disabled}- />- )}{sections.map((s) => (<SidebarNavItemkey={s.slug}diff --git a/apps/web/src/components/ui/chart.tsx b/apps/web/src/components/ui/chart.tsxindex c7f55bd0..adcafae4 100644--- a/apps/web/src/components/ui/chart.tsx+++ b/apps/web/src/components/ui/chart.tsx@@ -10,6 +10,13 @@ import { cn } from '@/lib/utils';const THEMES = { light: '', dark: '.dark' } as const;const INITIAL_DIMENSION = { width: 320, height: 200 } as const;++// The chart is re-laid out at most once per this many milliseconds. A container whose+// width is animated (the widget grid transitions it, the sidebar and the chat panel+// change it) would otherwise resize the chart in the ResizeObserver callback of every+// frame, and each of those writes the new size into the recharts store from an effect+// — a chain React gives up on with "Maximum update depth exceeded".+const RESIZE_INTERVAL = 100;type TooltipNameType = number | string;export type ChartConfig = Record<@@ -45,6 +52,7 @@ function ChartContainer({children,config,initialDimension = INITIAL_DIMENSION,+ ref,...props}: React.ComponentProps<'div'> & {config: ChartConfig;@@ -56,10 +64,31 @@ function ChartContainer({}) {const uniqueId = React.useId();const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`;+ const [sized, setSized] = React.useState(false);++ // A chart inside a subtree that is display:none — the closed chat panel, an inactive+ // chat tab — measures 0x0, and recharts answers every such measurement with a+ // container error in the console. It is drawn only while its box is real.+ const measure = React.useCallback(+ (node: HTMLDivElement | null) => {+ assignRef(ref, node);+ if (!node) return;+ const observer = new ResizeObserver(([entry]) => {+ setSized(entry.contentRect.width > 0 && entry.contentRect.height > 0);+ });+ observer.observe(node);+ return () => {+ observer.disconnect();+ assignRef(ref, null);+ };+ },+ [ref],+ );return (<ChartContext.Provider value={{ config }}><div+ ref={measure}data-slot="chart"data-chart={chartId}className={cn(@@ -69,14 +98,24 @@ function ChartContainer({{...props}><ChartStyle id={chartId} config={config} />- <RechartsPrimitive.ResponsiveContainer initialDimension={initialDimension}>- {children}- </RechartsPrimitive.ResponsiveContainer>+ {sized && (+ <RechartsPrimitive.ResponsiveContainer+ initialDimension={initialDimension}+ debounce={RESIZE_INTERVAL}+ >+ {children}+ </RechartsPrimitive.ResponsiveContainer>+ )}</div></ChartContext.Provider>);}+function assignRef(ref: React.Ref<HTMLDivElement> | undefined, node: HTMLDivElement | null) {+ if (typeof ref === 'function') ref(node);+ else if (ref) ref.current = node;+}+const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);diff --git a/apps/web/src/features/account/AccountPreferencesPage.tsx b/apps/web/src/features/account/AccountPreferencesPage.tsxindex dec2cca3..a224a0fb 100644--- a/apps/web/src/features/account/AccountPreferencesPage.tsx+++ b/apps/web/src/features/account/AccountPreferencesPage.tsx@@ -30,7 +30,7 @@ const THEMES: ThemePreference[] = ['system', 'light', 'dark'];const ISSUE_OPEN_MODES: IssueOpenMode[] = ['panel', 'page'];const ISSUE_STATS_VIEWS: IssueStatsView[] = ['compact', 'timeline'];const ISSUE_ACTIVITY_VIEWS: IssueActivityView[] = ['flat', 'grouped'];-const START_PAGES: StartPage[] = ['work-items', 'inbox', 'dashboard', 'initiatives', 'ai-chat'];+const START_PAGES: StartPage[] = ['work-items', 'inbox', 'dashboard', 'initiatives'];// Personal interface preferences (/account/preferences). Each choice saves as soon// as it is made and applies on every device the user signs in from.diff --git a/apps/web/src/features/ai-chat/AiChatPage.tsx b/apps/web/src/features/ai-chat/AiChatPage.tsxdeleted file mode 100644index af83a268..00000000--- a/apps/web/src/features/ai-chat/AiChatPage.tsx+++ /dev/null@@ -1,95 +0,0 @@-'use client';--import Link from 'next/link';-import { useTranslations } from 'next-intl';-import { useShell } from '@/context/shellContext';-import { usePermissions } from '@/hooks/usePermissions';-import { aiAgentsPath } from '@/utils/paths';-import { Button } from '@/components/ui/button';-import { EmptyState } from '@/components/common/page/EmptyState';-import { AiChatAgentRail } from './components/page/AiChatAgentRail';-import { AiChatThreadRail } from './components/page/AiChatThreadRail';-import { AiChatConversation } from './components/page/AiChatConversation';-import { AiChatPageSkeleton } from './components/page/AiChatPageSkeleton';-import { useAiChatSelection } from './hooks/useAiChatSelection';--// The AI Chat page (/project/:projectKey/ai-team/chat): a full-page chat with the-// project's internal agents.-export default function AiChatPage() {- const t = useTranslations('aiChat');- const { project } = useShell();- const { can } = usePermissions();- const {- agents,- isLoading,- providerLabel,- selected,- selectedThreadId,- newChatNonce,- selectAgent,- selectThread,- startNewChat,- handleThreadCreated,- handleThreadDeleted,- } = useAiChatSelection(project?.project.key ?? null);-- if (!project) return null;-- if (!can('ai_agents', 'read')) {- return (- <div className="flex h-full items-center justify-center px-4 text-center text-sm text-muted-foreground">- {t('noAccess')}- </div>- );- }-- if (isLoading) return <AiChatPageSkeleton />;-- if (agents.length === 0) {- return (- <div className="flex h-full">- <EmptyState title={t('emptyTitle')} description={t('emptyDescription')}>- {can('ai_agents', 'edit') && (- <Button asChild size="sm">- <Link href={aiAgentsPath(project.project.key)}>{t('createAgent')}</Link>- </Button>- )}- </EmptyState>- </div>- );- }-- return (- <div className="flex h-full min-h-0">- <AiChatAgentRail- agents={agents}- selectedId={selected?.id ?? null}- onSelect={selectAgent}- providerLabel={providerLabel}- />- {selected && (- <>- <AiChatThreadRail- key={selected.id}- projectKey={project.project.key}- agentId={selected.id}- selectedThreadId={selectedThreadId}- onSelect={selectThread}- onDeleted={handleThreadDeleted}- onNewChat={startNewChat}- />- <div className="flex min-h-0 flex-1 flex-col">- <AiChatConversation- key={`${selected.id}:${newChatNonce}`}- projectKey={project.project.key}- agent={selected}- providerLabel={providerLabel}- threadId={selectedThreadId}- onThreadCreated={handleThreadCreated}- />- </div>- </>- )}- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/floating/FloatingChat.tsx b/apps/web/src/features/ai-chat/components/floating/FloatingChat.tsxdeleted file mode 100644index c3162b36..00000000--- a/apps/web/src/features/ai-chat/components/floating/FloatingChat.tsx+++ /dev/null@@ -1,131 +0,0 @@-'use client';--import { useState } from 'react';-import { MessagesSquare, X } from 'lucide-react';-import { useTranslations } from 'next-intl';-import { useShell } from '@/context/shellContext';-import { usePermissions } from '@/hooks/usePermissions';-import { cn } from '@/lib/utils';-import { Button } from '@/components/ui/button';-import { AiChatThread } from '../shared/AiChatThread';-import { AiChatThreadSkeleton } from '../shared/AiChatThreadSkeleton';-import { FloatingChatHeader } from './FloatingChatHeader';-import { FloatingChatHistory } from './FloatingChatHistory';-import { useAiChatSelection } from '../../hooks/useAiChatSelection';--// The floating AI chat: a launcher button anchored to the corner and a chat window-// above it. It is mounted by the Shell while the header toggle is on, so the whole-// widget (and the conversation inside it) survives navigation between project pages.-// The window is hidden rather than unmounted when minimized, so a chat in progress is-// kept.-export function FloatingChat({- open,- onOpenChange,-}: {- open: boolean;- onOpenChange: (open: boolean) => void;-}) {- const t = useTranslations('aiChat');- const { project } = useShell();- const { can } = usePermissions();- const {- agents,- isLoading,- providerLabel,- selected,- selectedThreadId,- newChatNonce,- selectAgent,- selectThread,- startNewChat,- handleThreadCreated,- handleThreadDeleted,- } = useAiChatSelection(project?.project.key ?? null);-- const [view, setView] = useState<'chat' | 'history'>('chat');-- // Every way of changing the conversation also leaves the history layer.- const handleSelectAgent = (id: number) => {- selectAgent(id);- setView('chat');- };-- const handleSelectThread = (threadId: string) => {- selectThread(threadId);- setView('chat');- };-- const handleNewChat = () => {- startNewChat();- setView('chat');- };-- if (!project || !can('ai_agents', 'read')) return null;-- return (- <div className="fixed right-4 bottom-4 z-40 flex flex-col items-end gap-3">- <div- className={cn(- 'relative flex h-[32rem] max-h-[calc(100vh-7rem)] w-[calc(100vw-2rem)] max-w-96 flex-col overflow-hidden rounded-xl border bg-background shadow-[var(--modal-shadow)]',- !open && 'hidden',- )}- >- <FloatingChatHeader- agents={agents}- providerLabel={providerLabel}- projectKey={project.project.key}- selected={selected}- threadId={selectedThreadId}- onSelectAgent={handleSelectAgent}- onShowHistory={() => setView('history')}- onNewChat={handleNewChat}- onMinimize={() => onOpenChange(false)}- />-- <div className="relative min-h-0 flex-1">- {isLoading ? (- <AiChatThreadSkeleton />- ) : selected ? (- <AiChatThread- key={`${selected.id}:${newChatNonce}`}- projectKey={project.project.key}- agent={selected}- threadId={selectedThreadId}- onThreadCreated={handleThreadCreated}- />- ) : (- <div className="flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground">- {t('noAgentsYet')}- </div>- )}-- {/* History over the conversation, which stays mounted so a chat in progress- is kept when the list is opened and closed without picking a thread. */}- {view === 'history' && selected && (- <div className="absolute inset-0 bg-background">- <FloatingChatHistory- projectKey={project.project.key}- agentId={selected.id}- selectedThreadId={selectedThreadId}- onSelect={handleSelectThread}- onDeleted={handleThreadDeleted}- onBack={() => setView('chat')}- />- </div>- )}- </div>- </div>-- <Button- size="icon"- className="size-12 shrink-0 rounded-full shadow-[var(--overlay-shadow)]"- title={open ? t('hideChat') : t('openChat')}- aria-expanded={open}- onClick={() => onOpenChange(!open)}- >- {open ? <X className="size-5" /> : <MessagesSquare className="size-5" />}- <span className="sr-only">{open ? t('hideChat') : t('openChat')}</span>- </Button>- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/floating/FloatingChatHeader.tsx b/apps/web/src/features/ai-chat/components/floating/FloatingChatHeader.tsxdeleted file mode 100644index 4c878be5..00000000--- a/apps/web/src/features/ai-chat/components/floating/FloatingChatHeader.tsx+++ /dev/null@@ -1,130 +0,0 @@-'use client';--import { Bot, Check, ChevronDown, History, MessageSquarePlus } from 'lucide-react';-import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';-import { Button } from '@/components/ui/button';-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuSeparator,- DropdownMenuTrigger,-} from '@/components/ui/dropdown-menu';-import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';-import { AiChatSessionBadge } from '../shared/AiChatSessionBadge';-import { useThreadSessionId } from '../../hooks/useThreadSessionId';-import { agentModelLabel } from '../../utils/agentModelLabel';--// The top bar of the floating chat: the agent picker plus the session, history, new-chat-// and minimize actions. `selected` is null when the project has no agents, which disables-// everything but minimize.-export function FloatingChatHeader({- agents,- providerLabel,- projectKey,- selected,- threadId,- onSelectAgent,- onShowHistory,- onNewChat,- onMinimize,-}: {- agents: AiAgent[];- providerLabel: (key: string) => string;- projectKey: string;- selected: AiAgent | null;- threadId: string | null;- onSelectAgent: (id: number) => void;- onShowHistory: () => void;- onNewChat: () => void;- onMinimize: () => void;-}) {- const t = useTranslations('aiChat');- const sessionId = useThreadSessionId(projectKey, selected?.id ?? null, threadId);-- return (- <div className="flex items-center gap-1 border-b px-2.5 py-2">- <DropdownMenu>- <DropdownMenuTrigger asChild disabled={!selected}>- <button- type="button"- className="flex min-w-0 flex-1 items-center gap-2 rounded-md px-1.5 py-1 text-left transition-colors hover:bg-accent"- >- <div className="flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary">- <Bot className="size-4" />- </div>- <div className="min-w-0 flex-1">- <div className="truncate text-sm leading-tight font-medium">- {selected?.name ?? t('noAgents')}- </div>- <div className="truncate text-xs leading-tight text-muted-foreground">- {selected ? `@${selected.username}` : t('addAgent')}- </div>- </div>- {selected && <ChevronDown className="size-4 shrink-0 text-muted-foreground" />}- </button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start" className="w-64">- <DropdownMenuLabel>{t('agents')}</DropdownMenuLabel>- <DropdownMenuSeparator />- {agents.map((agent) => (- <DropdownMenuItem- key={agent.id}- onSelect={() => onSelectAgent(agent.id)}- className="gap-2"- >- <Bot className="size-4 shrink-0" />- <div className="min-w-0 flex-1">- <div className="truncate text-sm">{agent.name}</div>- <div className="truncate text-xs text-muted-foreground">- {agent.kind === 'external' ? (- <AgentRunnerStatus agent={agent} compact />- ) : (- agentModelLabel(agent, providerLabel, t('noModel'))- )}- </div>- </div>- {agent.id === selected?.id && <Check className="size-4 shrink-0" />}- </DropdownMenuItem>- ))}- </DropdownMenuContent>- </DropdownMenu>-- {sessionId && <AiChatSessionBadge compact sessionId={sessionId} />}- <Button- variant="ghost"- size="icon"- className="size-7 shrink-0 text-muted-foreground hover:text-foreground"- title={t('history')}- disabled={!selected}- onClick={onShowHistory}- >- <History />- <span className="sr-only">{t('history')}</span>- </Button>- <Button- variant="ghost"- size="icon"- className="size-7 shrink-0 text-muted-foreground hover:text-foreground"- title={t('newChat')}- disabled={!selected}- onClick={onNewChat}- >- <MessageSquarePlus />- <span className="sr-only">{t('newChat')}</span>- </Button>- <Button- variant="ghost"- size="icon"- className="size-7 shrink-0 text-muted-foreground hover:text-foreground"- title={t('minimize')}- onClick={onMinimize}- >- <ChevronDown />- <span className="sr-only">{t('minimizeChat')}</span>- </Button>- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/floating/FloatingChatHistory.tsx b/apps/web/src/features/ai-chat/components/floating/FloatingChatHistory.tsxdeleted file mode 100644index ef5e0479..00000000--- a/apps/web/src/features/ai-chat/components/floating/FloatingChatHistory.tsx+++ /dev/null@@ -1,52 +0,0 @@-'use client';--import { ChevronLeft } from 'lucide-react';-import { useTranslations } from 'next-intl';-import { Button } from '@/components/ui/button';-import { AiChatThreadList } from '../shared/AiChatThreadList';--// The history layer of the floating chat, shown over the conversation.-export function FloatingChatHistory({- projectKey,- agentId,- selectedThreadId,- onSelect,- onDeleted,- onBack,-}: {- projectKey: string;- agentId: number;- selectedThreadId: string | null;- onSelect: (threadId: string) => void;- onDeleted: (threadId: string) => void;- onBack: () => void;-}) {- const t = useTranslations('aiChat');- const tCommon = useTranslations('common');-- return (- <div className="flex h-full min-h-0 flex-col">- <div className="flex items-center gap-2 border-b px-2.5 py-2">- <Button- variant="ghost"- size="icon"- className="size-7 shrink-0"- title={tCommon('back')}- onClick={onBack}- >- <ChevronLeft />- <span className="sr-only">{t('backToChat')}</span>- </Button>- <div className="text-sm font-medium">{t('history')}</div>- </div>-- <AiChatThreadList- projectKey={projectKey}- agentId={agentId}- selectedThreadId={selectedThreadId}- onSelect={onSelect}- onDeleted={onDeleted}- />- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/page/AiChatAgentRail.tsx b/apps/web/src/features/ai-chat/components/page/AiChatAgentRail.tsxdeleted file mode 100644index 44fb59aa..00000000--- a/apps/web/src/features/ai-chat/components/page/AiChatAgentRail.tsx+++ /dev/null@@ -1,79 +0,0 @@-'use client';--import { Bot, Sparkles } from 'lucide-react';-import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';-import { cn } from '@/lib/utils';-import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';-import { agentModelLabel } from '../../utils/agentModelLabel';--// The left rail of the AI Chat page: the agents to chat with. An internal agent shows-// the model it runs on, an external one whether its runner is connected.-export function AiChatAgentRail({- agents,- selectedId,- onSelect,- providerLabel,-}: {- agents: AiAgent[];- selectedId: number | null;- onSelect: (id: number) => void;- providerLabel: (key: string) => string;-}) {- const t = useTranslations('aiChat');-- return (- <div className="flex w-72 shrink-0 flex-col border-r bg-muted/30">- <div className="border-b px-4 py-3">- <div className="text-sm font-semibold">{t('agents')}</div>- <div className="text-xs text-muted-foreground">- {t('agentsAvailable', { count: agents.length })}- </div>- </div>- <div className="min-h-0 flex-1 space-y-0.5 overflow-y-auto p-2">- {agents.map((agent) => {- const active = agent.id === selectedId;- return (- <button- key={agent.id}- type="button"- onClick={() => onSelect(agent.id)}- aria-pressed={active}- className={cn(- 'flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors',- active ? 'bg-accent' : 'hover:bg-accent/50',- )}- >- <div- className={cn(- 'mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border',- active- ? 'border-primary/20 bg-primary/10 text-primary'- : 'bg-background text-muted-foreground',- )}- >- <Bot className="size-4" />- </div>- <div className="min-w-0 flex-1">- <div className="truncate text-sm font-medium">{agent.name}</div>- <div className="truncate text-xs text-muted-foreground">@{agent.username}</div>- <div className="mt-1 flex items-center gap-1 text-xs text-muted-foreground/80">- {agent.kind === 'external' ? (- <AgentRunnerStatus agent={agent} compact />- ) : (- <>- <Sparkles className="size-3 shrink-0" />- <span className="truncate">- {agentModelLabel(agent, providerLabel, t('noModel'))}- </span>- </>- )}- </div>- </div>- </button>- );- })}- </div>- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/page/AiChatConversation.tsx b/apps/web/src/features/ai-chat/components/page/AiChatConversation.tsxdeleted file mode 100644index 4a63248a..00000000--- a/apps/web/src/features/ai-chat/components/page/AiChatConversation.tsx+++ /dev/null@@ -1,73 +0,0 @@-'use client';--import { Bot } from 'lucide-react';-import { useTranslations } from 'next-intl';-import type { AiAgent } from '@/lib/api';-import { Badge } from '@/components/ui/badge';-import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';-import { AiChatThread } from '../shared/AiChatThread';-import { AiChatSessionBadge } from '../shared/AiChatSessionBadge';-import { useThreadSessionId } from '../../hooks/useThreadSessionId';-import { agentModelLabel } from '../../utils/agentModelLabel';--// One agent's conversation on the AI Chat page: a header identifying the agent, and the-// transcript plus composer below it.-export function AiChatConversation({- projectKey,- agent,- providerLabel,- threadId,- onThreadCreated,-}: {- projectKey: string;- agent: AiAgent;- providerLabel: (key: string) => string;- threadId: string | null;- onThreadCreated: (threadId: string) => void;-}) {- const t = useTranslations('aiChat');- const sessionId = useThreadSessionId(projectKey, agent.id, threadId);-- return (- <div className="flex h-full min-h-0 flex-col">- <div className="flex items-center gap-3 border-b px-5 py-3">- <div className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">- <Bot className="size-4.5" />- </div>- <div className="min-w-0 flex-1">- <div className="flex items-center gap-2">- <span className="truncate text-sm font-medium">{agent.name}</span>- {/* Memory is a setting of the built-in runtime. An external agent's memory is- its runner's session, whose id the header shows instead. */}- {agent.kind === 'internal' && !agent.memoryEnabled && (- <Badge variant="secondary" className="shrink-0">- {t('memoryOff')}- </Badge>- )}- </div>- <div className="flex items-center gap-1.5 truncate text-xs text-muted-foreground">- <span className="truncate">@{agent.username}</span>- <span aria-hidden>·</span>- {agent.kind === 'external' ? (- <AgentRunnerStatus agent={agent} compact />- ) : (- <span className="truncate">- {agentModelLabel(agent, providerLabel, t('noModel'))}- </span>- )}- </div>- </div>- {sessionId && <AiChatSessionBadge sessionId={sessionId} />}- </div>-- <div className="min-h-0 flex-1">- <AiChatThread- projectKey={projectKey}- agent={agent}- threadId={threadId}- onThreadCreated={onThreadCreated}- />- </div>- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/page/AiChatPageSkeleton.tsx b/apps/web/src/features/ai-chat/components/page/AiChatPageSkeleton.tsxdeleted file mode 100644index 9051ccdf..00000000--- a/apps/web/src/features/ai-chat/components/page/AiChatPageSkeleton.tsx+++ /dev/null@@ -1,21 +0,0 @@-import ListSkeleton from '@/components/common/skeleton/ListSkeleton';-import { AiChatThreadSkeleton } from '../shared/AiChatThreadSkeleton';--// Stands in for the AI Chat page while its agents load. The two rails keep the widths-// and borders AiChatAgentRail and AiChatThreadRail render at, so the loaded page lands-// where the skeleton was.-export function AiChatPageSkeleton() {- return (- <div className="flex h-full min-h-0">- <div className="w-72 shrink-0 border-r bg-muted/30 p-2">- <ListSkeleton rows={5} rowClassName="h-12" />- </div>- <div className="w-64 shrink-0 border-r bg-muted/20 p-2">- <ListSkeleton rows={4} rowClassName="h-9" />- </div>- <div className="min-h-0 flex-1">- <AiChatThreadSkeleton />- </div>- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/page/AiChatThreadRail.tsx b/apps/web/src/features/ai-chat/components/page/AiChatThreadRail.tsxdeleted file mode 100644index a25972fd..00000000--- a/apps/web/src/features/ai-chat/components/page/AiChatThreadRail.tsx+++ /dev/null@@ -1,51 +0,0 @@-'use client';--import { MessageSquarePlus } from 'lucide-react';-import { useTranslations } from 'next-intl';-import { Button } from '@/components/ui/button';-import { AiChatThreadList } from '../shared/AiChatThreadList';--// The middle column of the AI Chat page. A fresh chat that has not been sent yet is-// marked by selectedThreadId null.-export function AiChatThreadRail({- projectKey,- agentId,- selectedThreadId,- onSelect,- onDeleted,- onNewChat,-}: {- projectKey: string;- agentId: number;- selectedThreadId: string | null;- onSelect: (threadId: string) => void;- onDeleted: (threadId: string) => void;- onNewChat: () => void;-}) {- const t = useTranslations('aiChat');-- return (- <div className="flex w-64 shrink-0 flex-col border-r bg-muted/20">- <div className="flex items-center justify-between gap-2 border-b px-3 py-3">- <div className="text-sm font-semibold">{t('chats')}</div>- <Button- size="sm"- variant="outline"- className="h-7 gap-1.5 px-2 text-xs"- onClick={onNewChat}- >- <MessageSquarePlus className="size-3.5" />- {t('newChat')}- </Button>- </div>-- <AiChatThreadList- projectKey={projectKey}- agentId={agentId}- selectedThreadId={selectedThreadId}- onSelect={onSelect}- onDeleted={onDeleted}- />- </div>- );-}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsxnew file mode 100644index 00000000..6f1d60e1--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsx@@ -0,0 +1,127 @@+'use client';++import { useRef } from 'react';+import { Maximize2, Minimize2, Pin, PinOff, X } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { Direction } from 'radix-ui';+import { useIsMobile } from '@/hooks/use-mobile';+import { usePersistedWidth } from '@/hooks/usePersistedWidth';+import { cn } from '@/lib/utils';+import { Button } from '@/components/ui/button';+import ResizeGrip from '@/components/common/ResizeGrip';+import { ChatPanelBody } from './ChatPanelBody';+import { chatPanelWidthKey, type ChatPanelMode } from '../../hooks/useChatPanel';++const DEFAULT_WIDTH = 400;+const MIN_WIDTH = 320;+const MAX_WIDTH = 720;++// The agent chat as a panel on the end edge of the content area. The Shell mounts it+// for every project page, so the panel and the sessions in it survive a move to a+// different page: a closed panel is hidden, not unmounted, and a reply running in it+// goes on.+//+// In push mode the panel is a column of the content row, which narrows the page next to+// it; in overlay mode it stands over that page. A narrow screen has no room for a+// narrower page, so it is always overlay, over the full width. Fullscreen takes the+// panel out of the content row and over the whole viewport, the same way a dialog+// expands.+export function ChatPanel({+ projectKey,+ open,+ mode,+ fullscreen,+ onToggleMode,+ onToggleFullscreen,+ onClose,+}: {+ projectKey: string;+ open: boolean;+ mode: ChatPanelMode;+ fullscreen: boolean;+ onToggleMode: () => void;+ onToggleFullscreen: () => void;+ onClose: () => void;+}) {+ const t = useTranslations('aiChat');+ const tCommon = useTranslations('common');+ const direction = Direction.useDirection();+ const isMobile = useIsMobile();+ const { width, setWidth } = usePersistedWidth(+ chatPanelWidthKey(projectKey),+ DEFAULT_WIDTH,+ MIN_WIDTH,+ MAX_WIDTH,+ );++ const overlay = isMobile || mode === 'overlay';++ // The body is what loads the agents, the tabs and their transcripts, so it waits for+ // the first open: a panel nobody opens costs no requests. Once mounted it stays, which+ // is what keeps a running reply alive while the panel is closed.+ const opened = useRef(false);+ if (open) opened.current = true;++ return (+ <aside+ className={cn(+ 'flex h-full min-h-0 flex-col bg-background',+ !open && 'hidden',+ fullscreen+ ? 'fixed inset-0 z-50'+ : cn(+ 'border-s',+ overlay+ ? 'absolute inset-y-0 end-0 z-30 shadow-[var(--side-panel-shadow)]'+ : 'relative shrink-0',+ ),+ )}+ style={fullscreen ? undefined : { width: isMobile ? '100%' : width }}+ >+ {!isMobile && !fullscreen && (+ <ResizeGrip+ label={t('resizePanel')}+ className="absolute inset-y-0 start-0 z-10"+ onDrag={(deltaX) => setWidth(width + (direction === 'rtl' ? deltaX : -deltaX))}+ />+ )}++ <div className="flex items-center gap-1 border-b px-3 py-2">+ <span className="min-w-0 flex-1 truncate text-sm font-medium">{t('chatPanel')}</span>+ {!isMobile && !fullscreen && (+ <Button+ variant="ghost"+ size="icon"+ className="size-7 text-muted-foreground hover:text-foreground"+ onClick={onToggleMode}+ title={t(mode === 'push' ? 'overlayMode' : 'pushMode')}+ aria-pressed={mode === 'push'}+ >+ {mode === 'push' ? <PinOff /> : <Pin />}+ </Button>+ )}+ <Button+ variant="ghost"+ size="icon"+ className="size-7 text-muted-foreground hover:text-foreground"+ onClick={onToggleFullscreen}+ title={tCommon(fullscreen ? 'exitFullscreen' : 'fullscreen')}+ aria-pressed={fullscreen}+ >+ {fullscreen ? <Minimize2 /> : <Maximize2 />}+ </Button>+ <Button+ variant="ghost"+ size="icon"+ className="size-7 text-muted-foreground hover:text-foreground"+ onClick={onClose}+ title={tCommon('close')}+ >+ <X />+ </Button>+ </div>++ {opened.current && <ChatPanelBody projectKey={projectKey} />}+ </aside>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsxnew file mode 100644index 00000000..429cc9a8--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelAgentSwitcher.tsx@@ -0,0 +1,50 @@+'use client';++import { Bot, ChevronDown } from 'lucide-react';+import { useTranslations } from 'next-intl';+import type { AiAgent } from '@/lib/api';+import { DropdownMenu, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';+import { InputGroupButton } from '@/components/ui/input-group';+import { AiChatAgentMenu } from '../shared/AiChatAgentMenu';++// The agent of the session, next to its composer. It takes no selection while a reply+// is running: that answer belongs to the agent that is producing it.+export function ChatPanelAgentSwitcher({+ agents,+ selected,+ providerLabel,+ disabled,+ onSelect,+}: {+ agents: AiAgent[];+ selected: AiAgent;+ providerLabel: (key: string) => string;+ disabled: boolean;+ onSelect: (agentId: number) => void;+}) {+ const t = useTranslations('aiChat');++ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild disabled={disabled}>+ <InputGroupButton+ type="button"+ variant="ghost"+ size="xs"+ className="max-w-44 rounded-md text-muted-foreground hover:text-foreground"+ title={t('agents')}+ >+ <Bot className="shrink-0" />+ <span className="truncate">{selected.name}</span>+ <ChevronDown className="shrink-0 opacity-60" />+ </InputGroupButton>+ </DropdownMenuTrigger>+ <AiChatAgentMenu+ agents={agents}+ selectedId={selected.id}+ providerLabel={providerLabel}+ onSelect={onSelect}+ />+ </DropdownMenu>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelBody.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelBody.tsxnew file mode 100644index 00000000..cf7c9f22--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelBody.tsx@@ -0,0 +1,101 @@+'use client';++import { memo } from 'react';+import { useAiAgentsQuery } from '@/services/aiAgents.service';+import { AiChatThreadSkeleton } from '../shared/AiChatThreadSkeleton';+import { ChatPanelEmpty } from './ChatPanelEmpty';+import { ChatPanelSession } from './ChatPanelSession';+import { ChatPanelTabs } from './ChatPanelTabs';+import { useChatSessions, type ChatSession } from '../../hooks/useChatSessions';+import { useProviderLabel } from '../../hooks/useProviderLabel';++// What the chat panel holds under its header: the open sessions and the tab row over+// them. Memoised because resizing the panel re-renders it on every pointer move, and a+// render here reaches every transcript.+export const ChatPanelBody = memo(function ChatPanelBody({ projectKey }: { projectKey: string }) {+ const agentsQuery = useAiAgentsQuery(projectKey);+ const agents = agentsQuery.data ?? [];+ const providerLabel = useProviderLabel(projectKey);+ const {+ sessions,+ active,+ setActive,+ newTab,+ openTab,+ openThread,+ closeSession,+ moveTab,+ swapTabs,+ setThread,+ setAgent,+ setState,+ } = useChatSessions(projectKey, agents[0]?.id ?? null);++ // A session that has said nothing changes its agent in place; one with a transcript+ // keeps it, and the other agent is chatted with in a tab of its own.+ const selectAgent = (session: ChatSession, agentId: number) => {+ if (agentId === session.agentId) return;+ if (session.hasMessages) openTab(agentId);+ else setAgent(session.id, agentId);+ };++ // A conversation that is deleted from the history cannot be shown any more.+ const handleThreadDeleted = (threadId: string) => {+ const session = sessions.find((candidate) => candidate.threadId === threadId);+ if (session) closeSession(session.id);+ };++ if (agentsQuery.isLoading) {+ return (+ <div className="min-h-0 flex-1">+ <AiChatThreadSkeleton />+ </div>+ );+ }++ if (agents.length === 0) {+ return (+ <div className="min-h-0 flex-1">+ <ChatPanelEmpty projectKey={projectKey} />+ </div>+ );+ }++ return (+ <>+ <ChatPanelTabs+ projectKey={projectKey}+ sessions={sessions}+ activeId={active?.id ?? null}+ onSelect={setActive}+ onClose={closeSession}+ onNewTab={newTab}+ onMoveTab={moveTab}+ onSwapTabs={swapTabs}+ />++ <div className="relative min-h-0 flex-1">+ {sessions.map((session) => {+ const agent = agents.find((candidate) => candidate.id === session.agentId);+ if (!agent) return null;+ return (+ <ChatPanelSession+ key={session.id}+ projectKey={projectKey}+ agents={agents}+ agent={agent}+ session={session}+ active={session.id === active?.id}+ providerLabel={providerLabel}+ onThreadCreated={setThread}+ onStateChange={setState}+ onSelectAgent={selectAgent}+ onSelectThread={openThread}+ onThreadDeleted={handleThreadDeleted}+ />+ );+ })}+ </div>+ </>+ );+});diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelEmpty.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelEmpty.tsxnew file mode 100644index 00000000..4605ad60--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelEmpty.tsx@@ -0,0 +1,27 @@+'use client';++import Link from 'next/link';+import { useTranslations } from 'next-intl';+import { usePermissions } from '@/hooks/usePermissions';+import { aiAgentsPath } from '@/utils/paths';+import { Button } from '@/components/ui/button';+import { EmptyState } from '@/components/common/page/EmptyState';++// What the panel shows for a project with no agent: there is nobody to chat with, so+// there is no composer either.+export function ChatPanelEmpty({ projectKey }: { projectKey: string }) {+ const t = useTranslations('aiChat');+ const { can } = usePermissions();++ return (+ <div className="flex h-full flex-col">+ <EmptyState title={t('emptyTitle')} description={t('emptyDescription')}>+ {can('ai_agents', 'edit') && (+ <Button asChild size="sm">+ <Link href={aiAgentsPath(projectKey)}>{t('createAgent')}</Link>+ </Button>+ )}+ </EmptyState>+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelHistory.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelHistory.tsxnew file mode 100644index 00000000..58cf4430--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelHistory.tsx@@ -0,0 +1,77 @@+'use client';++import { useState } from 'react';+import { History } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';+import { InputGroupButton } from '@/components/ui/input-group';+import { AiChatThreadList } from '../shared/AiChatThreadList';++// The past conversations with the agent of this session, over the composer. The session+// below stays mounted, so a reply that runs while the list is open goes on.+export function ChatPanelHistory({+ projectKey,+ agentId,+ agentName,+ selectedThreadId,+ onSelect,+ onDeleted,+}: {+ projectKey: string;+ agentId: number;+ agentName: string;+ selectedThreadId: string | null;+ onSelect: (threadId: string) => void;+ onDeleted: (threadId: string) => void;+}) {+ const t = useTranslations('aiChat');+ const [open, setOpen] = useState(false);++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <InputGroupButton+ type="button"+ variant="ghost"+ size="icon-xs"+ className="rounded-md text-muted-foreground hover:text-foreground"+ title={t('history')}+ >+ <History />+ <span className="sr-only">{t('history')}</span>+ </InputGroupButton>+ </PopoverTrigger>+ <PopoverContent+ align="start"+ className="flex max-h-96 w-80 flex-col p-0"+ // Picking a conversation hides the session this popover is anchored to, and a+ // hidden trigger reports a zero rect in the top left corner, where the popover+ // would be moved while it plays its closing animation. Without that animation it+ // is gone in the same frame, so there is none it could be seen in.+ style={open ? undefined : { animation: 'none' }}+ // The delete confirmation opens in a portal of its own, so a click in it counts+ // as outside this popover. The list has to stay mounted for that delete to run.+ onInteractOutside={(event) => {+ if ((event.target as HTMLElement | null)?.closest('[role="dialog"]'))+ event.preventDefault();+ }}+ >+ <div className="flex min-w-0 items-baseline gap-1.5 border-b px-3 py-2">+ <span className="text-sm font-medium">{t('history')}</span>+ <span className="truncate text-xs text-muted-foreground">{agentName}</span>+ </div>++ <AiChatThreadList+ projectKey={projectKey}+ agentId={agentId}+ selectedThreadId={selectedThreadId}+ onSelect={(threadId) => {+ setOpen(false);+ onSelect(threadId);+ }}+ onDeleted={onDeleted}+ />+ </PopoverContent>+ </Popover>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsxnew file mode 100644index 00000000..e43a8feb--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelSession.tsx@@ -0,0 +1,86 @@+'use client';++import { useCallback } from 'react';+import type { AiAgent } from '@/lib/api';+import { cn } from '@/lib/utils';+import { AiChatSessionBadge } from '../shared/AiChatSessionBadge';+import { AiChatThread } from '../shared/AiChatThread';+import { ChatPanelAgentSwitcher } from './ChatPanelAgentSwitcher';+import { ChatPanelHistory } from './ChatPanelHistory';+import { useThreadSessionId } from '../../hooks/useThreadSessionId';+import type { ChatSession, ChatSessionState } from '../../hooks/useChatSessions';++// One open session of the chat panel. Every session is mounted, and the ones that are+// not shown are hidden rather than dropped: that is what keeps their transcript and+// their composer, and lets a reply run to the end while another session is on screen.+//+// The thread is keyed by the agent, so picking a different agent for a session starts a+// fresh conversation with it.+export function ChatPanelSession({+ projectKey,+ agents,+ agent,+ session,+ active,+ providerLabel,+ onThreadCreated,+ onStateChange,+ onSelectAgent,+ onSelectThread,+ onThreadDeleted,+}: {+ projectKey: string;+ agents: AiAgent[];+ agent: AiAgent;+ session: ChatSession;+ active: boolean;+ providerLabel: (key: string) => string;+ onThreadCreated: (sessionId: string, threadId: string) => void;+ onStateChange: (sessionId: string, state: ChatSessionState) => void;+ onSelectAgent: (session: ChatSession, agentId: number) => void;+ onSelectThread: (agentId: number, threadId: string) => void;+ onThreadDeleted: (threadId: string) => void;+}) {+ const handleThreadCreated = useCallback(+ (threadId: string) => onThreadCreated(session.id, threadId),+ [session.id, onThreadCreated],+ );+ const handleStateChange = useCallback(+ (state: ChatSessionState) => onStateChange(session.id, state),+ [session.id, onStateChange],+ );+ const sessionId = useThreadSessionId(projectKey, agent.id, session.threadId);++ return (+ <div className={cn('absolute inset-0', !active && 'hidden')}>+ <AiChatThread+ key={agent.id}+ projectKey={projectKey}+ agent={agent}+ threadId={session.threadId}+ onThreadCreated={handleThreadCreated}+ onStateChange={handleStateChange}+ composerStart={+ <>+ <ChatPanelAgentSwitcher+ agents={agents}+ selected={agent}+ providerLabel={providerLabel}+ disabled={session.running}+ onSelect={(agentId) => onSelectAgent(session, agentId)}+ />+ <ChatPanelHistory+ projectKey={projectKey}+ agentId={agent.id}+ agentName={agent.name}+ selectedThreadId={session.threadId}+ onSelect={(threadId) => onSelectThread(agent.id, threadId)}+ onDeleted={onThreadDeleted}+ />+ {sessionId && <AiChatSessionBadge sessionId={sessionId} />}+ </>+ }+ />+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelTab.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelTab.tsxnew file mode 100644index 00000000..b60e89b4--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelTab.tsx@@ -0,0 +1,91 @@+'use client';++import { useState } from 'react';+import { LoaderCircle, X } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { cn } from '@/lib/utils';+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';+import { ChatPanelTabRename } from './ChatPanelTabRename';+import { useChatSessionTitle } from '../../hooks/useChatSessionTitle';+import type { ChatSession } from '../../hooks/useChatSessions';++// One session in the tab row.+export function ChatPanelTab({+ projectKey,+ session,+ active,+ dragging = false,+ editing = false,+ onEditing,+ onSelect,+ onClose,+}: {+ projectKey: string;+ session: ChatSession;+ active: boolean;+ dragging?: boolean;+ editing?: boolean;+ onEditing?: (editing: boolean) => void;+ onSelect: () => void;+ onClose: () => void;+}) {+ const t = useTranslations('aiChat');+ const { title, agentName } = useChatSessionTitle(projectKey, session);+ // Controlled, so that a tab being dragged shows no tooltip over the row it moves in.+ const [tooltipOpen, setTooltipOpen] = useState(false);++ return (+ <div+ className={cn(+ 'group relative flex shrink-0 items-center rounded-md transition-colors',+ active ? 'bg-accent' : 'hover:bg-accent/50',+ )}+ >+ {editing && session.threadId ? (+ <ChatPanelTabRename+ projectKey={projectKey}+ agentId={session.agentId}+ threadId={session.threadId}+ title={title}+ onDone={() => onEditing?.(false)}+ />+ ) : (+ <Tooltip open={tooltipOpen && !dragging} onOpenChange={setTooltipOpen}>+ <TooltipTrigger asChild>+ <button+ type="button"+ onClick={onSelect}+ // A chat that has not started has no thread to carry a title yet.+ onDoubleClick={() => session.threadId && onEditing?.(true)}+ aria-pressed={active}+ className="flex max-w-40 items-center gap-1.5 py-1 ps-2 pe-7 text-xs"+ >+ {session.running && (+ <LoaderCircle className="size-3 shrink-0 animate-spin text-muted-foreground" />+ )}+ <span className={cn('truncate', !active && 'text-muted-foreground')}>{title}</span>+ </button>+ </TooltipTrigger>+ {/* Which agent a tab chats with is only on screen for the one in front. */}+ <TooltipContent side="bottom" className="max-w-64">+ <div className="truncate">{title}</div>+ {agentName && <div className="font-medium text-muted-foreground">{agentName}</div>}+ {session.threadId && (+ <div className="mt-1 text-[11px] text-muted-foreground/70">{t('renameHint')}</div>+ )}+ </TooltipContent>+ </Tooltip>+ )}++ <button+ type="button"+ onClick={onClose}+ title={t('closeTab')}+ className="absolute end-1 rounded-sm p-0.5 text-muted-foreground hover:text-foreground"+ >+ <X className="size-3" />+ <span className="sr-only">{t('closeTab')}</span>+ </button>+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelTabRename.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabRename.tsxnew file mode 100644index 00000000..a8f56e4b--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabRename.tsx@@ -0,0 +1,54 @@+'use client';++import { useState } from 'react';+import { useTranslations } from 'next-intl';+import { useRenameAgentThread } from '@/services/aiAgents.service';+import { Input } from '@/components/ui/input';++// The title of a conversation, being typed in place of its tab. Enter and blur save it+// on the thread, Escape leaves it as it was.+export function ChatPanelTabRename({+ projectKey,+ agentId,+ threadId,+ title,+ onDone,+}: {+ projectKey: string;+ agentId: number;+ threadId: string;+ title: string;+ onDone: () => void;+}) {+ const t = useTranslations('aiChat');+ const rename = useRenameAgentThread(projectKey, agentId);+ const [draft, setDraft] = useState(title);++ const commit = () => {+ onDone();+ const next = draft.trim();+ if (next && next !== title) rename.mutate({ threadId, title: next });+ };++ return (+ <Input+ autoFocus+ value={draft}+ maxLength={80}+ aria-label={t('renameThread')}+ onFocus={(e) => e.currentTarget.select()}+ onChange={(e) => setDraft(e.target.value)}+ onBlur={commit}+ onKeyDown={(e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ e.currentTarget.blur();+ } else if (e.key === 'Escape') {+ setDraft(title);+ onDone();+ }+ }}+ className="h-auto w-40 border-0 bg-transparent px-2 py-1 text-xs shadow-none focus-visible:ring-0"+ />+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelTabSortable.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabSortable.tsxnew file mode 100644index 00000000..bf573943--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabSortable.tsx@@ -0,0 +1,71 @@+'use client';++import { useState } from 'react';+import { useSortable } from '@dnd-kit/sortable';+import { CSS } from '@dnd-kit/utilities';+import { cn } from '@/lib/utils';+import { ChatPanelTab } from './ChatPanelTab';+import type { ChatSession } from '../../hooks/useChatSessions';++// A tab of the row in its place, which a drag moves. The drag listeners sit on this+// wrapper rather than on the tab's own buttons: the keyboard sensor takes over Space and+// Enter, which those buttons need for themselves.+export function ChatPanelTabSortable({+ projectKey,+ session,+ active,+ onSelect,+ onClose,+}: {+ projectKey: string;+ session: ChatSession;+ active: boolean;+ onSelect: () => void;+ onClose: () => void;+}) {+ const [editing, setEditing] = useState(false);+ // A tab whose title is being typed does not move: the drag listeners would take the+ // press that puts the caret in the input.+ const {+ attributes,+ listeners,+ setNodeRef,+ setActivatorNodeRef,+ transform,+ transition,+ isDragging,+ } = useSortable({+ id: session.id,+ disabled: editing,+ });++ return (+ <div+ ref={(node) => {+ setNodeRef(node);+ setActivatorNodeRef(node);+ }}+ // Translate, not the full transform: tabs are of different widths, and the scale+ // part of it would squeeze the dragged tab to the width of the one under it.+ style={{ transform: CSS.Translate.toString(transform), transition }}+ {...attributes}+ {...listeners}+ className={cn(+ 'shrink-0',+ editing ? 'cursor-text' : 'cursor-grab',+ isDragging && 'opacity-40',+ )}+ >+ <ChatPanelTab+ projectKey={projectKey}+ session={session}+ active={active}+ dragging={isDragging}+ editing={editing}+ onEditing={setEditing}+ onSelect={onSelect}+ onClose={onClose}+ />+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelTabs.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabs.tsxnew file mode 100644index 00000000..00092dea--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabs.tsx@@ -0,0 +1,111 @@+'use client';++import { closestCenter, DndContext, type DragEndEvent } from '@dnd-kit/core';+import { horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable';+import { Plus } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { useStripSortSensors } from '@/lib/dnd';+import { Button } from '@/components/ui/button';+import { ChatPanelTab } from './ChatPanelTab';+import { ChatPanelTabSortable } from './ChatPanelTabSortable';+import { ChatPanelTabsOverflow } from './ChatPanelTabsOverflow';+import { useTabOverflow } from '../../hooks/useTabOverflow';+import type { ChatSession } from '../../hooks/useChatSessions';++// The open sessions of the panel, with the control that opens one more. The row shows+// the tabs it has width for and lists the rest in a menu.+export function ChatPanelTabs({+ projectKey,+ sessions,+ activeId,+ onSelect,+ onClose,+ onNewTab,+ onMoveTab,+ onSwapTabs,+}: {+ projectKey: string;+ sessions: ChatSession[];+ activeId: string | null;+ onSelect: (id: string) => void;+ onClose: (id: string) => void;+ onNewTab: () => void;+ onMoveTab: (id: string, overId: string) => void;+ onSwapTabs: (id: string, otherId: string) => void;+}) {+ const t = useTranslations('aiChat');+ const sensors = useStripSortSensors();+ const { rowRef, measureRef, visible, hidden } = useTabOverflow(sessions, activeId);+ const lastVisibleId = visible[visible.length - 1]?.id ?? null;++ // Selecting from the menu shows that chat in the last slot of the row; the swap is+ // what keeps it there afterwards.+ const selectHidden = (id: string) => {+ if (lastVisibleId) onSwapTabs(id, lastVisibleId);+ onSelect(id);+ };++ return (+ <div className="relative z-10 flex items-center gap-1 border-b px-2 py-1 shadow-[var(--chat-tabs-shadow)]">+ <div ref={rowRef} className="flex min-w-0 flex-1 items-center gap-1 overflow-hidden">+ <DndContext+ sensors={sensors}+ collisionDetection={closestCenter}+ onDragEnd={({ active, over }: DragEndEvent) => {+ if (over && active.id !== over.id) onMoveTab(String(active.id), String(over.id));+ }}+ >+ <SortableContext+ items={visible.map((session) => session.id)}+ strategy={horizontalListSortingStrategy}+ >+ {visible.map((session) => (+ <ChatPanelTabSortable+ key={session.id}+ projectKey={projectKey}+ session={session}+ active={session.id === activeId}+ onSelect={() => onSelect(session.id)}+ onClose={() => onClose(session.id)}+ />+ ))}+ </SortableContext>+ </DndContext>+ </div>++ {hidden.length > 0 && (+ <ChatPanelTabsOverflow+ projectKey={projectKey}+ sessions={hidden}+ activeId={activeId}+ onSelect={selectHidden}+ onClose={onClose}+ />+ )}++ <Button+ variant="ghost"+ size="icon"+ className="size-7 shrink-0 text-muted-foreground hover:text-foreground"+ title={t('newChat')}+ onClick={onNewTab}+ >+ <Plus />+ <span className="sr-only">{t('newChat')}</span>+ </Button>++ <div ref={measureRef} aria-hidden className="pointer-events-none invisible absolute flex">+ {sessions.map((session) => (+ <ChatPanelTab+ key={session.id}+ projectKey={projectKey}+ session={session}+ active={false}+ onSelect={() => {}}+ onClose={() => {}}+ />+ ))}+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelTabsMenuItem.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabsMenuItem.tsxnew file mode 100644index 00000000..40516cb5--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabsMenuItem.tsx@@ -0,0 +1,54 @@+'use client';++import { LoaderCircle, X } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { cn } from '@/lib/utils';+import { Button } from '@/components/ui/button';+import { DropdownMenuItem } from '@/components/ui/dropdown-menu';+import { useChatSessionTitle } from '../../hooks/useChatSessionTitle';+import type { ChatSession } from '../../hooks/useChatSessions';++// One session in the menu of the tabs the row did not fit. The close control sits next+// to the item rather than inside it, so closing a tab leaves the menu open.+export function ChatPanelTabsMenuItem({+ projectKey,+ session,+ active,+ onSelect,+ onClose,+}: {+ projectKey: string;+ session: ChatSession;+ active: boolean;+ onSelect: () => void;+ onClose: () => void;+}) {+ const t = useTranslations('aiChat');+ const { title, agentName } = useChatSessionTitle(projectKey, session);++ return (+ <div className="relative">+ <DropdownMenuItem+ className={cn('items-start pe-8', active && 'bg-accent')}+ onSelect={onSelect}+ >+ {session.running && <LoaderCircle className="mt-1 size-3 shrink-0 animate-spin" />}+ <div className="min-w-0 flex-1">+ <div className="truncate">{title}</div>+ {agentName && <div className="truncate text-xs text-muted-foreground">{agentName}</div>}+ </div>+ </DropdownMenuItem>++ <Button+ variant="ghost"+ size="icon"+ title={t('closeTab')}+ onClick={onClose}+ className="absolute end-1 top-1/2 size-6 -translate-y-1/2 text-muted-foreground hover:text-foreground"+ >+ <X className="size-3" />+ <span className="sr-only">{t('closeTab')}</span>+ </Button>+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanelTabsOverflow.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabsOverflow.tsxnew file mode 100644index 00000000..d4c65efd--- /dev/null+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanelTabsOverflow.tsx@@ -0,0 +1,58 @@+'use client';++import { MoreHorizontal } from 'lucide-react';+import { useTranslations } from 'next-intl';+import { Button } from '@/components/ui/button';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';+import { ChatPanelTabsMenuItem } from './ChatPanelTabsMenuItem';+import type { ChatSession } from '../../hooks/useChatSessions';++// The sessions the tab row has no width for.+export function ChatPanelTabsOverflow({+ projectKey,+ sessions,+ activeId,+ onSelect,+ onClose,+}: {+ projectKey: string;+ sessions: ChatSession[];+ activeId: string | null;+ onSelect: (id: string) => void;+ onClose: (id: string) => void;+}) {+ const t = useTranslations('aiChat');++ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ size="icon"+ className="size-7 shrink-0 text-muted-foreground hover:text-foreground"+ title={t('moreTabs', { count: sessions.length })}+ >+ <MoreHorizontal />+ <span className="sr-only">{t('moreTabs', { count: sessions.length })}</span>+ </Button>+ </DropdownMenuTrigger>++ <DropdownMenuContent align="end" className="w-64">+ {sessions.map((session) => (+ <ChatPanelTabsMenuItem+ key={session.id}+ projectKey={projectKey}+ session={session}+ active={session.id === activeId}+ onSelect={() => onSelect(session.id)}+ onClose={() => onClose(session.id)}+ />+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsxnew file mode 100644index 00000000..ede1a0fe--- /dev/null+++ b/apps/web/src/features/ai-chat/components/shared/AiChatAgentMenu.tsx@@ -0,0 +1,53 @@+'use client';++import { Bot, Check } from 'lucide-react';+import { useTranslations } from 'next-intl';+import type { AiAgent } from '@/lib/api';+import {+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+} from '@/components/ui/dropdown-menu';+import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';+import { agentModelLabel } from '../../utils/agentModelLabel';++// The project's agents to pick from, as the content of a dropdown the host opens with+// its own trigger. An external agent shows the state of its runner instead of a model:+// it answers only while that runner is connected.+export function AiChatAgentMenu({+ agents,+ selectedId,+ providerLabel,+ onSelect,+}: {+ agents: AiAgent[];+ selectedId: number | null;+ providerLabel: (key: string) => string;+ onSelect: (agentId: number) => void;+}) {+ const t = useTranslations('aiChat');++ return (+ <DropdownMenuContent align="start" className="w-64">+ <DropdownMenuLabel>{t('agents')}</DropdownMenuLabel>+ <DropdownMenuSeparator />+ {agents.map((agent) => (+ <DropdownMenuItem key={agent.id} onSelect={() => onSelect(agent.id)} className="gap-2">+ <Bot className="size-4 shrink-0" />+ <div className="min-w-0 flex-1">+ <div className="truncate text-sm">{agent.name}</div>+ <div className="truncate text-xs text-muted-foreground">+ {agent.kind === 'external' ? (+ <AgentRunnerStatus agent={agent} compact />+ ) : (+ agentModelLabel(agent, providerLabel, t('noModel'))+ )}+ </div>+ </div>+ {agent.id === selectedId && <Check className="size-4 shrink-0" />}+ </DropdownMenuItem>+ ))}+ </DropdownMenuContent>+ );+}diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatSessionBadge.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatSessionBadge.tsxindex b08d1f0f..0dbf3c03 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatSessionBadge.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatSessionBadge.tsx@@ -4,19 +4,13 @@ import { Check, Copy, Terminal } from 'lucide-react';import { useState } from 'react';import { useTranslations } from 'next-intl';import { Button } from '@/components/ui/button';+import { InputGroupButton } from '@/components/ui/input-group';import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';// The coding agent session the agent's runner keeps for this conversation on its own// machine. It is what the operator resumes to read the full transcript — `claude-// --resume <id>` in the runner's working directory. `compact` drops the id from the-// trigger, for the floating window, where the header has no room for it.-export function AiChatSessionBadge({- sessionId,- compact = false,-}: {- sessionId: string;- compact?: boolean;-}) {+// --resume <id>` in the runner's working directory.+export function AiChatSessionBadge({ sessionId }: { sessionId: string }) {const t = useTranslations('aiChat');const [copied, setCopied] = useState(false);@@ -29,25 +23,16 @@ export function AiChatSessionBadge({return (<Popover><PopoverTrigger asChild>- <Button+ <InputGroupButton+ type="button"variant="ghost"- size={compact ? 'icon' : 'sm'}+ size="icon-xs"title={t('sessionLabel')}- className={- compact- ? 'size-7 shrink-0 text-muted-foreground hover:text-foreground'- : 'h-7 min-w-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground'- }+ className="rounded-md text-muted-foreground hover:text-foreground">- <Terminal className="size-3.5 shrink-0" />- {compact ? (- <span className="sr-only">{t('sessionLabel')}</span>- ) : (- <span className="max-w-56 truncate font-mono text-xs" dir="ltr">- {sessionId}- </span>- )}- </Button>+ <Terminal className="shrink-0" />+ <span className="sr-only">{t('sessionLabel')}</span>+ </InputGroupButton></PopoverTrigger><PopoverContent align="end" className="w-96 space-y-2"><p className="text-sm font-medium">{t('sessionLabel')}</p>diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsxindex f252b59c..2a70a105 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatThread.tsx@@ -1,6 +1,6 @@'use client';-import { useEffect, useRef } from 'react';+import { useEffect, useRef, type ReactNode } from 'react';import { useQueryClient } from '@tanstack/react-query';import type { AiAgent } from '@/lib/api';import { useAgentChat } from '@/hooks/useAgentChat';@@ -22,11 +22,18 @@ export function AiChatThread({agent,threadId,onThreadCreated,+ onStateChange,+ composerStart,}: {projectKey: string;agent: AiAgent;threadId: string | null;onThreadCreated: (threadId: string) => void;+ // Reported so a host that keeps the conversation out of sight can still tell what is+ // going on in it.+ onStateChange?: (state: { running: boolean; hasMessages: boolean }) => void;+ // A control of the host that belongs to this conversation, put next to its composer.+ composerStart?: ReactNode;}) {const {messages,@@ -51,6 +58,10 @@ export function AiChatThread({void qc.invalidateQueries({ queryKey: qk.agentThreads(projectKey, agent.id) });}, [status, qc, projectKey, agent.id]);+ useEffect(() => {+ onStateChange?.({ running: status !== 'ready', hasMessages: messages.length > 0 });+ }, [status, messages.length, onStateChange]);+// How many transcript pages of the active thread are already in the conversation.// Page 0 counts as merged from the start: for a restored thread it is what// loadThread put there, and for a thread created live in this session its server@@ -103,6 +114,7 @@ export function AiChatThread({onSend={send}onStop={stop}onRemovePending={removePending}+ composerStart={composerStart}hasEarlierMessages={messagesQuery.hasNextPage}isLoadingEarlier={messagesQuery.isFetchingNextPage}onLoadEarlier={() => void messagesQuery.fetchNextPage()}diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatThreadItemSkeleton.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatThreadItemSkeleton.tsxnew file mode 100644index 00000000..2edc0030--- /dev/null+++ b/apps/web/src/features/ai-chat/components/shared/AiChatThreadItemSkeleton.tsx@@ -0,0 +1,14 @@+import { Skeleton } from '@/components/ui/skeleton';++// Stands in for one conversation in the thread list: its title and the time under it.+export function AiChatThreadItemSkeleton() {+ return (+ <div className="flex items-start gap-2 px-1.5 py-2">+ <Skeleton className="mt-0.5 size-3.5 shrink-0 rounded" />+ <div className="min-w-0 flex-1 space-y-1.5">+ <Skeleton className="h-3.5 w-4/5 rounded" />+ <Skeleton className="h-3 w-12 rounded" />+ </div>+ </div>+ );+}diff --git a/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsx b/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsxindex ea7ac4c8..34e1e5a4 100644--- a/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsx+++ b/apps/web/src/features/ai-chat/components/shared/AiChatThreadList.tsx@@ -1,19 +1,19 @@'use client';-import { useState } from 'react';+import { useEffect, useRef, useState } from 'react';import { useTranslations } from 'next-intl';import { useAgentThreadsQuery, useDeleteAgentThread } from '@/services/aiAgents.service';-import { Skeleton } from '@/components/ui/skeleton';import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';import type { AiChatThread } from '@/lib/api';import { AiChatThreadItem } from './AiChatThreadItem';+import { AiChatThreadItemSkeleton } from './AiChatThreadItemSkeleton';-// The caller's own past conversations with one agent, newest first. Used by both the-// AI Chat page's thread rail and the floating chat's history layer; each host supplies-// its own header. `selectedThreadId` marks the conversation currently shown; a thread-// that has not produced its first reply yet has no id and so is not in this list.-// Deleting a conversation removes it and its messages; `onDeleted` lets the host reset-// the chat when the deleted one was open.+// The caller's own past conversations with one agent, newest first, loaded a page at a+// time as the end of the list comes into view. The host supplies the header around it.+// `selectedThreadId` marks the conversation currently shown; a thread that has not+// produced its first reply yet has no id and so is not in this list. Deleting a+// conversation removes it and its messages; `onDeleted` lets the host reset the chat+// when the deleted one was open.export function AiChatThreadList({projectKey,agentId,@@ -30,10 +30,26 @@ export function AiChatThreadList({const t = useTranslations('aiChat');const tCommon = useTranslations('common');const threadsQuery = useAgentThreadsQuery(projectKey, agentId);- const threads = threadsQuery.data ?? [];+ const threads = threadsQuery.data?.pages.flatMap((page) => page.items) ?? [];+ const { hasNextPage, isFetchingNextPage, fetchNextPage } = threadsQuery;const deleteThread = useDeleteAgentThread(projectKey, agentId);const [pending, setPending] = useState<AiChatThread | null>(null);+ const sentinelRef = useRef<HTMLDivElement | null>(null);+ useEffect(() => {+ const el = sentinelRef.current;+ if (!el || !hasNextPage) return;+ const observer = new IntersectionObserver(+ (entries) => {+ if (entries[0].isIntersecting && !isFetchingNextPage) void fetchNextPage();+ },+ // Start loading a bit before the sentinel is fully visible.+ { rootMargin: '200px' },+ );+ observer.observe(el);+ return () => observer.disconnect();+ }, [hasNextPage, isFetchingNextPage, fetchNextPage]);+async function confirmDelete() {if (!pending) return;await deleteThread.mutateAsync(pending.id);@@ -45,13 +61,7 @@ export function AiChatThreadList({return (<div className="min-h-0 flex-1 space-y-1 overflow-y-auto p-3">{Array.from({ length: 5 }).map((_, i) => (- <div key={i} className="flex items-start gap-2 px-1.5 py-2">- <Skeleton className="mt-0.5 size-3.5 shrink-0 rounded" />- <div className="min-w-0 flex-1 space-y-1.5">- <Skeleton className="h-3.5 w-4/5 rounded" />- <Skeleton className="h-3 w-12 rounded" />- </div>- </div>+ <AiChatThreadItemSkeleton key={i} />))}</div>);@@ -77,6 +87,8 @@ export function AiChatThreadList({onDelete={() => setPending(thread)}/>))}+ <div ref={sentinelRef} />+ {isFetchingNextPage && <AiChatThreadItemSkeleton />}</div>{pending && (diff --git a/apps/web/src/features/ai-chat/hooks/useAiChatSelection.ts b/apps/web/src/features/ai-chat/hooks/useAiChatSelection.tsdeleted file mode 100644index 440125bd..00000000--- a/apps/web/src/features/ai-chat/hooks/useAiChatSelection.ts+++ /dev/null@@ -1,65 +0,0 @@-'use client';--import { useState } from 'react';-import { useQueryClient } from '@tanstack/react-query';-import { useAiAgentsQuery } from '@/services/aiAgents.service';-import { useIntegrationCatalogQuery } from '@/services/integrations.service';-import { qk } from '@/services/queryKeys';--// The agents available for chat and which conversation is shown, shared by the AI Chat-// page and the floating chat. Both kinds appear: an internal agent answers in the API-// process, an external one through the runner its operator runs.-//-// `selectedThreadId` is a past thread, or null for a fresh chat. `newChatNonce` bumps on-// "New chat" so the host can key the conversation by it and remount into a fresh session-// without changing agents.-export function useAiChatSelection(projectKey: string | null) {- const qc = useQueryClient();- const agentsQuery = useAiAgentsQuery(projectKey);- const agents = agentsQuery.data ?? [];- const catalog = useIntegrationCatalogQuery(projectKey).data ?? [];- const providerLabel = (key: string) => catalog.find((entry) => entry.key === key)?.label ?? key;-- const [selectedId, setSelectedId] = useState<number | null>(null);- const selected = agents.find((agent) => agent.id === selectedId) ?? agents[0] ?? null;- const [selectedThreadId, setSelectedThreadId] = useState<string | null>(null);- const [newChatNonce, setNewChatNonce] = useState(0);-- const selectAgent = (id: number) => {- setSelectedId(id);- setSelectedThreadId(null);- };-- const startNewChat = () => {- setSelectedThreadId(null);- setNewChatNonce((n) => n + 1);- };-- // A fresh chat produced its first reply: show it as the selected thread and refresh- // the history list, which now holds it.- const handleThreadCreated = (threadId: string) => {- setSelectedThreadId(threadId);- if (projectKey && selected)- void qc.invalidateQueries({ queryKey: qk.agentThreads(projectKey, selected.id) });- };-- // A deleted conversation cannot be shown: if it was the open one, fall back to a- // fresh chat.- const handleThreadDeleted = (threadId: string) => {- if (threadId === selectedThreadId) startNewChat();- };-- return {- agents,- isLoading: agentsQuery.isLoading,- providerLabel,- selected,- selectedThreadId,- newChatNonce,- selectAgent,- selectThread: setSelectedThreadId,- startNewChat,- handleThreadCreated,- handleThreadDeleted,- };-}diff --git a/apps/web/src/features/ai-chat/hooks/useChatPanel.ts b/apps/web/src/features/ai-chat/hooks/useChatPanel.tsnew file mode 100644index 00000000..23b897fd--- /dev/null+++ b/apps/web/src/features/ai-chat/hooks/useChatPanel.ts@@ -0,0 +1,86 @@+'use client';++import { useCallback, useEffect, useRef, useState } from 'react';++// Overlay puts the panel above the content; push makes the content area narrower by+// the width of the panel.+export type ChatPanelMode = 'overlay' | 'push';++export const chatPanelWidthKey = (projectKey: string) => `aiChat:panel:width:${projectKey}`;++const openKey = (projectKey: string) => `aiChat:panel:open:${projectKey}`;+const modeKey = (projectKey: string) => `aiChat:panel:mode:${projectKey}`;+const fullscreenKey = (projectKey: string) => `aiChat:panel:fullscreen:${projectKey}`;++function read(key: string): string | null {+ try {+ return localStorage.getItem(key);+ } catch {+ return null;+ }+}++function write(key: string, value: string) {+ try {+ localStorage.setItem(key, value);+ } catch {+ // Storage unavailable (private mode / quota); the panel still applies the change.+ }+}++// Whether the chat panel is open, which mode it is in and whether it stands over the+// whole viewport, kept per project on the device. `showByDefault` is the account+// preference: it opens the panel for a project the user has not opened or closed it in+// yet.+//+// The stored values are read in an effect, not in the state initializer: the+// initializer also runs in the server render, where a client-only value would not+// match the markup.+export function useChatPanel(projectKey: string | null, showByDefault: boolean) {+ const [open, setOpen] = useState(false);+ const [mode, setMode] = useState<ChatPanelMode>('overlay');+ const [fullscreen, setFullscreen] = useState(false);+ // The preference arrives after the first render and must not reopen a panel the+ // user closed in the meantime.+ const touched = useRef(false);++ useEffect(() => {+ touched.current = false;+ if (!projectKey) return;+ setMode(read(modeKey(projectKey)) === 'push' ? 'push' : 'overlay');+ setFullscreen(read(fullscreenKey(projectKey)) === 'on');+ setOpen(read(openKey(projectKey)) === 'open');+ }, [projectKey]);++ useEffect(() => {+ if (!projectKey || !showByDefault || touched.current) return;+ if (read(openKey(projectKey)) === null) setOpen(true);+ }, [projectKey, showByDefault]);++ const toggle = useCallback(() => {+ touched.current = true;+ setOpen((prev) => {+ const next = !prev;+ if (projectKey) write(openKey(projectKey), next ? 'open' : 'closed');+ return next;+ });+ }, [projectKey]);++ const toggleMode = useCallback(() => {+ setMode((prev) => {+ const next = prev === 'push' ? 'overlay' : 'push';+ if (projectKey) write(modeKey(projectKey), next);+ return next;+ });+ }, [projectKey]);++ const toggleFullscreen = useCallback(() => {+ setFullscreen((prev) => {+ const next = !prev;+ if (projectKey) write(fullscreenKey(projectKey), next ? 'on' : 'off');+ return next;+ });+ }, [projectKey]);++ return { open, mode, fullscreen, toggle, toggleMode, toggleFullscreen };+}diff --git a/apps/web/src/features/ai-chat/hooks/useChatSessionTitle.ts b/apps/web/src/features/ai-chat/hooks/useChatSessionTitle.tsnew file mode 100644index 00000000..f4fc54d3--- /dev/null+++ b/apps/web/src/features/ai-chat/hooks/useChatSessionTitle.ts@@ -0,0 +1,20 @@+'use client';++import { useTranslations } from 'next-intl';+import { useAiAgentsQuery, useLoadedAgentThreads } from '@/services/aiAgents.service';+import type { ChatSession } from './useChatSessions';++// What a session is called in the tab row and in the menu of the tabs that did not fit+// it. The title comes from the agent's thread list, which every tab of that agent reads+// from the same query; a session with no thread yet is a new chat and has none.+export function useChatSessionTitle(projectKey: string, session: ChatSession) {+ const t = useTranslations('aiChat');+ const threads = useLoadedAgentThreads(projectKey, session.agentId);+ const agents = useAiAgentsQuery(projectKey).data ?? [];+ const thread = threads.find((candidate) => candidate.id === session.threadId);++ return {+ title: thread?.title ?? t('newChat'),+ agentName: agents.find((agent) => agent.id === session.agentId)?.name ?? '',+ };+}diff --git a/apps/web/src/features/ai-chat/hooks/useChatSessions.ts b/apps/web/src/features/ai-chat/hooks/useChatSessions.tsnew file mode 100644index 00000000..8bf062ec--- /dev/null+++ b/apps/web/src/features/ai-chat/hooks/useChatSessions.ts@@ -0,0 +1,232 @@+'use client';++import { useCallback, useEffect, useState } from 'react';+import { arrayMove } from '@dnd-kit/sortable';++// One open conversation in the chat panel. `threadId` is null until the agent answers+// the first message, and stays null for an agent that keeps no memory. `running` and+// `hasMessages` are what the session's transcript reports back, so the panel knows what+// is going on in a session it is not showing.+export type ChatSession = {+ id: string;+ agentId: number;+ threadId: string | null;+ running: boolean;+ hasMessages: boolean;+};++export type ChatSessionState = Pick<ChatSession, 'running' | 'hasMessages'>;++const storageKey = (projectKey: string) => `aiChat:panel:tabs:${projectKey}`;++const newSession = (agentId: number, threadId: string | null = null): ChatSession => ({+ id: crypto.randomUUID(),+ agentId,+ threadId,+ running: false,+ hasMessages: false,+});++type StoredTabs = {+ sessions: { id: string; agentId: number; threadId: string }[];+ activeId: string | null;+};++function isStored(value: unknown): value is StoredTabs {+ if (typeof value !== 'object' || value === null) return false;+ const tabs = value as StoredTabs;+ return (+ Array.isArray(tabs.sessions) &&+ tabs.sessions.every(+ (session) =>+ typeof session.id === 'string' &&+ typeof session.agentId === 'number' &&+ typeof session.threadId === 'string',+ ) &&+ (typeof tabs.activeId === 'string' || tabs.activeId === null)+ );+}++function read(projectKey: string): { sessions: ChatSession[]; activeId: string | null } {+ try {+ const raw = localStorage.getItem(storageKey(projectKey));+ const parsed: unknown = raw ? JSON.parse(raw) : null;+ if (!isStored(parsed)) return { sessions: [], activeId: null };+ return {+ sessions: parsed.sessions.map((session) => ({+ ...session,+ running: false,+ hasMessages: true,+ })),+ activeId: parsed.activeId,+ };+ } catch {+ return { sessions: [], activeId: null };+ }+}++function write(projectKey: string, sessions: ChatSession[], activeId: string | null) {+ // A session with no thread is a chat that has not started: there is nothing to+ // restore it from, so it is not kept.+ const stored = sessions.flatMap((session) =>+ session.threadId+ ? [{ id: session.id, agentId: session.agentId, threadId: session.threadId }]+ : [],+ );+ try {+ localStorage.setItem(storageKey(projectKey), JSON.stringify({ sessions: stored, activeId }));+ } catch {+ // Storage unavailable (private mode / quota); the tabs still work in this tab.+ }+}++// The sessions the chat panel holds open, for one project. Every session stays mounted+// while it is open, so a session that is not shown keeps its transcript and its composer+// and continues to receive its reply.+//+// The panel always holds at least one session: closing the last one leaves a fresh chat+// in its place. The tabs and the active one are kept on the device, so a reload opens+// the same conversations.+export function useChatSessions(projectKey: string | null, defaultAgentId: number | null) {+ const [sessions, setSessions] = useState<ChatSession[]>([]);+ const [activeId, setActiveId] = useState<string | null>(null);+ // The agent a new tab starts with: the one the user picked last.+ const [lastAgentId, setLastAgentId] = useState<number | null>(null);+ const [loadedKey, setLoadedKey] = useState<string | null>(null);++ // The panel outlives the route, so a move to a different project loads that+ // project's tabs. Storage is read here rather than in the state initializer: this+ // component also renders on the server, where there is none.+ useEffect(() => {+ if (!projectKey) return;+ const stored = read(projectKey);+ setSessions(stored.sessions);+ setActiveId(stored.activeId);+ setLastAgentId(null);+ setLoadedKey(projectKey);+ }, [projectKey]);++ // Only once this project's tabs have been read: a fresh chat made before that would+ // take the place of the kept ones.+ useEffect(() => {+ if (defaultAgentId == null || loadedKey !== projectKey || sessions.length > 0) return;+ const first = newSession(defaultAgentId);+ setSessions([first]);+ setActiveId(first.id);+ }, [defaultAgentId, projectKey, loadedKey, sessions.length]);++ // Only once this project's tabs have been read: an empty state on the way there+ // would overwrite them.+ useEffect(() => {+ if (projectKey && loadedKey === projectKey) write(projectKey, sessions, activeId);+ }, [projectKey, loadedKey, sessions, activeId]);++ const update = useCallback((id: string, change: Partial<ChatSession>) => {+ setSessions((prev) =>+ prev.map((session) => (session.id === id ? { ...session, ...change } : session)),+ );+ }, []);++ const openTab = useCallback((agentId: number, threadId: string | null = null) => {+ const session = newSession(agentId, threadId);+ setSessions((prev) => [...prev, session]);+ setActiveId(session.id);+ setLastAgentId(agentId);+ }, []);++ // Opens a past conversation: one that is already open is brought forward instead of+ // opening a second tab for it.+ const openThread = useCallback(+ (agentId: number, threadId: string) => {+ const existing = sessions.find((session) => session.threadId === threadId);+ if (existing) {+ setActiveId(existing.id);+ return;+ }+ openTab(agentId, threadId);+ },+ [sessions, openTab],+ );++ // The session next to the closed one takes over. Closing the last session leaves an+ // empty chat with the agent that session used.+ const closeSession = useCallback(+ (id: string) => {+ const index = sessions.findIndex((session) => session.id === id);+ if (index < 0) return;+ const rest = sessions.filter((session) => session.id !== id);+ if (rest.length === 0) {+ const fresh = newSession(sessions[index].agentId);+ setSessions([fresh]);+ setActiveId(fresh.id);+ return;+ }+ setSessions(rest);+ if (activeId === id) setActiveId((rest[index] ?? rest[rest.length - 1]).id);+ },+ [sessions, activeId],+ );++ // A tab dragged onto another one takes its place in the row. The order is what is+ // kept on the device, so it is also the order a reload opens the chats in.+ const moveTab = useCallback((id: string, overId: string) => {+ setSessions((prev) => {+ const from = prev.findIndex((session) => session.id === id);+ const to = prev.findIndex((session) => session.id === overId);+ if (from < 0 || to < 0) return prev;+ return arrayMove(prev, from, to);+ });+ }, []);++ // A chat picked from the menu of the tabs the row did not fit takes the place of the+ // tab it appears in, so it stays in the row once another tab is selected.+ const swapTabs = useCallback((id: string, otherId: string) => {+ setSessions((prev) => {+ const from = prev.findIndex((session) => session.id === id);+ const to = prev.findIndex((session) => session.id === otherId);+ if (from < 0 || to < 0) return prev;+ const next = [...prev];+ next[from] = prev[to];+ next[to] = prev[from];+ return next;+ });+ }, []);++ const active = sessions.find((session) => session.id === activeId) ?? sessions[0] ?? null;++ return {+ sessions,+ active,+ setActive: setActiveId,+ newTab: useCallback(() => {+ const agentId = lastAgentId ?? defaultAgentId;+ if (agentId != null) openTab(agentId);+ }, [openTab, lastAgentId, defaultAgentId]),+ openTab,+ openThread,+ closeSession,+ moveTab,+ swapTabs,+ setThread: useCallback((id: string, threadId: string) => update(id, { threadId }), [update]),+ setAgent: useCallback(+ (id: string, agentId: number) => {+ setLastAgentId(agentId);+ update(id, { agentId });+ },+ [update],+ ),+ // A session reports its state on every render of its transcript. Keeping the array+ // as it is when nothing changed is what stops that from re-rendering the panel.+ setState: useCallback((id: string, state: ChatSessionState) => {+ setSessions((prev) =>+ prev.some(+ (session) =>+ session.id === id &&+ (session.running !== state.running || session.hasMessages !== state.hasMessages),+ )+ ? prev.map((session) => (session.id === id ? { ...session, ...state } : session))+ : prev,+ );+ }, []),+ };+}diff --git a/apps/web/src/features/ai-chat/hooks/useProviderLabel.ts b/apps/web/src/features/ai-chat/hooks/useProviderLabel.tsnew file mode 100644index 00000000..5c8fd5ef--- /dev/null+++ b/apps/web/src/features/ai-chat/hooks/useProviderLabel.ts@@ -0,0 +1,10 @@+'use client';++import { useIntegrationCatalogQuery } from '@/services/integrations.service';++// Maps a model provider key to the label the integration catalog gives it, falling back+// to the key itself while the catalog loads or for a provider it does not carry.+export function useProviderLabel(projectKey: string | null) {+ const catalog = useIntegrationCatalogQuery(projectKey).data ?? [];+ return (key: string) => catalog.find((entry) => entry.key === key)?.label ?? key;+}diff --git a/apps/web/src/features/ai-chat/hooks/useTabOverflow.ts b/apps/web/src/features/ai-chat/hooks/useTabOverflow.tsnew file mode 100644index 00000000..d27ce8fb--- /dev/null+++ b/apps/web/src/features/ai-chat/hooks/useTabOverflow.ts@@ -0,0 +1,78 @@+'use client';++import { useLayoutEffect, useMemo, useRef, useState } from 'react';+import type { ChatSession } from './useChatSessions';++// The gap between two tabs, and the room the control that opens the rest takes next to+// them. Both are in the tab row's own classes.+const GAP = 4;+const OVERFLOW_WIDTH = 32;++function countThatFit(widths: number[], available: number) {+ let used = 0;+ for (let i = 0; i < widths.length; i += 1) {+ used += widths[i] + (i > 0 ? GAP : 0);+ if (used > available) return i;+ }+ return widths.length;+}++// Splits the sessions into the tabs the row shows and the ones its menu lists. The+// widths are read from a copy of the row that is laid out but not shown: the visible+// row holds only what fits, so it cannot report the width of a tab it does not render.+export function useTabOverflow(sessions: ChatSession[], activeId: string | null) {+ const rowRef = useRef<HTMLDivElement>(null);+ const measureRef = useRef<HTMLDivElement>(null);+ const [count, setCount] = useState(sessions.length);+ // The row loses this room to the control the moment it appears, so the width it+ // reports has to be read back to what the tabs alone have.+ const overflowShown = useRef(false);++ useLayoutEffect(() => {+ const row = rowRef.current;+ const measure = measureRef.current;+ if (!row || !measure) return;++ const apply = () => {+ const widths = Array.from(measure.children, (tab) => tab.getBoundingClientRect().width);+ const available = row.clientWidth + (overflowShown.current ? OVERFLOW_WIDTH : 0);+ const fit = countThatFit(widths, available);+ let next = fit === widths.length ? fit : countThatFit(widths, available - OVERFLOW_WIDTH);+ // The tab in front takes the last slot when its place in the row is past the ones+ // that fit, and it can be wider than the tab it stands in for: the room the rest+ // are measured against is what is left of the row once it has taken its own.+ const activeIndex = sessions.findIndex((session) => session.id === activeId);+ if (activeIndex >= next) {+ next = countThatFit(widths, available - OVERFLOW_WIDTH - GAP - widths[activeIndex]) + 1;+ }+ overflowShown.current = next < widths.length;+ setCount(next);+ };++ apply();+ const observer = new ResizeObserver(apply);+ observer.observe(row);+ observer.observe(measure);+ return () => observer.disconnect();+ }, [sessions, activeId]);++ return useMemo(() => {+ if (count >= sessions.length) return { rowRef, measureRef, visible: sessions, hidden: [] };++ const visible = sessions.slice(0, count);+ // The session in front keeps its tab whatever its place in the row, so it takes the+ // last slot when it did not fit.+ if (activeId && !visible.some((session) => session.id === activeId)) {+ const active = sessions.find((session) => session.id === activeId);+ if (active) visible.splice(Math.max(count - 1, 0), 1, active);+ }+ const shown = new Set(visible.map((session) => session.id));++ return {+ rowRef,+ measureRef,+ visible,+ hidden: sessions.filter((session) => !shown.has(session.id)),+ };+ }, [sessions, count, activeId]);+}diff --git a/apps/web/src/features/ai-chat/hooks/useThreadSessionId.ts b/apps/web/src/features/ai-chat/hooks/useThreadSessionId.tsindex 4dacc7aa..6106649a 100644--- a/apps/web/src/features/ai-chat/hooks/useThreadSessionId.ts+++ b/apps/web/src/features/ai-chat/hooks/useThreadSessionId.ts@@ -1,6 +1,6 @@'use client';-import { useAgentThreadsQuery } from '@/services/aiAgents.service';+import { useLoadedAgentThreads } from '@/services/aiAgents.service';// The coding agent session an external agent's runner keeps for the shown thread, which// the thread list is what carries. Null until a runner has reported one.@@ -9,7 +9,7 @@ export function useThreadSessionId(agentId: number | null,threadId: string | null,): string | null {- const threadsQuery = useAgentThreadsQuery(projectKey, agentId);+ const threads = useLoadedAgentThreads(projectKey, agentId);if (!threadId) return null;- return threadsQuery.data?.find((thread) => thread.id === threadId)?.cliSessionId ?? null;+ return threads.find((thread) => thread.id === threadId)?.cliSessionId ?? null;}diff --git a/apps/web/src/features/dashboards/components/WidgetFrame.tsx b/apps/web/src/features/dashboards/components/WidgetFrame.tsxindex 69501701..df9b478e 100644--- a/apps/web/src/features/dashboards/components/WidgetFrame.tsx+++ b/apps/web/src/features/dashboards/components/WidgetFrame.tsx@@ -100,7 +100,10 @@ export default function WidgetFrame({</DropdownMenu>)}</header>- <div className="min-h-0 flex-1 overflow-y-auto">{children}</div>+ {/* The gutter is reserved whether or not the scrollbar is there: a widget that+ sizes itself to this width would otherwise lose the room to the scrollbar,+ fit less, become shorter, and take the scrollbar away again. */}+ <div className="min-h-0 flex-1 [scrollbar-gutter:stable] overflow-y-auto">{children}</div></section>);}diff --git a/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsx b/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsxindex a2878905..aacbf5a3 100644--- a/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsx+++ b/apps/web/src/features/dashboards/components/widgets/PulseWidget.tsx@@ -52,12 +52,25 @@ export default function PulseWidget({const containerRef = useRef<HTMLDivElement>(null);const [width, setWidth] = useState(0);+ // Measured in whole pixels and applied on the next frame: the columns are laid out+ // from this width, and laying them out resizes the element again. Without the+ // rounding a sub-pixel width feeds back into itself, and without the frame the+ // observer and the render that follows it chain within one frame — which is the+ // update depth React gives up on.useEffect(() => {const el = containerRef.current;if (!el) return;- const ro = new ResizeObserver((entries) => setWidth(entries[0].contentRect.width));+ let frame = 0;+ const ro = new ResizeObserver((entries) => {+ const measured = Math.floor(entries[0].contentRect.width);+ cancelAnimationFrame(frame);+ frame = requestAnimationFrame(() => setWidth(measured));+ });ro.observe(el);- return () => ro.disconnect();+ return () => {+ cancelAnimationFrame(frame);+ ro.disconnect();+ };}, []);// Columns that fully fit the measured width (drawn), and a slightly larger fetch@@ -94,10 +107,17 @@ export default function PulseWidget({<div className="space-y-3"><p className="text-xs text-muted-foreground">{t(`caption.${unit}`)}</p>- {/* Full-width measuring wrapper; the grid draws only what fits (no scroll). */}- <div ref={containerRef} className="w-full overflow-hidden">+ {/* Full-width measuring wrapper; the grid draws only what fits (no scroll). Its+ height is the one the cells add up to, whatever is inside it: a widget that+ grew or shrank with the loading state would take the scrollbar of the frame+ around it away and back, and the width this measures with it. */}+ <div+ ref={containerRef}+ className="w-full overflow-hidden"+ style={{ height: geo.rows * geo.cell + (geo.rows - 1) * geo.gap }}+ >{isLoading || cols.length === 0 ? (- <Skeleton className="h-24 w-full" />+ <Skeleton className="size-full" />) : (<div style={{ display: 'flex', gap: geo.gap }}>{cols.map((col, ci) => (diff --git a/apps/web/src/hooks/useAgentChat.ts b/apps/web/src/hooks/useAgentChat.tsindex 2d56bf4c..b3b30107 100644--- a/apps/web/src/hooks/useAgentChat.ts+++ b/apps/web/src/hooks/useAgentChat.ts@@ -1,12 +1,14 @@'use client';import { useCallback, useEffect, useRef, useState } from 'react';-import { toast } from 'sonner';import { ApiError, streamAiAgentChat, streamAiAgentRun } from '@/lib/api';import type { AiChatMessage, AiChatPart, AiChatToolPart } from '@/lib/api';import { useTranslations } from 'next-intl';-export type ChatMessage = AiChatMessage;+// `error` is what a stream that failed left behind. It is not part of a stored+// transcript: a restored thread holds the answer the agent produced, not the run that+// broke.+export type ChatMessage = AiChatMessage & { error?: string };// Only a tool call between two chunks of the answer starts a new text part.function appendText(parts: AiChatPart[], chunk: string): AiChatPart[] {@@ -49,9 +51,10 @@ export type PendingMessage = { id: string; text: string };// one. threadId is null while a new conversation has not produced its first reply.//// A message sent while a reply is running is held in `pending` and sent on its own once-// that reply ends, one at a time and in the order it was typed. A reply that failed or-// was stopped pauses the queue: what is left waits until the next send, so a message is-// not thrown at an agent that is not answering.+// that reply ends, one at a time and in the order it was typed. A reply that failed+// pauses the queue: what is left waits until the next send, so a message is not thrown+// at an agent that is not answering. A stop is not a failure — it ends the reply being+// produced and the message waiting behind it is sent next.//// stop() ends the reply being produced. What the agent wrote before it stays in the// transcript, marked stopped. An internal agent's run is bound to the stream, so@@ -84,6 +87,9 @@ export function useAgentChat(projectKey: string, agentId: number, external: boolsetRunning(true);const stopper = new AbortController();stopRef.current = stopper;+ // Kept for the transcript rather than reported at once: the session may not be+ // the one on screen, and the answer is where the user looks for what happened.+ let failure: string | null = null;const assistantId = crypto.randomUUID();const createdAt = new Date().toISOString();@@ -155,31 +161,40 @@ export function useAgentChat(projectKey: string, agentId: number, external: boolsetThreadId(event.threadId);break;case 'error':- toast.error(event.message);+ failure = event.message;setQueuePaused(true);break;}}} catch (err) {// A stop ends the stream by aborting it; that is what was asked for, not a- // failure to report.+ // failure to report, and the queue behind it goes on.if (!stopper.signal.aborted) {- toast.error(err instanceof ApiError ? err.message : t('unreachable'));+ failure = err instanceof ApiError ? err.message : t('unreachable');+ setQueuePaused(true);}- setQueuePaused(true);} finally {runningRef.current = false;stopRef.current = null;setRunning(false);setStatus('ready');setActiveTool(null);- // Drop the assistant placeholder if the agent never produced anything (an error- // or a stop before the first chunk), so an empty bubble is not left behind.+ // Drop the assistant placeholder if the agent never produced anything and there+ // is nothing to say about it, so an empty bubble is not left behind. A failure+ // keeps the bubble: it carries the message.const stopped = stopper.signal.aborted;setMessages((m) =>m- .filter((msg) => !(msg.id === assistantId && msg.parts.length === 0))- .map((msg) => (stopped && msg.id === assistantId ? { ...msg, stopped: true } : msg)),+ .filter((msg) => !(msg.id === assistantId && msg.parts.length === 0 && !failure))+ .map((msg) =>+ msg.id === assistantId+ ? {+ ...msg,+ ...(stopped && { stopped: true }),+ ...(failure && { error: failure }),+ }+ : msg,+ ),);}},@@ -204,8 +219,8 @@ export function useAgentChat(projectKey: string, agentId: number, external: boolsetPending((queue) => queue.filter((message) => message.id !== id));}, []);- // Ends the reply being produced. Whatever is queued stays queued: stopping this reply- // is not a reason to discard what was typed while it ran.+ // Ends the reply being produced. What is queued behind it is sent next: stopping this+ // reply is what clears the way for the message typed while it ran.const stop = useCallback(() => {stopRef.current?.abort();}, []);diff --git a/apps/web/src/hooks/useAppCommands.tsx b/apps/web/src/hooks/useAppCommands.tsxindex 60f382aa..03cfffaa 100644--- a/apps/web/src/hooks/useAppCommands.tsx+++ b/apps/web/src/hooks/useAppCommands.tsx@@ -1,4 +1,4 @@-import { LayoutGrid, ListChecks, Plus, SquarePlus } from 'lucide-react';+import { LayoutGrid, ListChecks, MessagesSquare, Plus, SquarePlus } from 'lucide-react';import type { Project } from '@/lib/api';import { useTranslations } from 'next-intl';import { VIEWS, type WorkItemsView } from '@/utils/viewTypes';@@ -21,6 +21,7 @@ export function useAppCommands({onSelectAll,onNewProject,onSelectProject,+ onToggleChat,}: {hasProject: boolean;// True on the work items routes, where the layout and selection commands apply.@@ -33,6 +34,7 @@ export function useAppCommands({onSelectAll: () => void;onNewProject: () => void;onSelectProject: (key: string) => void;+ onToggleChat: () => void;}): {board: CommandSection | null;general: CommandSection | null;@@ -80,6 +82,16 @@ export function useAppCommands({run: onNewIssue,});}+ if (hasProject && can('ai_agents', 'read')) {+ generalItems.push({+ id: 'general.ai-chat',+ label: tPalette('toggleChat'),+ icon: <MessagesSquare />,+ keywords: 'ai agents chat panel',+ shortcut: hotkey('chat.toggle') ?? undefined,+ run: onToggleChat,+ });+ }generalItems.push({id: 'general.new-project',label: tPalette('newProject'),diff --git a/apps/web/src/hooks/useKeyboardShortcuts.ts b/apps/web/src/hooks/useKeyboardShortcuts.tsindex c308ccde..221cb7ba 100644--- a/apps/web/src/hooks/useKeyboardShortcuts.ts+++ b/apps/web/src/hooks/useKeyboardShortcuts.ts@@ -19,6 +19,8 @@ const VIEW_HOTKEYS: [HotkeyId, WorkItemsView][] = [// combination is a plain key that would land in the text being typed.export function useKeyboardShortcuts(opts: {hasProject: boolean;+ // Whether this project has a chat panel to show at all.+ hasChat: boolean;projects: Project[];// True while any modal/overlay is open, which suppresses the app bindings.overlayOpen: boolean;@@ -28,9 +30,11 @@ export function useKeyboardShortcuts(opts: {onNewIssue: () => void;onNewProject: () => void;onSettings: () => void;+ onToggleChat: () => void;}) {const {hasProject,+ hasChat,projects,overlayOpen,onToggleCommand,@@ -39,6 +43,7 @@ export function useKeyboardShortcuts(opts: {onNewIssue,onNewProject,onSettings,+ onToggleChat,} = opts;const { matches, digit } = useHotkeyMatch();@@ -85,12 +90,18 @@ export function useKeyboardShortcuts(opts: {if (hasProject && matches(e, 'project.settings')) {e.preventDefault();onSettings();+ return;+ }+ if (hasChat && matches(e, 'chat.toggle')) {+ e.preventDefault();+ onToggleChat();}}window.addEventListener('keydown', onKeyDown);return () => window.removeEventListener('keydown', onKeyDown);}, [hasProject,+ hasChat,projects,overlayOpen,matches,@@ -101,5 +112,6 @@ export function useKeyboardShortcuts(opts: {onNewIssue,onNewProject,onSettings,+ onToggleChat,]);}diff --git a/apps/web/src/hooks/useNavigationCommands.tsx b/apps/web/src/hooks/useNavigationCommands.tsxindex 286d119c..b17a6f67 100644--- a/apps/web/src/hooks/useNavigationCommands.tsx+++ b/apps/web/src/hooks/useNavigationCommands.tsx@@ -5,7 +5,6 @@ import {FolderKanban,Inbox,LayoutDashboard,- MessagesSquare,Server,Shield,SquareKanban,@@ -15,7 +14,6 @@ import {import { useTranslations } from 'next-intl';import { useSession } from '@/lib/auth-client';import {- aiChatPath,aiSectionPath,aiTeamPath,apiDocsPath,@@ -80,8 +78,6 @@ export function useNavigationCommands(projectKey: string | null): CommandSection);if (features.initiatives && can('initiatives', 'read'))add('nav.initiatives', t('initiatives'), <Target />, initiativesPath(key), 'epics');- if (can('ai_agents', 'read'))- add('nav.ai-chat', t('chatWithAiTeam'), <MessagesSquare />, aiChatPath(key), 'ai agents');for (const s of AI_TEAM_SECTIONS) {if (can(s.resource, 'read'))add(diff --git a/apps/web/src/hooks/useOverlays.ts b/apps/web/src/hooks/useOverlays.tsindex da90d705..f39445b5 100644--- a/apps/web/src/hooks/useOverlays.ts+++ b/apps/web/src/hooks/useOverlays.ts@@ -1,4 +1,4 @@-import { useEffect, useRef, useState } from 'react';+import { useEffect, useState } from 'react';import { usePathname } from 'next/navigation';import type { NewIssueDefaults } from '@/utils/project';@@ -7,20 +7,13 @@ import type { NewIssueDefaults } from '@/utils/project';// one object instead of four flags, and so the keyboard shortcut layer can ask// whether any overlay is open through `anyOpen`. Project settings are their own// pages, not an overlay.-// `showChatByDefault` is the account preference: it shows the floating chat button-// from the start, with the chat window collapsed.-export function useOverlays(showChatByDefault: boolean) {+export function useOverlays() {const [showNewProject, setShowNewProject] = useState(false);const [showCommand, setShowCommand] = useState(false);// Initial field values for a new issue (null = the new-issue modal is closed).const [newIssueDefaults, setNewIssueDefaults] = useState<NewIssueDefaults | null>(null);// Which issue the detail panel shows (null = the panel is closed).const [openIssueId, setOpenIssueId] = useState<number | null>(null);- // The floating AI chat. `chatEnabled` is the header toggle (shows the floating- // button); `chatOpen` is whether the chat window is expanded. Kept out of- // `anyOpen` so the chat does not suppress the keyboard shortcuts.- const [chatEnabled, setChatEnabled] = useState(false);- const [chatOpen, setChatOpen] = useState(false);// The panel is not addressed by the URL, so a link inside it navigates the page// behind it and leaves the panel standing over the new page.@@ -29,23 +22,6 @@ export function useOverlays(showChatByDefault: boolean) {setOpenIssueId(null);}, [pathname]);- // The preference arrives after the first render, so it is applied in an effect,- // and only once — a manual toggle afterwards stays as the user left it.- const defaultApplied = useRef(false);- useEffect(() => {- if (defaultApplied.current || !showChatByDefault) return;- defaultApplied.current = true;- setChatEnabled(true);- }, [showChatByDefault]);-- // Turning the chat on opens the window immediately; turning it off hides both- // the button and the window.- const toggleChat = () => {- const next = !chatEnabled;- setChatEnabled(next);- setChatOpen(next);- };-const anyOpen = showNewProject || showCommand || newIssueDefaults != null || openIssueId != null;return {@@ -57,10 +33,6 @@ export function useOverlays(showChatByDefault: boolean) {setNewIssueDefaults,openIssueId,setOpenIssueId,- chatEnabled,- chatOpen,- setChatOpen,- toggleChat,anyOpen,};}diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.tsindex bdcaac81..2716d5d2 100644--- a/apps/web/src/lib/api.ts+++ b/apps/web/src/lib/api.ts@@ -558,6 +558,11 @@ export interface AiChatMessage {stopped?: boolean;}+export interface AiChatThreadPage {+ items: AiChatThread[];+ nextPage: number | null;+}+export interface AiChatMessagePage {items: AiChatMessage[];nextPage: number | null;@@ -656,7 +661,11 @@ export async function* streamAiAgentChat();const chat = `/projects/${projectKey}/ai-agents/${agentId}/chat/${sent.messageId}`;const cancel = () => {- request(`${chat}/cancel`, { method: 'POST' }).catch(() => {});+ // A stop the API refused leaves the answer being produced. The stream this belongs+ // to is already gone, so the console is the only place left to report it.+ request(`${chat}/cancel`, { method: 'POST' }).catch((err) => {+ console.error('Could not stop the answer', err);+ });};if (signal?.aborted) cancel();else signal?.addEventListener('abort', cancel, { once: true });@@ -1193,7 +1202,7 @@ export interface TelegramLinkStart {// project the app root reopens (null until the user has opened one).export type ThemePreference = 'light' | 'dark' | 'system';export type IssueOpenMode = 'panel' | 'page';-export type StartPage = 'inbox' | 'dashboard' | 'work-items' | 'initiatives' | 'ai-chat';+export type StartPage = 'inbox' | 'dashboard' | 'work-items' | 'initiatives';export type IssueStatsView = 'compact' | 'timeline';export type IssueActivityView = 'flat' | 'grouped';@@ -2899,14 +2908,20 @@ export const api = {`/projects/${projectKey}/agent-schedules/${scheduleId}/runs${runId != null ? `/${runId}` : ''}/cancel`,{ method: 'POST' },),- // The caller's own chat threads with an agent, newest first.- listAiAgentThreads: (projectKey: string, agentId: number) =>- request<AiChatThread[]>(`/projects/${projectKey}/ai-agents/${agentId}/threads`),+ // One page of the caller's own chat threads with an agent, newest first.+ listAiAgentThreads: (projectKey: string, agentId: number, page: number) =>+ request<AiChatThreadPage>(`/projects/${projectKey}/ai-agents/${agentId}/threads?page=${page}`),// The transcript of one chat thread, to restore the conversation.getAiAgentThreadMessages: (projectKey: string, agentId: number, threadId: string, page: number) =>request<AiChatMessagePage>(`/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}/messages?page=${page}`,),+ // Renames one of the caller's chat threads.+ renameAiAgentThread: (projectKey: string, agentId: number, threadId: string, title: string) =>+ request<void>(+ `/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}`,+ { method: 'PATCH', body: JSON.stringify({ title }) },+ ),deleteAiAgentThread: (projectKey: string, agentId: number, threadId: string) =>request<void>(`/projects/${projectKey}/ai-agents/${agentId}/threads/${encodeURIComponent(threadId)}`,diff --git a/apps/web/src/services/aiAgents.service.ts b/apps/web/src/services/aiAgents.service.tsindex e894fe9b..055ee2d7 100644--- a/apps/web/src/services/aiAgents.service.ts+++ b/apps/web/src/services/aiAgents.service.ts@@ -1,10 +1,16 @@// An agent is also an assignee, so writes here invalidate the project detail as// well, keeping the assignee picker in sync.-import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';+import {+ useInfiniteQuery,+ useMutation,+ useQuery,+ useQueryClient,+ type InfiniteData,+} from '@tanstack/react-query';import { toast } from 'sonner';import { useTranslations } from 'next-intl';-import { api } from '@/lib/api';+import { api, type AiChatThreadPage } from '@/lib/api';import { qk } from '@/services/queryKeys';import { useInvalidateProject } from '@/services/projects.service';@@ -34,16 +40,25 @@ export function useAgentRuns(projectKey: string | null, agentId: number | null)});}-// The caller's chat threads with one agent (the AI Chat history rail), newest-// first. Only fetched when an agent is selected.+// The caller's chat threads with one agent (the chat history), newest first and a+// page at a time. Only fetched when an agent is selected.export function useAgentThreadsQuery(projectKey: string | null, agentId: number | null) {- return useQuery({+ return useInfiniteQuery({queryKey: qk.agentThreads(projectKey ?? '', agentId ?? 0),- queryFn: () => api.listAiAgentThreads(projectKey!, agentId!),+ queryFn: ({ pageParam }) => api.listAiAgentThreads(projectKey!, agentId!, pageParam),+ initialPageParam: 0,+ getNextPageParam: (last) => last.nextPage ?? undefined,enabled: projectKey != null && agentId != null,});}+// The threads loaded so far, as one list. The pages the history has not reached are+// simply not in it: a tab of an older conversation falls back to its default title.+export function useLoadedAgentThreads(projectKey: string | null, agentId: number | null) {+ const query = useAgentThreadsQuery(projectKey, agentId);+ return query.data?.pages.flatMap((page) => page.items) ?? [];+}+// The transcript of one chat thread, to restore the conversation when a thread is// opened. Only fetched when a thread is selected.export function useAgentThreadMessagesQuery(@@ -61,6 +76,32 @@ export function useAgentThreadMessagesQuery(});}+// Renames one of the caller's chat threads. The new title is put into the loaded+// history right away: it is what the tab of that conversation is called.+export function useRenameAgentThread(projectKey: string | null, agentId: number | null) {+ const qc = useQueryClient();+ return useMutation({+ mutationFn: ({ threadId, title }: { threadId: string; title: string }) =>+ api.renameAiAgentThread(projectKey!, agentId!, threadId, title),+ onSuccess: (_res, { threadId, title }) => {+ if (!projectKey || agentId == null) return;+ qc.setQueryData<InfiniteData<AiChatThreadPage>>(+ qk.agentThreads(projectKey, agentId),+ (prev) =>+ prev && {+ ...prev,+ pages: prev.pages.map((page) => ({+ ...page,+ items: page.items.map((thread) =>+ thread.id === threadId ? { ...thread, title } : thread,+ ),+ })),+ },+ );+ },+ });+}+// Deletes one of the caller's chat threads with an agent and refreshes the history// list it was in.export function useDeleteAgentThread(projectKey: string | null, agentId: number | null) {diff --git a/apps/web/src/utils/hotkeys.ts b/apps/web/src/utils/hotkeys.tsindex cefba6f0..59b8eb53 100644--- a/apps/web/src/utils/hotkeys.ts+++ b/apps/web/src/utils/hotkeys.ts@@ -18,6 +18,7 @@ export type HotkeyId =| 'issue.new'| 'project.new'| 'project.settings'+ | 'chat.toggle'| 'board.select-all';// The heading a shortcut is listed under in the editor. The name of a group, and@@ -75,6 +76,7 @@ export const HOTKEYS: HotkeyDef[] = [combo: 's',scope: 'app',},+ { id: 'chat.toggle', group: 'general', combo: 'c', scope: 'app' },{ id: 'view.kanban', group: 'workItems', combo: '1', scope: 'app' },{ id: 'view.table', group: 'workItems', combo: '2', scope: 'app' },{ id: 'view.timeline', group: 'workItems', combo: '3', scope: 'app' },diff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.tsindex bfb5975d..db49ce48 100644--- a/apps/web/src/utils/paths.ts+++ b/apps/web/src/utils/paths.ts@@ -28,13 +28,10 @@ export const notePath = (key: string, boardId: number) => `${notesPath(key)}/${bexport const settingsPath = (key: string, section: string) =>`${projectPath(key)}/settings/${section}`;-// The AI Team destinations: the chat and the sections listed next to it in the-// main sidebar (see AI_TEAM_SECTIONS).+// The AI Team destinations listed in the main sidebar (see AI_TEAM_SECTIONS).export const aiTeamPath = (key: string, section: string) =>`${projectPath(key)}/ai-team/${section}`;-export const aiChatPath = (key: string) => aiTeamPath(key, 'chat');-export const inboxPath = (key: string) => `${projectPath(key)}/inbox`;// The member's own notification preferences (which events, by which channel, their@@ -130,8 +127,6 @@ export const startPagePath = (key: string, startPage: StartPage) => {return dashboardsPath(key);case 'initiatives':return initiativesPath(key);- case 'ai-chat':- return aiChatPath(key);default:return projectPath(key);}diff --git a/apps/web/src/utils/settingsSections.ts b/apps/web/src/utils/settingsSections.tsindex 954d605a..6d2f91ae 100644--- a/apps/web/src/utils/settingsSections.ts+++ b/apps/web/src/utils/settingsSections.ts@@ -21,7 +21,7 @@ import type { PermissionResource } from '@/lib/api';// The sidebar group a section is listed under: the project-level general// settings, workflow configuration, automation/integrations, or the AI section// (agents, providers, skills). 'ai-team' and 'ai' sections are listed in the main-// sidebar's AI Team group — 'ai-team' next to the chat, 'ai' inside the+// sidebar's AI Team group — 'ai-team' at its top level, 'ai' inside the// "Configure" item — not in the project settings sidebar.export type SettingsGroup = 'general' | 'configuration' | 'automation' | 'ai' | 'ai-team';diff --git a/packages/db/drizzle/0097_powerful_pandemic.sql b/packages/db/drizzle/0097_powerful_pandemic.sqlnew file mode 100644index 00000000..4ec4dcfb--- /dev/null+++ b/packages/db/drizzle/0097_powerful_pandemic.sql@@ -0,0 +1,3 @@+ALTER TABLE "user_preference" DROP CONSTRAINT "user_preference_start_page_check";--> statement-breakpoint+UPDATE "user_preference" SET "start_page" = 'work-items' WHERE "start_page" = 'ai-chat';--> statement-breakpoint+ALTER TABLE "user_preference" ADD CONSTRAINT "user_preference_start_page_check" CHECK ("user_preference"."start_page" IN ('inbox', 'dashboard', 'work-items', 'initiatives'));\ No newline at end of filediff --git a/packages/db/drizzle/meta/0097_snapshot.json b/packages/db/drizzle/meta/0097_snapshot.jsonnew file mode 100644index 00000000..fb0aa44d--- /dev/null+++ b/packages/db/drizzle/meta/0097_snapshot.json@@ -0,0 +1,6733 @@+{+ "id": "ab7dabfc-a65a-4b2d-bde5-1699eb95790b",+ "prevId": "44fa27aa-ce98-4658-9268-952450e870c4",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.account": {+ "name": "account",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.apikey": {+ "name": "apikey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "config_id": {+ "name": "config_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start": {+ "name": "start",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prefix": {+ "name": "prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refill_interval": {+ "name": "refill_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "refill_amount": {+ "name": "refill_amount",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_refill_at": {+ "name": "last_refill_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_enabled": {+ "name": "rate_limit_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_time_window": {+ "name": "rate_limit_time_window",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 1000+ },+ "rate_limit_max": {+ "name": "rate_limit_max",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 100+ },+ "request_count": {+ "name": "request_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "remaining": {+ "name": "remaining",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_request": {+ "name": "last_request",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "permissions": {+ "name": "permissions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "apikey_configId_idx": {+ "name": "apikey_configId_idx",+ "columns": [+ {+ "expression": "config_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_referenceId_idx": {+ "name": "apikey_referenceId_idx",+ "columns": [+ {+ "expression": "reference_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_key_idx": {+ "name": "apikey_key_idx",+ "columns": [+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.passkey": {+ "name": "passkey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "device_type": {+ "name": "device_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "backed_up": {+ "name": "backed_up",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "aaguid": {+ "name": "aaguid",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "passkey_userId_idx": {+ "name": "passkey_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "passkey_credentialID_idx": {+ "name": "passkey_credentialID_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "passkey_user_id_user_id_fk": {+ "name": "passkey_user_id_user_id_fk",+ "tableFrom": "passkey",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session": {+ "name": "session",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "session_userId_idx": {+ "name": "session_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "session_token_unique": {+ "name": "session_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_username": {+ "name": "display_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'user'"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_email_unique": {+ "name": "user_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "email"+ ]+ },+ "user_username_unique": {+ "name": "user_username_unique",+ "nullsNotDistinct": false,+ "columns": [+ "username"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verification": {+ "name": "verification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verification_identifier_idx": {+ "name": "verification_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_event": {+ "name": "agent_chat_event",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigserial",+ "primaryKey": true,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_event_message_idx": {+ "name": "agent_chat_event_message_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_event_message_id_agent_chat_message_id_fk": {+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",+ "tableFrom": "agent_chat_event",+ "tableTo": "agent_chat_message",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_message": {+ "name": "agent_chat_message",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_message_thread_idx": {+ "name": "agent_chat_message_thread_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_chat_message_due_idx": {+ "name": "agent_chat_message_due_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "agent_chat_thread",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_message_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_chat_message_role_check": {+ "name": "agent_chat_message_role_check",+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"+ },+ "agent_chat_message_status_check": {+ "name": "agent_chat_message_status_check",+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_chat_thread": {+ "name": "agent_chat_thread",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cli_session_id": {+ "name": "cli_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_thread_agent_user_idx": {+ "name": "agent_chat_thread_agent_user_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_thread_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_thread_user_id_user_id_fk": {+ "name": "agent_chat_thread_user_id_user_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_field_trigger": {+ "name": "agent_field_trigger",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "delay_sec": {+ "name": "delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ }+ },+ "indexes": {+ "agent_field_trigger_field_idx": {+ "name": "agent_field_trigger_field_idx",+ "columns": [+ {+ "expression": "field_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_field_trigger_agent_id_ai_agent_id_fk": {+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_field_trigger_field_id_custom_field_id_fk": {+ "name": "agent_field_trigger_field_id_custom_field_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_field_trigger_agent_id_field_id_pk": {+ "name": "agent_field_trigger_agent_id_field_id_pk",+ "columns": [+ "agent_id",+ "field_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_field_trigger_delay_check": {+ "name": "agent_field_trigger_delay_check",+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_run": {+ "name": "agent_run",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_id": {+ "name": "schedule_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'delegation'"+ },+ "scheduled_for": {+ "name": "scheduled_for",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "output": {+ "name": "output",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_run_schedule_fire_uq": {+ "name": "agent_run_schedule_fire_uq",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scheduled_for",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_due_idx": {+ "name": "agent_run_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_schedule_idx": {+ "name": "agent_run_schedule_idx",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_run_agent_id_ai_agent_id_fk": {+ "name": "agent_run_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_issue_id_issue_id_fk": {+ "name": "agent_run_issue_id_issue_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_schedule_id_agent_schedule_id_fk": {+ "name": "agent_run_schedule_id_agent_schedule_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "agent_schedule",+ "columnsFrom": [+ "schedule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_source_activity_id_issue_activity_id_fk": {+ "name": "agent_run_source_activity_id_issue_activity_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_run_status_check": {+ "name": "agent_run_status_check",+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"+ },+ "agent_run_trigger_check": {+ "name": "agent_run_trigger_check",+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_schedule": {+ "name": "agent_schedule",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "cron": {+ "name": "cron",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_schedule_due_idx": {+ "name": "agent_schedule_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_agent_idx": {+ "name": "agent_schedule_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_schedule_agent_id_ai_agent_id_fk": {+ "name": "agent_schedule_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_schedule_agent_id_name_unique": {+ "name": "agent_schedule_agent_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "agent_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_schedule_status_check": {+ "name": "agent_schedule_status_check",+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill": {+ "name": "agent_skill",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_url": {+ "name": "source_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_prefix": {+ "name": "s3_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "files": {+ "name": "files",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_skill_project_idx": {+ "name": "agent_skill_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_project_id_project_id_fk": {+ "name": "agent_skill_project_id_project_id_fk",+ "tableFrom": "agent_skill",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_skill_project_id_name_unique": {+ "name": "agent_skill_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_skill_source_check": {+ "name": "agent_skill_source_check",+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill_link": {+ "name": "agent_skill_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "skill_id": {+ "name": "skill_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_skill_link_skill_idx": {+ "name": "agent_skill_link_skill_idx",+ "columns": [+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_link_agent_id_ai_agent_id_fk": {+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_skill_link_skill_id_agent_skill_id_fk": {+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "agent_skill",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_skill_link_agent_id_skill_id_pk": {+ "name": "agent_skill_link_agent_id_skill_id_pk",+ "columns": [+ "agent_id",+ "skill_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool": {+ "name": "agent_tool",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "tool_key": {+ "name": "tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_tool_project_idx": {+ "name": "agent_tool_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_tool_credential_idx": {+ "name": "agent_tool_credential_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_project_id_project_id_fk": {+ "name": "agent_tool_project_id_project_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_credential_id_integration_credential_id_fk": {+ "name": "agent_tool_credential_id_integration_credential_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_tool_project_id_tool_key_credential_id_unique": {+ "name": "agent_tool_project_id_tool_key_credential_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "tool_key",+ "credential_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool_link": {+ "name": "agent_tool_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "agent_tool_id": {+ "name": "agent_tool_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_tool_link_tool_idx": {+ "name": "agent_tool_link_tool_idx",+ "columns": [+ {+ "expression": "agent_tool_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_link_agent_id_ai_agent_id_fk": {+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "agent_tool",+ "columnsFrom": [+ "agent_tool_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_tool_link_agent_id_agent_tool_id_pk": {+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",+ "columns": [+ "agent_id",+ "agent_tool_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_agent": {+ "name": "ai_agent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model_credential_id": {+ "name": "model_credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "instructions": {+ "name": "instructions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "temperature": {+ "name": "temperature",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "max_steps": {+ "name": "max_steps",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_on_mention": {+ "name": "trigger_on_mention",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "trigger_on_assign": {+ "name": "trigger_on_assign",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "delegation_delay_sec": {+ "name": "delegation_delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_ciphertext": {+ "name": "api_key_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_iv": {+ "name": "api_key_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_auth_tag": {+ "name": "api_key_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_enabled": {+ "name": "memory_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "memory_last_messages": {+ "name": "memory_last_messages",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runner_scope": {+ "name": "runner_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'project'"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_agent_project_username_uq": {+ "name": "ai_agent_project_username_uq",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(\"username\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_agent_project_idx": {+ "name": "ai_agent_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_agent_project_id_project_id_fk": {+ "name": "ai_agent_project_id_project_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_user_id_user_id_fk": {+ "name": "ai_agent_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_model_credential_id_integration_credential_id_fk": {+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "model_credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "ai_agent_role_id_project_role_id_fk": {+ "name": "ai_agent_role_id_project_role_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "project_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "ai_agent_owner_user_id_user_id_fk": {+ "name": "ai_agent_owner_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "ai_agent_user_id_unique": {+ "name": "ai_agent_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "ai_agent_kind_check": {+ "name": "ai_agent_kind_check",+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"+ },+ "ai_agent_runner_scope_check": {+ "name": "ai_agent_runner_scope_check",+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'project')"+ },+ "ai_agent_delegation_delay_check": {+ "name": "ai_agent_delegation_delay_check",+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.app_secret": {+ "name": "app_secret",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.app_setting": {+ "name": "app_setting",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.custom_field": {+ "name": "custom_field",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_type_id": {+ "name": "issue_type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "field_type": {+ "name": "field_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "member_scope": {+ "name": "member_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "show_in_body": {+ "name": "show_in_body",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_project_id_project_id_fk": {+ "name": "custom_field_project_id_project_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "custom_field_issue_type_id_issue_type_id_fk": {+ "name": "custom_field_issue_type_id_issue_type_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "issue_type",+ "columnsFrom": [+ "issue_type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "custom_field_field_type_check": {+ "name": "custom_field_field_type_check",+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"+ },+ "custom_field_member_scope_check": {+ "name": "custom_field_member_scope_check",+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"+ }+ },+ "isRLSEnabled": false+ },+ "public.custom_field_option": {+ "name": "custom_field_option",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_option_field_id_custom_field_id_fk": {+ "name": "custom_field_option_field_id_custom_field_id_fk",+ "tableFrom": "custom_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "custom_field_option_field_id_value_unique": {+ "name": "custom_field_option_field_id_value_unique",+ "nullsNotDistinct": false,+ "columns": [+ "field_id",+ "value"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cycle": {+ "name": "cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "goal": {+ "name": "goal",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "end_date": {+ "name": "end_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cycle_project_idx": {+ "name": "cycle_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "start_date",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cycle_project_id_project_id_fk": {+ "name": "cycle_project_id_project_id_fk",+ "tableFrom": "cycle",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "cycle_dates_check": {+ "name": "cycle_dates_check",+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative": {+ "name": "initiative",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planned'"+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "target_date": {+ "name": "target_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_project_idx": {+ "name": "initiative_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_project_id_project_id_fk": {+ "name": "initiative_project_id_project_id_fk",+ "tableFrom": "initiative",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_owner_user_id_user_id_fk": {+ "name": "initiative_owner_user_id_user_id_fk",+ "tableFrom": "initiative",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "initiative_status_check": {+ "name": "initiative_status_check",+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative_label": {+ "name": "initiative_label",+ "schema": "",+ "columns": {+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "initiative_label_initiative_id_initiative_id_fk": {+ "name": "initiative_label_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_label_label_id_label_id_fk": {+ "name": "initiative_label_label_id_label_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "initiative_label_initiative_id_label_id_pk": {+ "name": "initiative_label_initiative_id_label_id_pk",+ "columns": [+ "initiative_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.integration_credential": {+ "name": "integration_credential",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "integration_key": {+ "name": "integration_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "integration_credential_project_idx": {+ "name": "integration_credential_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "integration_credential_project_id_project_id_fk": {+ "name": "integration_credential_project_id_project_id_fk",+ "tableFrom": "integration_credential",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue": {+ "name": "issue",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sequence_number": {+ "name": "sequence_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delegate_user_id": {+ "name": "delegate_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "due_date": {+ "name": "due_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_project_active_idx": {+ "name": "issue_project_active_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"archived_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_parent_idx": {+ "name": "issue_parent_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"parent_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_idx": {+ "name": "issue_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"cycle_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_project_id_project_id_fk": {+ "name": "issue_project_id_project_id_fk",+ "tableFrom": "issue",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_type_id_issue_type_id_fk": {+ "name": "issue_type_id_issue_type_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_initiative_id_initiative_id_fk": {+ "name": "issue_initiative_id_initiative_id_fk",+ "tableFrom": "issue",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_id_cycle_id_fk",+ "tableFrom": "issue",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_column_id_project_column_id_fk": {+ "name": "issue_column_id_project_column_id_fk",+ "tableFrom": "issue",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_parent_id_issue_id_fk": {+ "name": "issue_parent_id_issue_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_assignee_user_id_user_id_fk": {+ "name": "issue_assignee_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_delegate_user_id_user_id_fk": {+ "name": "issue_delegate_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "delegate_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_share_token_unique": {+ "name": "issue_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ },+ "issue_project_id_sequence_number_unique": {+ "name": "issue_project_id_sequence_number_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "sequence_number"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_activity": {+ "name": "issue_activity",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reply_to_id": {+ "name": "reply_to_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "subject": {+ "name": "subject",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "from_text": {+ "name": "from_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "to_text": {+ "name": "to_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_activity_issue_idx": {+ "name": "issue_activity_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_reply_idx": {+ "name": "issue_activity_reply_idx",+ "columns": [+ {+ "expression": "reply_to_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_initiative_idx": {+ "name": "issue_activity_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_activity_issue_id_issue_id_fk": {+ "name": "issue_activity_issue_id_issue_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_initiative_id_initiative_id_fk": {+ "name": "issue_activity_initiative_id_initiative_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_reply_to_id_issue_activity_id_fk": {+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "reply_to_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_actor_user_id_user_id_fk": {+ "name": "issue_activity_actor_user_id_user_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_activity_kind_check": {+ "name": "issue_activity_kind_check",+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"+ },+ "issue_activity_owner_check": {+ "name": "issue_activity_owner_check",+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_attachment": {+ "name": "issue_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_attachment_issue_idx": {+ "name": "issue_attachment_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_attachment_issue_id_issue_id_fk": {+ "name": "issue_attachment_issue_id_issue_id_fk",+ "tableFrom": "issue_attachment",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_attachment_public_id_unique": {+ "name": "issue_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist": {+ "name": "issue_checklist",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_issue_idx": {+ "name": "issue_checklist_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_issue_id_issue_id_fk": {+ "name": "issue_checklist_issue_id_issue_id_fk",+ "tableFrom": "issue_checklist",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist_item": {+ "name": "issue_checklist_item",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "checklist_id": {+ "name": "checklist_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "done": {+ "name": "done",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_item_checklist_idx": {+ "name": "issue_checklist_item_checklist_idx",+ "columns": [+ {+ "expression": "checklist_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",+ "tableFrom": "issue_checklist_item",+ "tableTo": "issue_checklist",+ "columnsFrom": [+ "checklist_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_option": {+ "name": "issue_field_option",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "option_id": {+ "name": "option_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_option_issue_id_issue_id_fk": {+ "name": "issue_field_option_issue_id_issue_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_field_id_custom_field_id_fk": {+ "name": "issue_field_option_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_option_id_custom_field_option_id_fk": {+ "name": "issue_field_option_option_id_custom_field_option_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field_option",+ "columnsFrom": [+ "option_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_field_option_issue_id_field_id_option_id_pk": {+ "name": "issue_field_option_issue_id_field_id_option_id_pk",+ "columns": [+ "issue_id",+ "field_id",+ "option_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_value": {+ "name": "issue_field_value",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value_text": {+ "name": "value_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "value_number": {+ "name": "value_number",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "value_bool": {+ "name": "value_bool",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "value_date": {+ "name": "value_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime": {+ "name": "value_datetime",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime_end": {+ "name": "value_datetime_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_user_id": {+ "name": "value_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_value_issue_id_issue_id_fk": {+ "name": "issue_field_value_issue_id_issue_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_field_id_custom_field_id_fk": {+ "name": "issue_field_value_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_value_user_id_user_id_fk": {+ "name": "issue_field_value_value_user_id_user_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "user",+ "columnsFrom": [+ "value_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_field_value_issue_id_field_id_unique": {+ "name": "issue_field_value_issue_id_field_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "field_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_label": {+ "name": "issue_label",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_label_issue_id_issue_id_fk": {+ "name": "issue_label_issue_id_issue_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_label_label_id_label_id_fk": {+ "name": "issue_label_label_id_label_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_label_issue_id_label_id_pk": {+ "name": "issue_label_issue_id_label_id_pk",+ "columns": [+ "issue_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_link": {+ "name": "issue_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "target_issue_id": {+ "name": "target_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_link_pair_kind_idx": {+ "name": "issue_link_pair_kind_idx",+ "columns": [+ {+ "expression": "least(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_source_idx": {+ "name": "issue_link_source_idx",+ "columns": [+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_target_idx": {+ "name": "issue_link_target_idx",+ "columns": [+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_link_source_issue_id_issue_id_fk": {+ "name": "issue_link_source_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_link_target_issue_id_issue_id_fk": {+ "name": "issue_link_target_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "target_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_link_kind_check": {+ "name": "issue_link_kind_check",+ "value": "\"issue_link\".\"kind\" IN ('blocks', 'relates', 'duplicates')"+ },+ "issue_link_self_check": {+ "name": "issue_link_self_check",+ "value": "\"issue_link\".\"source_issue_id\" <> \"issue_link\".\"target_issue_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_type": {+ "name": "issue_type",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_type_project_id_project_id_fk": {+ "name": "issue_type_project_id_project_id_fk",+ "tableFrom": "issue_type",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_type_project_id_name_unique": {+ "name": "issue_type_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_watcher": {+ "name": "issue_watcher",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subscribed": {+ "name": "subscribed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_watcher_issue_id_issue_id_fk": {+ "name": "issue_watcher_issue_id_issue_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_watcher_user_id_user_id_fk": {+ "name": "issue_watcher_user_id_user_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_watcher_issue_id_user_id_pk": {+ "name": "issue_watcher_issue_id_user_id_pk",+ "columns": [+ "issue_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.label": {+ "name": "label",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_project_id_project_id_fk": {+ "name": "label_project_id_project_id_fk",+ "tableFrom": "label",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "label_group_id_label_group_id_fk": {+ "name": "label_group_id_label_group_id_fk",+ "tableFrom": "label",+ "tableTo": "label_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_project_id_name_unique": {+ "name": "label_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.label_group": {+ "name": "label_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_group_project_id_project_id_fk": {+ "name": "label_group_project_id_project_id_fk",+ "tableFrom": "label_group",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_group_project_id_name_unique": {+ "name": "label_group_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.note_board": {+ "name": "note_board",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "canvas": {+ "name": "canvas",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "note_board_project_idx": {+ "name": "note_board_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_project_id_project_id_fk": {+ "name": "note_board_project_id_project_id_fk",+ "tableFrom": "note_board",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_owner_user_id_user_id_fk": {+ "name": "note_board_owner_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_created_by_user_id_user_id_fk": {+ "name": "note_board_created_by_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.note_board_member": {+ "name": "note_board_member",+ "schema": "",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "note_board_member_user_idx": {+ "name": "note_board_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_member_board_id_note_board_id_fk": {+ "name": "note_board_member_board_id_note_board_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "note_board",+ "columnsFrom": [+ "board_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_member_user_id_user_id_fk": {+ "name": "note_board_member_user_id_user_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "note_board_member_board_id_user_id_pk": {+ "name": "note_board_member_board_id_user_id_pk",+ "columns": [+ "board_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notification": {+ "name": "notification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "read_at": {+ "name": "read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_user_idx": {+ "name": "notification_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_user_unread_idx": {+ "name": "notification_user_unread_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"read_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_user_id_user_id_fk": {+ "name": "notification_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_project_id_project_id_fk": {+ "name": "notification_project_id_project_id_fk",+ "tableFrom": "notification",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_issue_id_issue_id_fk": {+ "name": "notification_issue_id_issue_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_source_activity_id_issue_activity_id_fk": {+ "name": "notification_source_activity_id_issue_activity_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "notification_actor_user_id_user_id_fk": {+ "name": "notification_actor_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_type_check": {+ "name": "notification_type_check",+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.notification_delivery": {+ "name": "notification_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "channel": {+ "name": "channel",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "recipient": {+ "name": "recipient",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_delivery_due_idx": {+ "name": "notification_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_delivery_project_id_project_id_fk": {+ "name": "notification_delivery_project_id_project_id_fk",+ "tableFrom": "notification_delivery",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_delivery_channel_check": {+ "name": "notification_delivery_channel_check",+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project": {+ "name": "project",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "next_sequence": {+ "name": "next_sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "initiatives_enabled": {+ "name": "initiatives_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "dashboards_enabled": {+ "name": "dashboards_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "notes_enabled": {+ "name": "notes_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "cycles_enabled": {+ "name": "cycles_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "subtasks_enabled": {+ "name": "subtasks_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "checklists_enabled": {+ "name": "checklists_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_enabled": {+ "name": "issue_stats_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_key_unique": {+ "name": "project_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_action": {+ "name": "project_action",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "condition": {+ "name": "condition",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "effect": {+ "name": "effect",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_action_project_idx": {+ "name": "project_action_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_action_project_id_project_id_fk": {+ "name": "project_action_project_id_project_id_fk",+ "tableFrom": "project_action",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_column": {+ "name": "project_column",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unstarted'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "wip_limit": {+ "name": "wip_limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "wip_mode": {+ "name": "wip_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'soft'"+ },+ "auto_assign_user_id": {+ "name": "auto_assign_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_column_project_id_project_id_fk": {+ "name": "project_column_project_id_project_id_fk",+ "tableFrom": "project_column",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_column_auto_assign_user_id_user_id_fk": {+ "name": "project_column_auto_assign_user_id_user_id_fk",+ "tableFrom": "project_column",+ "tableTo": "user",+ "columnsFrom": [+ "auto_assign_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_column_project_id_position_unique": {+ "name": "project_column_project_id_position_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "position"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_column_state_type_check": {+ "name": "project_column_state_type_check",+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"+ },+ "project_column_wip_mode_check": {+ "name": "project_column_wip_mode_check",+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"+ },+ "project_column_wip_limit_check": {+ "name": "project_column_wip_limit_check",+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_dashboard": {+ "name": "project_dashboard",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layout": {+ "name": "layout",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_dashboard_project_idx": {+ "name": "project_dashboard_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_dashboard_project_id_project_id_fk": {+ "name": "project_dashboard_project_id_project_id_fk",+ "tableFrom": "project_dashboard",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_invite": {+ "name": "project_invite",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "invited_by_user_id": {+ "name": "invited_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accepted_by_user_id": {+ "name": "accepted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "responded_at": {+ "name": "responded_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "project_invite_pending_uq": {+ "name": "project_invite_pending_uq",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"project_invite\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_invite_project_idx": {+ "name": "project_invite_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_invite_project_id_project_id_fk": {+ "name": "project_invite_project_id_project_id_fk",+ "tableFrom": "project_invite",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_invite_role_id_project_role_id_fk": {+ "name": "project_invite_role_id_project_role_id_fk",+ "tableFrom": "project_invite",+ "tableTo": "project_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_invite_invited_by_user_id_user_id_fk": {+ "name": "project_invite_invited_by_user_id_user_id_fk",+ "tableFrom": "project_invite",+ "tableTo": "user",+ "columnsFrom": [+ "invited_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_invite_accepted_by_user_id_user_id_fk": {+ "name": "project_invite_accepted_by_user_id_user_id_fk",+ "tableFrom": "project_invite",+ "tableTo": "user",+ "columnsFrom": [+ "accepted_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_invite_token_unique": {+ "name": "project_invite_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_invite_role_check": {+ "name": "project_invite_role_check",+ "value": "\"project_invite\".\"role\" IN ('owner', 'member')"+ },+ "project_invite_status_check": {+ "name": "project_invite_status_check",+ "value": "\"project_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_member": {+ "name": "project_member",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_member_user_idx": {+ "name": "project_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_member_project_id_project_id_fk": {+ "name": "project_member_project_id_project_id_fk",+ "tableFrom": "project_member",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_user_id_user_id_fk": {+ "name": "project_member_user_id_user_id_fk",+ "tableFrom": "project_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_role_id_project_role_id_fk": {+ "name": "project_member_role_id_project_role_id_fk",+ "tableFrom": "project_member",+ "tableTo": "project_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_member_project_id_user_id_pk": {+ "name": "project_member_project_id_user_id_pk",+ "columns": [+ "project_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_member_role_check": {+ "name": "project_member_role_check",+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_notification_setting": {+ "name": "project_notification_setting",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_notification_setting_project_id_project_id_fk": {+ "name": "project_notification_setting_project_id_project_id_fk",+ "tableFrom": "project_notification_setting",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_role": {+ "name": "project_role",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "permissions": {+ "name": "permissions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_role_default_uq": {+ "name": "project_role_default_uq",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"project_role\".\"is_default\"",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_role_project_idx": {+ "name": "project_role_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_role_project_id_project_id_fk": {+ "name": "project_role_project_id_project_id_fk",+ "tableFrom": "project_role",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_role_project_id_name_unique": {+ "name": "project_role_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_setting": {+ "name": "project_setting",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_setting_project_id_project_id_fk": {+ "name": "project_setting_project_id_project_id_fk",+ "tableFrom": "project_setting",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_setting_project_id_key_pk": {+ "name": "project_setting_project_id_key_pk",+ "columns": [+ "project_id",+ "key"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view": {+ "name": "project_view",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "filters": {+ "name": "filters",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "display": {+ "name": "display",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_view_project_idx": {+ "name": "project_view_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_view_project_id_project_id_fk": {+ "name": "project_view_project_id_project_id_fk",+ "tableFrom": "project_view",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_view_share_token_unique": {+ "name": "project_view_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view_favorite": {+ "name": "project_view_favorite",+ "schema": "",+ "columns": {+ "view_id": {+ "name": "view_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_view_favorite_view_id_project_view_id_fk": {+ "name": "project_view_favorite_view_id_project_view_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "project_view",+ "columnsFrom": [+ "view_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_favorite_user_id_user_id_fk": {+ "name": "project_view_favorite_user_id_user_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_view_favorite_view_id_user_id_pk": {+ "name": "project_view_favorite_view_id_user_id_pk",+ "columns": [+ "view_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.revision": {+ "name": "revision",+ "schema": "",+ "columns": {+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "rev": {+ "name": "rev",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {+ "revision_project_idx": {+ "name": "revision_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_notification_preference": {+ "name": "user_notification_preference",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "email_events": {+ "name": "email_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "telegram_events": {+ "name": "telegram_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_notification_preference_user_id_user_id_fk": {+ "name": "user_notification_preference_user_id_user_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_notification_preference_project_id_project_id_fk": {+ "name": "user_notification_preference_project_id_project_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_notification_pref_user_project_unique": {+ "name": "user_notification_pref_user_project_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_preference": {+ "name": "user_preference",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'UTC'"+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'en'"+ },+ "theme": {+ "name": "theme",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "issue_open_mode": {+ "name": "issue_open_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'panel'"+ },+ "start_page": {+ "name": "start_page",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'work-items'"+ },+ "show_chat_by_default": {+ "name": "show_chat_by_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "issue_stats_open": {+ "name": "issue_stats_open",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_view": {+ "name": "issue_stats_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compact'"+ },+ "issue_activity_view": {+ "name": "issue_activity_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'flat'"+ },+ "auto_watch": {+ "name": "auto_watch",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "hotkeys": {+ "name": "hotkeys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_project_id": {+ "name": "last_project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_preference_user_id_user_id_fk": {+ "name": "user_preference_user_id_user_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_preference_last_project_id_project_id_fk": {+ "name": "user_preference_last_project_id_project_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "project",+ "columnsFrom": [+ "last_project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "user_preference_theme_check": {+ "name": "user_preference_theme_check",+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"+ },+ "user_preference_issue_open_mode_check": {+ "name": "user_preference_issue_open_mode_check",+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"+ },+ "user_preference_start_page_check": {+ "name": "user_preference_start_page_check",+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"+ },+ "user_preference_issue_stats_view_check": {+ "name": "user_preference_issue_stats_view_check",+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"+ },+ "user_preference_issue_activity_view_check": {+ "name": "user_preference_issue_activity_view_check",+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"+ }+ },+ "isRLSEnabled": false+ },+ "public.user_telegram_account": {+ "name": "user_telegram_account",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "chat_id": {+ "name": "chat_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code": {+ "name": "link_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code_expires_at": {+ "name": "link_code_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "linked_at": {+ "name": "linked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_telegram_account_chat_id_unique": {+ "name": "user_telegram_account_chat_id_unique",+ "columns": [+ {+ "expression": "chat_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_telegram_account_link_code_unique": {+ "name": "user_telegram_account_link_code_unique",+ "columns": [+ {+ "expression": "link_code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_telegram_account_user_id_user_id_fk": {+ "name": "user_telegram_account_user_id_user_id_fk",+ "tableFrom": "user_telegram_account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook": {+ "name": "webhook",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "events": {+ "name": "events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "consecutive_failures": {+ "name": "consecutive_failures",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_project_idx": {+ "name": "webhook_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_project_id_project_id_fk": {+ "name": "webhook_project_id_project_id_fk",+ "tableFrom": "webhook",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook_delivery": {+ "name": "webhook_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "event_id": {+ "name": "event_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "response_status": {+ "name": "response_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "response_body": {+ "name": "response_body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_delivery_due_idx": {+ "name": "webhook_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"webhook_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "webhook_delivery_webhook_idx": {+ "name": "webhook_delivery_webhook_idx",+ "columns": [+ {+ "expression": "webhook_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_delivery_webhook_id_webhook_id_fk": {+ "name": "webhook_delivery_webhook_id_webhook_id_fk",+ "tableFrom": "webhook_delivery",+ "tableTo": "webhook",+ "columnsFrom": [+ "webhook_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.jsonindex 3f5aab75..abbbfcd1 100644--- a/packages/db/drizzle/meta/_journal.json+++ b/packages/db/drizzle/meta/_journal.json@@ -680,6 +680,13 @@"when": 1787485270149,"tag": "0096_wooden_dazzler","breakpoints": true+ },+ {+ "idx": 97,+ "version": "7",+ "when": 1787513820293,+ "tag": "0097_powerful_pandemic",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/schema/app.ts b/packages/db/src/schema/app.tsindex f766636f..821d5615 100644--- a/packages/db/src/schema/app.ts+++ b/packages/db/src/schema/app.ts@@ -144,7 +144,7 @@ export const userPreference = pgTable(check('user_preference_issue_open_mode_check', sql`${t.issueOpenMode} IN ('panel', 'page')`),check('user_preference_start_page_check',- sql`${t.startPage} IN ('inbox', 'dashboard', 'work-items', 'initiatives', 'ai-chat')`,+ sql`${t.startPage} IN ('inbox', 'dashboard', 'work-items', 'initiatives')`,),check('user_preference_issue_stats_view_check',