diff --git a/apps/desktop/go.sum b/apps/desktop/go.sum index 0c39c56..a205b47 100644 --- a/apps/desktop/go.sum +++ b/apps/desktop/go.sum @@ -16,8 +16,6 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= -github.com/labstack/echo/v4 v4.16.1 h1:h05NuF1GvNu6jSAZxOv++AdjD/NJK+mZdGy0thiiuns= -github.com/labstack/echo/v4 v4.16.1/go.mod h1:V/EQaTVHYJH92QhbQe7kFQ4mjgcjxLQQUQtAN87zZdw= github.com/labstack/echo/v4 v4.16.3 h1:wAzM49wiBxHpZJQ621lminvdxbwfd1Cn6KwRThKV6nA= github.com/labstack/echo/v4 v4.16.3/go.mod h1:V/EQaTVHYJH92QhbQe7kFQ4mjgcjxLQQUQtAN87zZdw= github.com/labstack/gommon v0.5.0 h1:6VSQ2NOzsnEJ5W6+84E0RbcaDDmgB6NIAzWCczTEe6c= diff --git a/apps/web/src/components/Rail.tsx b/apps/web/src/components/Rail.tsx index a0fb412..03413c1 100644 --- a/apps/web/src/components/Rail.tsx +++ b/apps/web/src/components/Rail.tsx @@ -25,7 +25,7 @@ import { } from "../lib/updates"; import { subscribe } from "../lib/events"; import { deriveKey, initials } from "../lib/text"; -import { useNav } from "../stores/nav"; +import { useNarrow, useNav } from "../stores/nav"; import { setProjectOrder, setProjectSort, @@ -120,7 +120,7 @@ function ProjectRow(props: { aria-label={expanded() ? "Hide channels" : "Show channels"} aria-expanded={expanded()} onClick={() => setManual(!expanded())} - class="hidden shrink-0 rounded p-0.5 text-faint transition-colors hover:text-fg sm:block" + class="shrink-0 rounded p-0.5 text-faint transition-colors hover:text-fg" > void }) { export function Rail() { const session = useSession(); const projects = useProjects(); - const { navOpen, closeNav } = useNav(); + const { navOpen, openNav, closeNav } = useNav(); + const narrow = useNarrow(); + // On a phone the aside is either the icon rail or the overlay drawer. + // Desktop keeps the resizable column. The drawer sits above thread panels. + const drawer = () => narrow() && navOpen(); const [creating, setCreating] = createSignal(false); onMount(refreshUnread); const unsub = subscribe((e) => { @@ -842,27 +846,32 @@ export function Rail() { return ( <> - + +

+ Swipe right to reply · swipe left for the thread +

{ fileEl = el; @@ -4987,6 +5022,7 @@ function ThreadPanel(props: { thread: ThreadSummary; onClose: () => void; }) { + const narrow = useNarrow(); const [width, setWidth] = createSignal(threadWidth()); const [full, setFull] = createSignal(false); const [idCopied, setIdCopied] = createSignal(false); @@ -4994,9 +5030,22 @@ function ThreadPanel(props: { const [expiresAt, setExpiresAt] = createSignal( undefined, ); + // reply_count arrives as a snapshot in ThreadSummary; the panel is open + // while replies land, so it tracks thread.updated frames itself. + const [replyCount, setReplyCount] = createSignal(props.thread.reply_count); let expiryWrapEl: HTMLDivElement | undefined; let dragging = false; + onMount(() => + onCleanup( + subscribe((e) => { + if (e.type !== "thread.updated" && e.type !== "thread.created") return; + const t = e.data?.thread as Thread | undefined; + if (t?.id === props.thread.id) setReplyCount(t.reply_count); + }), + ), + ); + createEffect(() => { if (!expiryOpen()) return; // read current expiry once per open — the index endpoint already lists it @@ -5063,14 +5112,42 @@ function ThreadPanel(props: { onMount(() => window.addEventListener("keydown", onKey)); onCleanup(() => window.removeEventListener("keydown", onKey)); + // Swipe right closes the thread. The gesture ignores fields so a + // composer drag does not dismiss the panel. + let swipeStart: { x: number; y: number } | null = null; + const onSwipeStart = (e: TouchEvent) => { + const t = e.touches[0]; + const el = e.target as HTMLElement | null; + if (!t || el?.closest("textarea, input, button, a")) { + swipeStart = null; + return; + } + swipeStart = { x: t.clientX, y: t.clientY }; + }; + const onSwipeEnd = (e: TouchEvent) => { + const start = swipeStart; + swipeStart = null; + const t = e.changedTouches[0]; + if (!start || !t) return; + if (horizontalSwipe(t.clientX - start.x, t.clientY - start.y, 72) === "right") { + props.onClose(); + } + }; + + // Cover the conversation column, never the app rail or the top bar. + // Fullscreen and phones overlay the chat; sm+ sits beside it. + const overlay = () => full() || narrow(); + return (

- {props.thread.reply_count}{" "} - {props.thread.reply_count === 1 ? "reply" : "replies"} + {replyCount()} {replyCount() === 1 ? "reply" : "replies"}

(expiryWrapEl = el)}> @@ -5245,7 +5321,7 @@ export function Conversation(props: { } > {(c) => ( -
+
+ # | undefined; let watchdog: ReturnType | undefined; let visBound = false; let upBound = false; @@ -58,13 +62,13 @@ function resyncSoon() { function startWatchdog() { if (!watchdog) { watchdog = setInterval(() => { - if (net.isLocal()) return; + if (net.isLocal() || authBlocked) return; if (Date.now() - lastFrame <= HEARTBEAT_MISS_MS) return; connect(); // The stream may be unrecoverable — a desktop shell without the SSE // bridge, or a proxy that buffers EventSource to death. Reconcile // over REST each tick so a dead stream can't freeze the UI until a - // reload. + // reload. A 401 stays blocked so the login screen does not retry. emitLocal({ type: "stream.resync", project_id: "" }); }, 15_000); } @@ -74,6 +78,7 @@ function startWatchdog() { if ( document.visibilityState === "visible" && !net.isLocal() && + !authBlocked && Date.now() - lastFrame > HEARTBEAT_MISS_MS ) { connect(); @@ -118,6 +123,7 @@ function connectBridge(token: string): boolean { function connect() { const wasConnected = everConnected; + authBlocked = false; source?.close(); bridged = false; if (retry) { @@ -153,12 +159,37 @@ function connect() { }; es.onerror = () => { es.close(); - // backoff: 1s, 2s, 4s … capped at 30s - const delay = Math.min(30000, 1000 * 2 ** attempts++); - retry = setTimeout(connect, delay); + if (source === es) source = undefined; + // No token means auth is cookie-only or absent — one cheap probe + // distinguishes "session expired/absent" (stop) from a network blip + // (back off and retry). + if (!token) { + authProbe ??= fetch(`${base}/api/auth/session`) + .then((r) => r.ok) + .catch(() => true) // probe unreachable: treat as blip, keep retrying + .finally(() => { + authProbe = undefined; + }); + void authProbe.then((authed) => { + if (!authed) { + authBlocked = true; + return; + } + scheduleRetry(); + }); + return; + } + scheduleRetry(); }; } +// backoff: 1s, 2s, 4s … capped at 30s +function scheduleRetry() { + if (authBlocked) return; + const delay = Math.min(30000, 1000 * 2 ** attempts++); + retry = setTimeout(connect, delay); +} + // emitLocal feeds a synthetic event to subscribers. Local mode has no SSE; // the adapter uses this for updates a live view needs (e.g. a thread's // reply count on the parent message). diff --git a/apps/web/src/lib/local.test.ts b/apps/web/src/lib/local.test.ts index 10e164b..5d08f88 100644 --- a/apps/web/src/lib/local.test.ts +++ b/apps/web/src/lib/local.test.ts @@ -9,7 +9,7 @@ vi.stubGlobal("localStorage", { removeItem: () => {}, clear: () => {}, }); -const { dumpLocal, importRemoteSnapshot, remoteOriginOf } = await import( +const { dumpLocal, importRemoteSnapshot, local, remoteOriginOf } = await import( "./local" ); @@ -155,3 +155,25 @@ describe("importRemoteSnapshot", () => { expect(remoteOriginOf("pX")).toBeUndefined(); }); }); + +describe("local channels", () => { + it("lists one row per project and keeps channels off the main chat", async () => { + const p = await local.createProject({ name: "Phone Nav Test" }); + dumpLocal().projects.push({ ...p }); + const listed = await local.listProjects(); + expect(listed.projects.filter((x) => x.id === p.id)).toHaveLength(1); + + const main = await local.projectConversation(p.id); + const { channel } = await local.createChannel(p.id, " ops "); + expect(channel.name).toBe("ops"); + expect((await local.projectConversation(p.id)).id).toBe(main.id); + expect((await local.listChannels(p.id)).channels.map((c) => c.name)).toEqual([ + "ops", + ]); + await expect(local.createChannel(p.id, "OPS")).rejects.toThrow( + /already exists/, + ); + await local.deleteChannel(channel.id); + expect((await local.listChannels(p.id)).channels).toHaveLength(0); + }); +}); diff --git a/apps/web/src/lib/local.ts b/apps/web/src/lib/local.ts index 0cbbdec..bfcf976 100644 --- a/apps/web/src/lib/local.ts +++ b/apps/web/src/lib/local.ts @@ -31,6 +31,7 @@ import { type Project, type Reaction, type SearchResults, + type Channel, type Thread, type Todo, type User, @@ -49,9 +50,19 @@ interface LocalThread { parent_message_id: string; parent_conversation: string; title: string | null; + expires_at?: string | null; created_at: string; } +// Channel name and flags ride on the conversation row. The wire Conversation +// type has no name; these fields round-trip through the JSON doc. +type ChannelConv = Conversation & { + name?: string | null; + agents_blocked?: boolean; + intake_mode?: "" | "receive" | "chat" | "ops"; + email_alerts?: string[]; +}; + interface LocalDB { user: User; workspace: WorkspaceWithRole; @@ -126,6 +137,13 @@ export const localReady: Promise = (async () => { const saved = await localStore.get("doc"); if (saved) { db = { ...emptyDB(), ...saved }; + // A create that appended onto the live list used to persist the same + // project twice. Drop the extras once so the rail stays a single row. + const projects = uniqueById(db.projects); + if (projects.length !== db.projects.length) { + db.projects = projects; + save(); + } await rehydrateUrls(); return; } @@ -236,10 +254,22 @@ const me = () => ({ const findMessage = (id: string) => db.messages.find((m) => m.id === id); const findIssue = (id: string) => db.issues.find((i) => i.id === id); +function uniqueById(list: T[] | undefined): T[] { + const seen = new Set(); + const out: T[] = []; + for (const item of list ?? []) { + if (!item?.id || seen.has(item.id)) continue; + seen.add(item.id); + out.push(item); + } + return out; +} + const convOf = (projectId: string, issueId?: string) => db.conversations.find( (c) => c.kind !== "thread" && + c.kind !== "channel" && c.project_id === projectId && (c.issue_id ?? null) === (issueId ?? null), ); @@ -320,10 +350,45 @@ function threadOut(t: LocalThread): Thread { ? { author: parent.author.name, preview: parent.body.slice(0, 160) } : { author: "Deleted", preview: "Original message was deleted" }, last_reply_at: replies.at(-1)?.created_at ?? null, + expires_at: t.expires_at ?? null, created_at: t.created_at, }; } +function threadLive(t: LocalThread): boolean { + if (!t.expires_at) return true; + const at = Date.parse(t.expires_at); + return Number.isNaN(at) || at > Date.now(); +} + +function channelName(raw: string): string { + const s = raw.trim().replace(/\s+/g, " "); + if ([...s].length < 1 || [...s].length > 60) return ""; + return s; +} + +function asChannel(c: Conversation): Channel { + const x = c as ChannelConv; + const mode = x.intake_mode ?? ""; + return { + id: c.id, + project_id: c.project_id, + kind: "channel", + name: x.name ?? null, + agents_blocked: !!x.agents_blocked, + intake_mode: mode, + intake: mode !== "", + email_alerts: x.email_alerts ?? [], + created_at: c.created_at, + }; +} + +function findChannel(channelId: string): ChannelConv { + const c = db.conversations.find((x) => x.id === channelId); + if (!c || c.kind !== "channel") notFound(); + return c as ChannelConv; +} + // --- the adapter surface (subset of the server client) --- const impl = { @@ -340,7 +405,7 @@ const impl = { members: [{ user: db.user, role: "owner" }], }), - listProjects: async () => ({ projects: db.projects }), + listProjects: async () => ({ projects: uniqueById(db.projects) }), createProject: async (input: { name: string; key?: string; @@ -442,6 +507,7 @@ const impl = { }, listThreads: async (projectId: string) => ({ threads: db.threads + .filter(threadLive) .filter( (t) => db.conversations.find((c) => c.id === t.parent_conversation) @@ -455,6 +521,126 @@ const impl = { ) .map(threadOut), }), + setThreadExpiry: async (conversationId: string, expiresAt: string | null) => { + const t = db.threads.find((x) => x.id === conversationId); + if (!t) notFound(); + t.expires_at = expiresAt; + save(); + const live = threadLive(t); + emitLocal({ + type: live ? "thread.updated" : "thread.deleted", + project_id: + db.conversations.find((c) => c.id === t.parent_conversation) + ?.project_id ?? "", + data: { thread: threadOut(t) }, + }); + return { thread: live ? threadOut(t) : null, deleted: !live }; + }, + listChannels: async (projectId: string) => ({ + channels: db.conversations + .filter((c) => c.kind === "channel" && c.project_id === projectId) + .sort((a, b) => a.created_at.localeCompare(b.created_at)) + .map(asChannel), + }), + createChannel: async (projectId: string, name: string) => { + if (!db.projects.some((p) => p.id === projectId)) notFound(); + const n = channelName(name); + if (!n) { + throw new ApiClientError(400, "channel name must be 1-60 characters"); + } + const taken = db.conversations.some( + (c) => + c.kind === "channel" && + c.project_id === projectId && + (c as ChannelConv).name?.toLowerCase() === n.toLowerCase(), + ); + if (taken) { + throw new ApiClientError(409, "a channel with that name already exists"); + } + const conv: ChannelConv = { + id: uuid(), + project_id: projectId, + kind: "channel", + issue_id: null, + name: n, + agents_blocked: false, + intake_mode: "", + email_alerts: [], + created_at: now(), + }; + db.conversations.push(conv); + save(); + const channel = asChannel(conv); + emitLocal({ + type: "channel.created", + project_id: projectId, + data: { channel }, + }); + return { channel }; + }, + updateChannel: async ( + channelId: string, + input: { + name?: string; + agents_blocked?: boolean; + intake_mode?: "" | "receive" | "chat" | "ops"; + email_alerts?: string[]; + }, + ) => { + const c = findChannel(channelId); + if (input.name != null) { + const n = channelName(input.name); + if (!n) { + throw new ApiClientError(400, "channel name must be 1-60 characters"); + } + const taken = db.conversations.some( + (x) => + x.id !== c.id && + x.kind === "channel" && + x.project_id === c.project_id && + (x as ChannelConv).name?.toLowerCase() === n.toLowerCase(), + ); + if (taken) { + throw new ApiClientError( + 409, + "a channel with that name already exists", + ); + } + c.name = n; + } + if (input.agents_blocked != null) c.agents_blocked = input.agents_blocked; + if (input.intake_mode != null) c.intake_mode = input.intake_mode; + if (input.email_alerts != null) c.email_alerts = input.email_alerts; + save(); + const channel = asChannel(c); + emitLocal({ + type: "channel.updated", + project_id: c.project_id, + data: { channel }, + }); + return { channel }; + }, + deleteChannel: async (channelId: string) => { + const c = findChannel(channelId); + const threadIds = new Set( + db.threads + .filter((t) => t.parent_conversation === channelId) + .map((t) => t.id), + ); + db.threads = db.threads.filter((t) => !threadIds.has(t.id)); + db.conversations = db.conversations.filter( + (x) => x.id !== channelId && !threadIds.has(x.id), + ); + db.messages = db.messages.filter( + (m) => m.conversation_id !== channelId && !threadIds.has(m.conversation_id), + ); + save(); + emitLocal({ + type: "channel.deleted", + project_id: c.project_id, + data: { channel_id: channelId }, + }); + }, listMessages: async ( conversationId: string, @@ -637,6 +823,8 @@ const impl = { }, markMessageRead: async () => undefined, markConversationRead: async () => undefined, + sendTyping: async () => undefined, + listScheduledMessages: async () => ({ scheduled: [] }), listIssues: async ( projectId: string, @@ -1270,12 +1458,15 @@ const impl = { // object URL for an already-loaded attachment (img src can't await). const SYNC_READS = new Set(["attachmentURL"]); export const local = new Proxy(impl, { - get(t, k: string) { + get(t, k: string | symbol) { + if (typeof k !== "string") return undefined; if (SYNC_READS.has(k)) return t[k as keyof typeof t]; + const fn = t[k as keyof typeof t]; + // Unknown methods stay undefined so api.ts can say the call needs a + // server, instead of throwing "t[k] is not a function". + if (typeof fn !== "function") return undefined; return (...args: unknown[]) => - localReady.then(() => - (t[k as keyof typeof t] as (...a: unknown[]) => unknown)(...args), - ); + localReady.then(() => (fn as (...a: unknown[]) => unknown)(...args)); }, }) as typeof impl; diff --git a/apps/web/src/lib/swipe.test.ts b/apps/web/src/lib/swipe.test.ts new file mode 100644 index 0000000..98282b4 --- /dev/null +++ b/apps/web/src/lib/swipe.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from "vitest"; +import { horizontalSwipe } from "./swipe"; + +describe("horizontalSwipe", () => { + it("ignores vertical scrolls", () => { + expect(horizontalSwipe(20, 80)).toBeNull(); + expect(horizontalSwipe(-40, 40)).toBeNull(); + }); + + it("requires the threshold", () => { + expect(horizontalSwipe(55, 0)).toBeNull(); + expect(horizontalSwipe(56, 10)).toBe("right"); + expect(horizontalSwipe(-56, 4)).toBe("left"); + }); +}); diff --git a/apps/web/src/lib/swipe.ts b/apps/web/src/lib/swipe.ts new file mode 100644 index 0000000..65ad740 --- /dev/null +++ b/apps/web/src/lib/swipe.ts @@ -0,0 +1,16 @@ +// Horizontal gesture decision shared by message rows, the thread panel, +// and the nav edge swipe. Vertical movement wins so a scroll never +// becomes a reply or a back. + +export type HSwipe = "left" | "right" | null; + +export function horizontalSwipe( + dx: number, + dy: number, + threshold = 56, +): HSwipe { + if (Math.abs(dy) >= Math.abs(dx)) return null; + if (dx >= threshold) return "right"; + if (dx <= -threshold) return "left"; + return null; +} diff --git a/apps/web/src/pages/Home.tsx b/apps/web/src/pages/Home.tsx index 8399e6f..e88e05f 100644 --- a/apps/web/src/pages/Home.tsx +++ b/apps/web/src/pages/Home.tsx @@ -180,15 +180,17 @@ export default function Home() { - {totals().issues} open issues + {totals().issues} open{" "} + {totals().issues === 1 ? "issue" : "issues"} - {totals().prs} open PRs + {totals().prs} open{" "} + {totals().prs === 1 ? "PR" : "PRs"} 0}> {totals().reviews}{" "} - reviews pending + {totals().reviews === 1 ? "review" : "reviews"} pending
diff --git a/apps/web/src/stores/nav.ts b/apps/web/src/stores/nav.ts index d013489..5a36112 100644 --- a/apps/web/src/stores/nav.ts +++ b/apps/web/src/stores/nav.ts @@ -8,10 +8,24 @@ export function useNav() { return { navOpen, toggleNav: () => setNavOpen((v) => !v), + openNav: () => setNavOpen(true), closeNav: () => setNavOpen(false), }; } +// Phones and narrow windows keep a permanent icon rail. The full project +// list is the drawer. md (768px) is where the rail becomes the desktop column. +const narrowQuery = + typeof window !== "undefined" + ? window.matchMedia("(max-width: 767.98px)") + : null; +const [narrow, setNarrow] = createSignal(narrowQuery?.matches ?? false); +narrowQuery?.addEventListener("change", (e) => setNarrow(e.matches)); + +export function useNarrow() { + return narrow; +} + // Phone gesture: swipe in from the left edge opens the drawer, a leftward // fling while it's open closes it — the same convention every mobile app // with a side drawer uses. Vertical scrolls are ignored by the axis check. @@ -25,9 +39,9 @@ export function initNavSwipe() { (e) => { const t = e.touches[0]; if (!t) return; - // opening requires starting at the screen edge; closing works anywhere - // (when open, the drawer + backdrop cover the content anyway) - tracking = (!navOpen() && t.clientX <= 28) || navOpen(); + // Opening starts on the icon rail (3.5rem). Closing works anywhere — + // the drawer and its backdrop cover the content. + tracking = (!navOpen() && t.clientX <= 56) || navOpen(); x0 = t.clientX; y0 = t.clientY; }, diff --git a/apps/web/src/stores/projects.tsx b/apps/web/src/stores/projects.tsx index dbb9e24..1d937df 100644 --- a/apps/web/src/stores/projects.tsx +++ b/apps/web/src/stores/projects.tsx @@ -105,7 +105,12 @@ export function ProjectsProvider(props: ParentProps) { sorted, create: async (input) => { const project = await api.createProject(input); - mutate((list) => [...(list ?? []), project]); + // Local mode's list is the same array createProject just pushed + // onto. Appending again paints the new project twice. + mutate((list) => [ + ...(list ?? []).filter((p) => p.id !== project.id), + project, + ]); return project; }, refresh: async () => { diff --git a/apps/web/src/stores/unread.ts b/apps/web/src/stores/unread.ts index 2e4930a..66fe185 100644 --- a/apps/web/src/stores/unread.ts +++ b/apps/web/src/stores/unread.ts @@ -1,4 +1,4 @@ -import { createEffect, createMemo, createSignal } from "solid-js"; +import { createEffect, createMemo, createRoot, createSignal } from "solid-js"; import type { UnreadConversation } from "@relay/api-client"; import { api } from "../lib/api"; import { desktopSetUnread } from "../lib/desktop"; @@ -21,14 +21,18 @@ export function useUnreadConversations() { return { unreadConversations }; } -// issue_id -> unread count, for marking issue rows. -const unreadByIssueMap = createMemo(() => { - const m = new Map(); - for (const c of unreadConversations()) { - if (c.kind === "issue" && c.issue_id) m.set(c.issue_id, c.unread); - } - return m; -}); +// issue_id -> unread count, for marking issue rows. Module-scope memos and +// effects need an owner or Solid warns they can never be disposed — this +// store is app-lifetime by design, so a detached root is correct. +const unreadByIssueMap = createRoot(() => + createMemo(() => { + const m = new Map(); + for (const c of unreadConversations()) { + if (c.kind === "issue" && c.issue_id) m.set(c.issue_id, c.unread); + } + return m; + }), +); export function useUnreadByIssue() { return unreadByIssueMap; @@ -36,10 +40,12 @@ export function useUnreadByIssue() { // Total unread across conversations — bridged to the desktop shell's // window title and tray badge. The effect is a no-op in a plain browser. -const unreadTotal = createMemo(() => - unreadConversations().reduce((sum, c) => sum + c.unread, 0), +const unreadTotal = createRoot(() => + createMemo(() => + unreadConversations().reduce((sum, c) => sum + c.unread, 0), + ), ); -createEffect(() => desktopSetUnread(unreadTotal())); +createRoot(() => createEffect(() => desktopSetUnread(unreadTotal()))); export function usePendingReviews() { return { pendingReviews }; diff --git a/db/queries/mcp.sql b/db/queries/mcp.sql index 13916e5..ca231eb 100644 --- a/db/queries/mcp.sql +++ b/db/queries/mcp.sql @@ -26,9 +26,9 @@ from conversations c left join lateral ( select count(*)::int as message_count, max(m.created_at)::timestamptz as last_message_at, - (array_agg(m.body order by m.created_at desc, m.id desc))[1]::text as last_body, - (array_agg(coalesce(u.name, au.name, nullif(m.author_name_snapshot, ''), '') - order by m.created_at desc, m.id desc))[1]::text as last_author + coalesce((array_agg(m.body order by m.created_at desc, m.id desc))[1]::text, '') as last_body, + coalesce((array_agg(coalesce(u.name, au.name, nullif(m.author_name_snapshot, ''), '') + order by m.created_at desc, m.id desc))[1]::text, '') as last_author from messages m left join users u on u.id = m.author_user_id left join agents au on au.id = m.author_agent_id diff --git a/internal/db/mcp.sql.go b/internal/db/mcp.sql.go index 3638749..ebfba75 100644 --- a/internal/db/mcp.sql.go +++ b/internal/db/mcp.sql.go @@ -670,9 +670,9 @@ from conversations c left join lateral ( select count(*)::int as message_count, max(m.created_at)::timestamptz as last_message_at, - (array_agg(m.body order by m.created_at desc, m.id desc))[1]::text as last_body, - (array_agg(coalesce(u.name, au.name, nullif(m.author_name_snapshot, ''), '') - order by m.created_at desc, m.id desc))[1]::text as last_author + coalesce((array_agg(m.body order by m.created_at desc, m.id desc))[1]::text, '') as last_body, + coalesce((array_agg(coalesce(u.name, au.name, nullif(m.author_name_snapshot, ''), '') + order by m.created_at desc, m.id desc))[1]::text, '') as last_author from messages m left join users u on u.id = m.author_user_id left join agents au on au.id = m.author_agent_id diff --git a/internal/mcpserver/mcpserver.go b/internal/mcpserver/mcpserver.go index d19377a..0979752 100644 --- a/internal/mcpserver/mcpserver.go +++ b/internal/mcpserver/mcpserver.go @@ -343,8 +343,8 @@ func (s *Service) registerTools(srv *server.MCPServer) { return jsonResult(gin.H{ "guide": agentdoc.Guide, "manifest": gin.H{ - "tools": s.tools, - "reply_flow": "send_message with reply_to= — conversation_id is inferred from the target; pass conversation_id/project_id explicitly only when starting a new top-level message", + "tools": s.tools, + "reply_flow": "send_message with reply_to= — conversation_id is inferred from the target; pass conversation_id/project_id explicitly only when starting a new top-level message", "mention_syntax": "@name mentions a workspace member, @agent: an agent, KEY-1 an issue, owner/repo#N a GitHub issue/PR, @file: a linked local file", "minimal_mode": "most read tools accept minimal:true — bodies/descriptions become 200-char excerpts with truncated:true", "wait_for_reply": "await_message {conversation_id, timeout_s<=55} long-polls for a reply from another author; inbox lists mentions, replies and unread in one call", @@ -3149,7 +3149,7 @@ func (s *Service) whoami(ctx context.Context, _ mcp.CallToolRequest) (*mcp.CallT out := gin.H{ "id": a.ID, "name": a.Name, "slug": a.Slug, "review_mode": a.ReviewMode, "grant_all": a.GrantAll, - "grant_scopes": a.GrantScopes, + "grant_scopes": a.GrantScopes, "server_version": s.version, // the registered tool list — feature-detect instead of guessing names "capabilities": names, @@ -3196,7 +3196,7 @@ func (s *Service) activity(ctx context.Context, req mcp.CallToolRequest) (*mcp.C for _, m := range rows { e := gin.H{ "id": m.ID, "conversation_id": m.ConversationID, - "created_at": m.CreatedAt.Time, + "created_at": m.CreatedAt.Time, "conversation_kind": m.ConversationKind, "project": gin.H{"id": m.ProjectID, "key": m.ProjectKey, "name": m.ProjectName}, "author": gin.H{"name": m.AuthorName, "kind": m.AuthorKind},