fix(cli): sidebar delete conversation — fix silent failure (#201)
Some checks failed
ci/woodpecker/push/ci Pipeline failed

Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #201.
This commit is contained in:
2026-03-17 02:36:46 +00:00
committed by jason.woltje
parent 93645295d5
commit 1f2b8125c6

View File

@@ -31,18 +31,22 @@ export function useConversations(opts: UseConversationsOptions): UseConversation
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const mountedRef = useRef(true); const mountedRef = useRef(true);
const headers = useCallback((): Record<string, string> => { const headers = useCallback(
const h: Record<string, string> = { 'Content-Type': 'application/json' }; (includeContentType = true): Record<string, string> => {
if (sessionCookie) h['Cookie'] = sessionCookie; const h: Record<string, string> = { Origin: gatewayUrl };
return h; if (includeContentType) h['Content-Type'] = 'application/json';
}, [sessionCookie]); if (sessionCookie) h['Cookie'] = sessionCookie;
return h;
},
[gatewayUrl, sessionCookie],
);
const refresh = useCallback(async () => { const refresh = useCallback(async () => {
if (!mountedRef.current) return; if (!mountedRef.current) return;
setLoading(true); setLoading(true);
setError(null); setError(null);
try { 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}`); if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = (await res.json()) as ConversationSummary[]; const data = (await res.json()) as ConversationSummary[];
if (mountedRef.current) { if (mountedRef.current) {
@@ -93,7 +97,7 @@ export function useConversations(opts: UseConversationsOptions): UseConversation
try { try {
const res = await fetch(`${gatewayUrl}/api/conversations/${id}`, { const res = await fetch(`${gatewayUrl}/api/conversations/${id}`, {
method: 'DELETE', method: 'DELETE',
headers: headers(), headers: headers(false),
}); });
if (!res.ok) return false; if (!res.ok) return false;
if (mountedRef.current) { if (mountedRef.current) {