fix(chat): preserve tool duration across session switches (#1712)

* fix(chat): preserve tool duration across session switches

Fix #1636: ToolPart.tsx reset pinnedTime to empty on unmount/remount,
causing LiveDuration to not render on first paint. Now initializes
pinnedTime from server-provided time?.start/time?.end in the useState
initializer, eliminating the one-frame gap.

* fix(sync): preserve tool state.time in materialization merge

---------

Co-authored-by: Leonid Skorobogatyy <bash@opencode.itc.local>
This commit is contained in:
bashrusakh
2026-06-23 22:30:04 +03:00
committed by GitHub
co-authored by Leonid Skorobogatyy
parent 57cef1b278
commit ac0f173655
3 changed files with 58 additions and 1 deletions
@@ -2055,7 +2055,10 @@ const ToolPartContent: React.FC<ToolPartProps> = ({
const input = stateWithData.input;
const time = stateWithData.time;
const [pinnedTime, setPinnedTime] = React.useState<{ start?: number; end?: number }>({});
const [pinnedTime, setPinnedTime] = React.useState<{ start?: number; end?: number }>(() => ({
start: typeof time?.start === 'number' ? time.start : undefined,
end: typeof time?.end === 'number' ? time.end : undefined,
}));
const [localStartAt, setLocalStartAt] = React.useState<number | undefined>(undefined);
const [localFinalizedAt, setLocalFinalizedAt] = React.useState<number | undefined>(undefined);