Files
PaperClipAI/ui/src/components/task-chat/expansion-state.tsx
T
DottaandPaperclip cd4c4ed205 fix(ui): stabilize task loading and live feeds (#13095)
Coordinate initial conversation reveal, preserve message identity and reading anchors during live updates, and bound transcript reads with recoverable retries. Cover desktop/mobile navigation and rich task loading with actual-route browser tests.

Verified all Linux CI gates, 5,575 local UI tests, eight layout browser scenarios, and recorded native Codex walkthroughs. Greptile: 5/5; all review findings resolved.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-09-09 10:00:37 -05:00

19 lines
874 B
TypeScript

import { createContext, useCallback, useContext, useState, type Dispatch, type SetStateAction } from "react";
// A phase can move from the live tail into persisted history. Its expansion
// belongs to the logical phase, not whichever component currently hosts it.
export const TaskChatExpansionState = createContext<Map<string, boolean> | null>(null);
export function useTaskChatExpansion(id: string, initial: boolean): [boolean, Dispatch<SetStateAction<boolean>>] {
const memory = useContext(TaskChatExpansionState);
const [open, setOpen] = useState(() => memory?.get(id) ?? initial);
const update = useCallback<Dispatch<SetStateAction<boolean>>>((value) => {
setOpen((previous) => {
const next = typeof value === "function" ? value(previous) : value;
memory?.set(id, next);
return next;
});
}, [id, memory]);
return [open, update];
}