From 048bc14a2caca7d5f4bbde9b9b086dc01312f130 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Mon, 16 Mar 2026 21:34:04 -0500 Subject: [PATCH] =?UTF-8?q?fix(cli):=20sidebar=20delete=20conversation=20?= =?UTF-8?q?=E2=80=94=20fix=20silent=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing Origin header to all requests in use-conversations hook. BetterAuth requires Origin for session validation; without it DELETE requests return 401 which was silently swallowed, causing 'd' in the sidebar to appear as a no-op. Fixes #191. Co-Authored-By: Claude Sonnet 4.6 --- .../cli/src/tui/hooks/use-conversations.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/tui/hooks/use-conversations.ts b/packages/cli/src/tui/hooks/use-conversations.ts index 0855eca..50078f7 100644 --- a/packages/cli/src/tui/hooks/use-conversations.ts +++ b/packages/cli/src/tui/hooks/use-conversations.ts @@ -31,18 +31,22 @@ export function useConversations(opts: UseConversationsOptions): UseConversation const [error, setError] = useState(null); const mountedRef = useRef(true); - const headers = useCallback((): Record => { - const h: Record = { 'Content-Type': 'application/json' }; - if (sessionCookie) h['Cookie'] = sessionCookie; - return h; - }, [sessionCookie]); + const headers = useCallback( + (includeContentType = true): Record => { + const h: Record = { Origin: gatewayUrl }; + if (includeContentType) h['Content-Type'] = 'application/json'; + if (sessionCookie) h['Cookie'] = sessionCookie; + return h; + }, + [gatewayUrl, sessionCookie], + ); const refresh = useCallback(async () => { if (!mountedRef.current) return; setLoading(true); setError(null); try { - const res = await fetch(`${gatewayUrl}/api/conversations`, { headers: headers() }); + const res = await fetch(`${gatewayUrl}/api/conversations`, { headers: headers(false) }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const data = (await res.json()) as ConversationSummary[]; if (mountedRef.current) { @@ -93,7 +97,7 @@ export function useConversations(opts: UseConversationsOptions): UseConversation try { const res = await fetch(`${gatewayUrl}/api/conversations/${id}`, { method: 'DELETE', - headers: headers(), + headers: headers(false), }); if (!res.ok) return false; if (mountedRef.current) { -- 2.49.1