The best way to control Claude Code, Codex and more from any computer or phone

main
ts 33 lines 1.16 KB
Raw
1 export interface ThreadWorkGroupScrollPosition {
2 readonly rowId: string;
3 readonly offsetWithinRow: number;
4 readonly scrollOffset: number;
5 }
6
7 export function resolveThreadWorkGroupInitialScroll(
8 rows: ReadonlyArray<{ readonly id: string }>,
9 position: ThreadWorkGroupScrollPosition | undefined,
10 ) {
11 const index = position ? rows.findIndex((row) => row.id === position.rowId) : -1;
12 return index >= 0 && position ? { index, viewOffset: -position.offsetWithinRow } : undefined;
13 }
14
15 export function resolveThreadFeedSubmissionAnchor<AnchorId>(input: {
16 readonly currentAnchorMessageId: AnchorId | null;
17 readonly submittedMessageId: AnchorId;
18 readonly hasStartedTurn: boolean;
19 readonly hasUserMessage: boolean;
20 readonly queuedMessageCount: number;
21 readonly deliveryDeferred: boolean;
22 }): AnchorId | null {
23 // Keeping the first message's anchor holds a short thread in place; a follow-up never anchors.
24 if (input.currentAnchorMessageId !== null) {
25 return input.currentAnchorMessageId;
26 }
27
28 if (input.deliveryDeferred || input.hasStartedTurn || input.hasUserMessage) {
29 return null;
30 }
31
32 return input.queuedMessageCount > 0 ? null : input.submittedMessageId;
33 }