@opengeni/react 0.13.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -23
- package/dist/chunk-6BXBGJ3B.js +1956 -0
- package/dist/chunk-6BXBGJ3B.js.map +1 -0
- package/dist/chunk-6UT5OC3P.js +2133 -0
- package/dist/chunk-6UT5OC3P.js.map +1 -0
- package/dist/chunk-EBTT3MYN.js +92 -0
- package/dist/chunk-EBTT3MYN.js.map +1 -0
- package/dist/chunk-HHFA4AFX.js +425 -0
- package/dist/chunk-HHFA4AFX.js.map +1 -0
- package/dist/chunk-LAZ2A743.js +2393 -0
- package/dist/chunk-LAZ2A743.js.map +1 -0
- package/dist/chunk-MRSECXRP.js +563 -0
- package/dist/chunk-MRSECXRP.js.map +1 -0
- package/dist/chunk-TK7G6XLT.js +18 -0
- package/dist/chunk-TK7G6XLT.js.map +1 -0
- package/dist/composer-DvUaa5ki.d.ts +585 -0
- package/dist/composer.d.ts +6 -0
- package/dist/composer.js +56 -0
- package/dist/composer.js.map +1 -0
- package/dist/index.d.ts +642 -1080
- package/dist/index.js +7672 -8005
- package/dist/index.js.map +1 -1
- package/dist/machines.d.ts +412 -3
- package/dist/machines.js +25 -1
- package/dist/noto-sans-arabic-loader-IA2T4X2A.js +21 -0
- package/dist/noto-sans-arabic-loader-IA2T4X2A.js.map +1 -0
- package/dist/noto-sans-jp-loader.generated-HFGLYBR3.js +292 -0
- package/dist/noto-sans-jp-loader.generated-HFGLYBR3.js.map +1 -0
- package/dist/queue-surface-implementation-NQMV2ML3.js +890 -0
- package/dist/queue-surface-implementation-NQMV2ML3.js.map +1 -0
- package/dist/session-Gd4iVPYw.d.ts +425 -0
- package/dist/session-context-DIFFlXKc.d.ts +52 -0
- package/dist/session.d.ts +4 -0
- package/dist/session.js +50 -0
- package/dist/session.js.map +1 -0
- package/dist/use-composer-BCfm4mzX.d.ts +112 -0
- package/package.json +23 -4
- package/src/approvals.ts +5 -3
- package/src/client.ts +50 -1
- package/src/components/approval-surface.tsx +198 -0
- package/src/components/chat-composer.tsx +104 -751
- package/src/components/code-editor.tsx +104 -26
- package/src/components/command-palette.tsx +8 -2
- package/src/components/composer-transcription-control.tsx +211 -0
- package/src/components/composer.tsx +1536 -0
- package/src/components/desktop-viewer.tsx +3 -3
- package/src/components/enrollment-consent.tsx +2 -2
- package/src/components/file-browser.tsx +367 -29
- package/src/components/human-input-form.tsx +417 -0
- package/src/components/machine-card.tsx +82 -16
- package/src/components/machine-health-pill.tsx +68 -0
- package/src/components/machine-metrics.tsx +10 -24
- package/src/components/machines/health.ts +146 -0
- package/src/components/machines/machine-detail.tsx +220 -0
- package/src/components/machines/metric-history-chart.tsx +298 -0
- package/src/components/machines/metric-sparkline.tsx +76 -0
- package/src/components/machines/series.ts +113 -0
- package/src/components/machines-dashboard.tsx +16 -4
- package/src/components/message-timeline.tsx +15 -7
- package/src/components/model-picker.tsx +12 -3
- package/src/components/pierre-diff.tsx +32 -6
- package/src/components/queue-surface-implementation.tsx +1041 -0
- package/src/components/queue-surface-state.tsx +94 -0
- package/src/components/queue-surface.tsx +60 -0
- package/src/components/sandbox-files.tsx +230 -21
- package/src/components/sandbox-terminal.tsx +8 -2
- package/src/components/sandbox-workspace.tsx +489 -135
- package/src/components/session-status.tsx +0 -6
- package/src/components/workbench-changes.tsx +145 -50
- package/src/components/workspace-dock.tsx +329 -68
- package/src/composer.ts +60 -0
- package/src/hooks/internal.ts +115 -34
- package/src/hooks/use-composer.ts +635 -74
- package/src/hooks/use-human-input.ts +131 -0
- package/src/hooks/use-machine-chip.ts +2 -2
- package/src/hooks/use-machines.ts +27 -11
- package/src/hooks/use-sandbox-files.ts +310 -62
- package/src/hooks/use-sandbox-git.ts +154 -40
- package/src/hooks/use-sandbox-terminal.ts +28 -6
- package/src/hooks/use-session-capabilities.ts +38 -9
- package/src/hooks/use-session-control.ts +43 -15
- package/src/hooks/use-session-events.ts +523 -48
- package/src/hooks/use-session-lineage.ts +15 -6
- package/src/hooks/use-session.ts +10 -2
- package/src/hooks/use-slash-commands.ts +38 -38
- package/src/hooks/use-transcription.ts +757 -0
- package/src/hooks/use-turn-queue.ts +273 -77
- package/src/hooks/use-windowed-sections.ts +2 -2
- package/src/hooks/use-workspace-capture.ts +146 -40
- package/src/hooks/use-workspace-edit.ts +50 -14
- package/src/hooks/use-workspace-sessions.ts +3 -0
- package/src/human-input.ts +72 -0
- package/src/index.ts +88 -12
- package/src/lib/noto-sans-arabic-loader.ts +21 -0
- package/src/lib/noto-sans-jp-loader.generated.ts +295 -0
- package/src/lib/use-portal-token-style.ts +51 -0
- package/src/lib/use-unicode-fonts.ts +57 -0
- package/src/machines.ts +16 -0
- package/src/provider.tsx +163 -41
- package/src/session-context.ts +135 -0
- package/src/session.ts +79 -0
- package/src/timeline/parsers.ts +78 -6
- package/src/timeline/projection.ts +36 -6
- package/src/timeline/tool-renderers.tsx +41 -0
- package/src/timeline/turn-summary.tsx +2 -2
- package/src/timeline/types.ts +16 -8
- package/styles/index.css +78 -0
- package/styles/index.d.ts +2 -0
- package/styles/tokens.css +11 -6
- package/styles/tokens.d.ts +2 -0
- package/dist/chunk-NFYVQWIB.js +0 -1377
- package/dist/chunk-NFYVQWIB.js.map +0 -1
- package/dist/machines-CnlMb7E-.d.ts +0 -329
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { SessionEvent } from "@opengeni/sdk";
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
import {
|
|
1
|
+
import type { SessionControlResponse, SessionEvent } from "@opengeni/sdk";
|
|
2
|
+
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
3
|
+
import { useEmbeddedSession, type EmbeddedSessionClientOverride } from "../session-context";
|
|
4
4
|
import { useMutationRunner } from "./internal";
|
|
5
5
|
|
|
6
|
-
export type UseSessionControlOptions =
|
|
6
|
+
export type UseSessionControlOptions = EmbeddedSessionClientOverride;
|
|
7
7
|
|
|
8
8
|
export type UseSessionControlResult = {
|
|
9
|
-
pause: (reason?: string) => Promise<
|
|
10
|
-
resume: (reason?: string) => Promise<
|
|
9
|
+
pause: (reason?: string) => Promise<SessionControlResponse | null>;
|
|
10
|
+
resume: (reason?: string) => Promise<SessionControlResponse | null>;
|
|
11
11
|
controlling: boolean;
|
|
12
12
|
/** Approve a pending `requires_action` approval. */
|
|
13
13
|
approve: (approvalId: string, message?: string) => Promise<SessionEvent | null>;
|
|
@@ -28,22 +28,33 @@ export function useSessionControl(
|
|
|
28
28
|
sessionId: string | null | undefined,
|
|
29
29
|
options: UseSessionControlOptions = {},
|
|
30
30
|
): UseSessionControlResult {
|
|
31
|
-
const { client, workspaceId } =
|
|
31
|
+
const { client, workspaceId } = useEmbeddedSession(options);
|
|
32
|
+
const approvalTargetKey = `${workspaceId}\u0000${sessionId ?? ""}`;
|
|
33
|
+
const pendingApproval = useRef<{
|
|
34
|
+
targetKey: string;
|
|
35
|
+
decisionKey: string;
|
|
36
|
+
clientEventId: string;
|
|
37
|
+
} | null>(null);
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (pendingApproval.current?.targetKey !== approvalTargetKey) {
|
|
40
|
+
pendingApproval.current = null;
|
|
41
|
+
}
|
|
42
|
+
}, [approvalTargetKey]);
|
|
32
43
|
const {
|
|
33
44
|
run: runControl,
|
|
34
45
|
mutating: controlling,
|
|
35
46
|
mutationError: controlError,
|
|
36
47
|
clearMutationError: clearControlError,
|
|
37
|
-
} = useMutationRunner();
|
|
48
|
+
} = useMutationRunner(approvalTargetKey);
|
|
38
49
|
const {
|
|
39
50
|
run: runApproval,
|
|
40
51
|
mutating: responding,
|
|
41
52
|
mutationError: approvalError,
|
|
42
53
|
clearMutationError: clearApprovalError,
|
|
43
|
-
} = useMutationRunner();
|
|
54
|
+
} = useMutationRunner(approvalTargetKey);
|
|
44
55
|
|
|
45
56
|
const pause = useCallback(
|
|
46
|
-
async (reason?: string): Promise<
|
|
57
|
+
async (reason?: string): Promise<SessionControlResponse | null> => {
|
|
47
58
|
if (!sessionId) {
|
|
48
59
|
return null;
|
|
49
60
|
}
|
|
@@ -55,12 +66,11 @@ export function useSessionControl(
|
|
|
55
66
|
);
|
|
56
67
|
|
|
57
68
|
const resume = useCallback(
|
|
58
|
-
async (reason?: string): Promise<
|
|
69
|
+
async (reason?: string): Promise<SessionControlResponse | null> => {
|
|
59
70
|
if (!sessionId) return null;
|
|
60
|
-
|
|
71
|
+
return await runControl(() =>
|
|
61
72
|
client.resumeSession(workspaceId, sessionId, reason !== undefined ? { reason } : {}),
|
|
62
73
|
);
|
|
63
|
-
return result?.event ?? null;
|
|
64
74
|
},
|
|
65
75
|
[client, workspaceId, sessionId, runControl],
|
|
66
76
|
);
|
|
@@ -74,15 +84,33 @@ export function useSessionControl(
|
|
|
74
84
|
if (!sessionId) {
|
|
75
85
|
return null;
|
|
76
86
|
}
|
|
77
|
-
|
|
87
|
+
const decisionKey = JSON.stringify([approvalId, decision, message ?? null]);
|
|
88
|
+
if (pendingApproval.current?.decisionKey !== decisionKey) {
|
|
89
|
+
pendingApproval.current = {
|
|
90
|
+
targetKey: approvalTargetKey,
|
|
91
|
+
decisionKey,
|
|
92
|
+
clientEventId: crypto.randomUUID(),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const clientEventId = pendingApproval.current.clientEventId;
|
|
96
|
+
const accepted = await runApproval(() =>
|
|
78
97
|
client.sendApprovalDecision(workspaceId, sessionId, {
|
|
79
98
|
approvalId,
|
|
80
99
|
decision,
|
|
81
100
|
...(message !== undefined ? { message } : {}),
|
|
101
|
+
clientEventId,
|
|
82
102
|
}),
|
|
83
103
|
);
|
|
104
|
+
if (
|
|
105
|
+
accepted !== null &&
|
|
106
|
+
pendingApproval.current?.targetKey === approvalTargetKey &&
|
|
107
|
+
pendingApproval.current.clientEventId === clientEventId
|
|
108
|
+
) {
|
|
109
|
+
pendingApproval.current = null;
|
|
110
|
+
}
|
|
111
|
+
return accepted;
|
|
84
112
|
},
|
|
85
|
-
[client, workspaceId, sessionId, runApproval],
|
|
113
|
+
[approvalTargetKey, client, workspaceId, sessionId, runApproval],
|
|
86
114
|
);
|
|
87
115
|
|
|
88
116
|
const approve = useCallback(
|