mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-07 16:35:48 +01:00
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>
19 lines
874 B
TypeScript
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];
|
|
}
|