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 mountedRef = useRef(true);
const headers = useCallback((): Record<string, string> => {
const h: Record<string, string> = { 'Content-Type': 'application/json' };
if (sessionCookie) h['Cookie'] = sessionCookie;
return h;
}, [sessionCookie]);
const headers = useCallback(
(includeContentType = true): Record<string, string> => {
const h: Record<string, string> = { 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) {