Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { useCallback, type PointerEvent } from "react";
|
|
import type { AgentGUINodeViewProps } from "./AgentGUINodeView.types";
|
|
import { useOptionalStableEventCallback } from "./agentGUIViewUtils";
|
|
|
|
export interface AgentGUIConversationRailResizeInteraction {
|
|
lastWidthPx: number;
|
|
pointerId: number;
|
|
startClientX: number;
|
|
startWidthPx: number;
|
|
}
|
|
|
|
interface UseAgentGUIConversationRailResizePointerMoveInput {
|
|
clampConversationRailWidth: (widthPx: number) => number;
|
|
layoutElementRef: { current: HTMLElement | null };
|
|
onConversationRailLayoutChange: AgentGUINodeViewProps["onConversationRailLayoutChange"];
|
|
providerRailWidthPx: number;
|
|
railResizeInteractionRef: {
|
|
current: AgentGUIConversationRailResizeInteraction | null;
|
|
};
|
|
}
|
|
|
|
export function useAgentGUIConversationRailResizePointerMove({
|
|
clampConversationRailWidth,
|
|
layoutElementRef,
|
|
onConversationRailLayoutChange,
|
|
providerRailWidthPx,
|
|
railResizeInteractionRef
|
|
}: UseAgentGUIConversationRailResizePointerMoveInput): (
|
|
event: PointerEvent<HTMLDivElement>
|
|
) => void {
|
|
const reportConversationRailLayoutChange = useOptionalStableEventCallback(
|
|
onConversationRailLayoutChange
|
|
);
|
|
|
|
return useCallback(
|
|
(event: PointerEvent<HTMLDivElement>): void => {
|
|
const resizeState = railResizeInteractionRef.current;
|
|
if (!resizeState || resizeState.pointerId !== event.pointerId) return;
|
|
|
|
const nextWidthPx = clampConversationRailWidth(
|
|
resizeState.startWidthPx + event.clientX - resizeState.startClientX
|
|
);
|
|
if (resizeState.lastWidthPx === nextWidthPx) return;
|
|
|
|
resizeState.lastWidthPx = nextWidthPx;
|
|
layoutElementRef.current?.style.setProperty(
|
|
"--agent-gui-conversation-rail-width",
|
|
`${nextWidthPx}px`
|
|
);
|
|
layoutElementRef.current?.style.setProperty(
|
|
"--agent-gui-conversation-rail-content-width",
|
|
`${nextWidthPx}px`
|
|
);
|
|
reportConversationRailLayoutChange?.({
|
|
providerRailWidthPx,
|
|
conversationRailWidthPx: nextWidthPx,
|
|
leftPanelWidthPx: providerRailWidthPx + nextWidthPx,
|
|
resizing: true
|
|
});
|
|
event.currentTarget.setAttribute("aria-valuenow", String(nextWidthPx));
|
|
},
|
|
[
|
|
clampConversationRailWidth,
|
|
layoutElementRef,
|
|
providerRailWidthPx,
|
|
railResizeInteractionRef,
|
|
reportConversationRailLayoutChange
|
|
]
|
|
);
|
|
}
|