@invergent/agent-chat-react 2.0.1 → 2.0.2
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/dist/index.cjs +104 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +105 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5982,7 +5982,13 @@ function ChatComposerInner({
|
|
|
5982
5982
|
disabled = false,
|
|
5983
5983
|
disabledReason,
|
|
5984
5984
|
tokenUsage,
|
|
5985
|
-
onComposerError
|
|
5985
|
+
onComposerError,
|
|
5986
|
+
showBrowser = false,
|
|
5987
|
+
onToggleBrowser,
|
|
5988
|
+
showWorkspace = false,
|
|
5989
|
+
onToggleWorkspace,
|
|
5990
|
+
canShowBrowser = false,
|
|
5991
|
+
canShowWorkspace = false
|
|
5986
5992
|
}) {
|
|
5987
5993
|
const { adapter } = useAgentChatAdapterContext();
|
|
5988
5994
|
const { textInput, attachments } = usePromptInputController();
|
|
@@ -6289,6 +6295,28 @@ function ChatComposerInner({
|
|
|
6289
6295
|
}
|
|
6290
6296
|
)
|
|
6291
6297
|
] }),
|
|
6298
|
+
canShowBrowser && onToggleBrowser && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6299
|
+
PromptInputButton,
|
|
6300
|
+
{
|
|
6301
|
+
"aria-label": showBrowser ? "Hide browser pane" : "Show browser pane",
|
|
6302
|
+
"aria-pressed": showBrowser,
|
|
6303
|
+
onClick: onToggleBrowser,
|
|
6304
|
+
tooltip: showBrowser ? "Hide browser pane" : "Show browser pane",
|
|
6305
|
+
className: showBrowser ? "bg-accent text-foreground" : void 0,
|
|
6306
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GlobeIcon, { className: "size-4" })
|
|
6307
|
+
}
|
|
6308
|
+
),
|
|
6309
|
+
canShowWorkspace && onToggleWorkspace && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6310
|
+
PromptInputButton,
|
|
6311
|
+
{
|
|
6312
|
+
"aria-label": showWorkspace ? "Hide workspace pane" : "Show workspace pane",
|
|
6313
|
+
"aria-pressed": showWorkspace,
|
|
6314
|
+
onClick: onToggleWorkspace,
|
|
6315
|
+
tooltip: showWorkspace ? "Hide workspace pane" : "Show workspace pane",
|
|
6316
|
+
className: showWorkspace ? "bg-accent text-foreground" : void 0,
|
|
6317
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FolderIcon, { className: "size-4" })
|
|
6318
|
+
}
|
|
6319
|
+
),
|
|
6292
6320
|
tokenUsage && tokenUsage.contextWindow > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6293
6321
|
Context,
|
|
6294
6322
|
{
|
|
@@ -7517,7 +7545,13 @@ function ChatThread({
|
|
|
7517
7545
|
tokenUsage,
|
|
7518
7546
|
retryIndicator,
|
|
7519
7547
|
onRetry,
|
|
7520
|
-
onComposerError
|
|
7548
|
+
onComposerError,
|
|
7549
|
+
showBrowser = false,
|
|
7550
|
+
onToggleBrowser,
|
|
7551
|
+
showWorkspace = false,
|
|
7552
|
+
onToggleWorkspace,
|
|
7553
|
+
canShowBrowser = false,
|
|
7554
|
+
canShowWorkspace = false
|
|
7521
7555
|
}) {
|
|
7522
7556
|
const groups = react.useMemo(() => groupMessages(messages), [messages]);
|
|
7523
7557
|
const artifactFallbacks = react.useMemo(() => {
|
|
@@ -7634,7 +7668,13 @@ function ChatThread({
|
|
|
7634
7668
|
disabled,
|
|
7635
7669
|
disabledReason,
|
|
7636
7670
|
tokenUsage,
|
|
7637
|
-
onComposerError
|
|
7671
|
+
onComposerError,
|
|
7672
|
+
showBrowser,
|
|
7673
|
+
onToggleBrowser,
|
|
7674
|
+
showWorkspace,
|
|
7675
|
+
onToggleWorkspace,
|
|
7676
|
+
canShowBrowser,
|
|
7677
|
+
canShowWorkspace
|
|
7638
7678
|
}
|
|
7639
7679
|
)
|
|
7640
7680
|
] })
|
|
@@ -9580,6 +9620,16 @@ function useAgentChatRuntime({
|
|
|
9580
9620
|
}));
|
|
9581
9621
|
}
|
|
9582
9622
|
}).catch(() => void 0);
|
|
9623
|
+
void adapter.getBrowserState(sessionId).then((browserState) => {
|
|
9624
|
+
if (sessionIdRef.current !== sessionId) return;
|
|
9625
|
+
setState((prev) => ({
|
|
9626
|
+
...prev,
|
|
9627
|
+
browser: browserState ? {
|
|
9628
|
+
status: browserState.status,
|
|
9629
|
+
controlOwner: browserState.controlOwner ?? null
|
|
9630
|
+
} : null
|
|
9631
|
+
}));
|
|
9632
|
+
}).catch(() => void 0);
|
|
9583
9633
|
return () => {
|
|
9584
9634
|
clearReconnectTimer();
|
|
9585
9635
|
closeStream();
|
|
@@ -9824,6 +9874,8 @@ function AgentChat({
|
|
|
9824
9874
|
}) {
|
|
9825
9875
|
const [workspacePath, setWorkspacePath] = react.useState(null);
|
|
9826
9876
|
const [mobileView, setMobileView] = react.useState("chat");
|
|
9877
|
+
const [showBrowser, setShowBrowser] = react.useState(true);
|
|
9878
|
+
const [showWorkspace, setShowWorkspace] = react.useState(true);
|
|
9827
9879
|
const runtime = useAgentChatRuntime({
|
|
9828
9880
|
adapter,
|
|
9829
9881
|
agentId,
|
|
@@ -9834,7 +9886,12 @@ function AgentChat({
|
|
|
9834
9886
|
const effectiveDisabled = disabled || isReadOnlySession;
|
|
9835
9887
|
const disabledReason = isReadOnlySession ? "Scheduled run is read-only" : void 0;
|
|
9836
9888
|
const browserState = runtime.state.browser;
|
|
9837
|
-
const
|
|
9889
|
+
const browserAvailable = browserState !== null && browserState.status !== "closed" && !!sessionId;
|
|
9890
|
+
const browserVisible = browserAvailable && showBrowser;
|
|
9891
|
+
const workspaceAvailable = !!sessionId;
|
|
9892
|
+
const workspaceVisible = workspaceAvailable && showWorkspace;
|
|
9893
|
+
const rightStackVisible = browserVisible || workspaceVisible;
|
|
9894
|
+
const bothPanesVisible = browserVisible && workspaceVisible;
|
|
9838
9895
|
react.useEffect(() => {
|
|
9839
9896
|
onMessagesChange?.(runtime.messages);
|
|
9840
9897
|
}, [onMessagesChange, runtime.messages]);
|
|
@@ -9842,11 +9899,18 @@ function AgentChat({
|
|
|
9842
9899
|
(path) => {
|
|
9843
9900
|
setWorkspacePath(path);
|
|
9844
9901
|
setMobileView("workspace");
|
|
9902
|
+
setShowWorkspace(true);
|
|
9845
9903
|
onFileSelect?.(path);
|
|
9846
9904
|
},
|
|
9847
9905
|
[onFileSelect]
|
|
9848
9906
|
);
|
|
9849
|
-
const
|
|
9907
|
+
const handleToggleBrowser = react.useCallback(() => {
|
|
9908
|
+
setShowBrowser((prev) => !prev);
|
|
9909
|
+
}, []);
|
|
9910
|
+
const handleToggleWorkspace = react.useCallback(() => {
|
|
9911
|
+
setShowWorkspace((prev) => !prev);
|
|
9912
|
+
}, []);
|
|
9913
|
+
const showMobileToggle = rightStackVisible;
|
|
9850
9914
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9851
9915
|
AgentChatAdapterProvider,
|
|
9852
9916
|
{
|
|
@@ -9864,8 +9928,11 @@ function AgentChat({
|
|
|
9864
9928
|
// Phone: flex column, tab toggle on top, then either chat or
|
|
9865
9929
|
// right stack visible based on `data-mobile-view`.
|
|
9866
9930
|
"flex min-h-0 flex-1 flex-col overflow-hidden bg-background text-sm text-foreground",
|
|
9867
|
-
// md+: restore desktop two-pane layout
|
|
9868
|
-
|
|
9931
|
+
// md+: restore desktop two-pane layout when the right stack
|
|
9932
|
+
// is visible. With both panes, absolute positioning lets the
|
|
9933
|
+
// browser/workspace split occupy a fixed width. Without the
|
|
9934
|
+
// right stack, the chat takes the full width.
|
|
9935
|
+
browserVisible ? "md:relative md:flex-row" : "md:flex-row"
|
|
9869
9936
|
),
|
|
9870
9937
|
style: { direction: "ltr", ...RIGHT_STACK_STYLE },
|
|
9871
9938
|
children: [
|
|
@@ -9906,8 +9973,13 @@ function AgentChat({
|
|
|
9906
9973
|
// Phone: full width column, hidden when workspace tab active.
|
|
9907
9974
|
"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
|
|
9908
9975
|
showMobileToggle && "data-[mobile-view=workspace]:hidden md:flex!",
|
|
9909
|
-
// md+:
|
|
9910
|
-
|
|
9976
|
+
// md+: positioning depends on whether the browser/workspace
|
|
9977
|
+
// right stack is laid out. When the browser pane is shown
|
|
9978
|
+
// we pin a fixed-width column on the right and absolutely
|
|
9979
|
+
// position the chat panel beside it. Otherwise the chat
|
|
9980
|
+
// panel just flexes alongside the workspace (or fills the
|
|
9981
|
+
// space when nothing else is visible).
|
|
9982
|
+
browserVisible ? "md:absolute md:inset-y-0 md:left-0 md:right-(--right-stack-w,440px) md:flex" : "md:relative md:flex-1"
|
|
9911
9983
|
),
|
|
9912
9984
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9913
9985
|
ChatThread,
|
|
@@ -9924,12 +9996,18 @@ function AgentChat({
|
|
|
9924
9996
|
disabledReason,
|
|
9925
9997
|
tokenUsage: runtime.tokenUsage,
|
|
9926
9998
|
retryIndicator: runtime.retryIndicator,
|
|
9927
|
-
onComposerError
|
|
9999
|
+
onComposerError,
|
|
10000
|
+
showBrowser,
|
|
10001
|
+
onToggleBrowser: handleToggleBrowser,
|
|
10002
|
+
showWorkspace,
|
|
10003
|
+
onToggleWorkspace: handleToggleWorkspace,
|
|
10004
|
+
canShowBrowser: browserAvailable,
|
|
10005
|
+
canShowWorkspace: workspaceAvailable
|
|
9928
10006
|
}
|
|
9929
10007
|
)
|
|
9930
10008
|
}
|
|
9931
10009
|
),
|
|
9932
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10010
|
+
rightStackVisible && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9933
10011
|
"div",
|
|
9934
10012
|
{
|
|
9935
10013
|
"data-testid": "right-stack",
|
|
@@ -9938,17 +10016,23 @@ function AgentChat({
|
|
|
9938
10016
|
// Phone: full width column, hidden when chat tab active.
|
|
9939
10017
|
"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",
|
|
9940
10018
|
showMobileToggle && "data-[mobile-view=chat]:hidden md:flex!",
|
|
9941
|
-
// md+:
|
|
9942
|
-
//
|
|
9943
|
-
//
|
|
9944
|
-
|
|
10019
|
+
// md+: positioning differs depending on what is inside.
|
|
10020
|
+
// - browser visible (with or without workspace): absolute
|
|
10021
|
+
// right column at the configured width.
|
|
10022
|
+
// - workspace only: relative shrink-0 column letting
|
|
10023
|
+
// WorkspacePanel manage its own width via the resize
|
|
10024
|
+
// handle.
|
|
10025
|
+
browserVisible ? "md:absolute md:inset-y-0 md:right-0 md:w-(--right-stack-w,440px) md:flex-none" : "md:relative md:shrink-0 md:flex-none md:w-auto"
|
|
9945
10026
|
),
|
|
9946
10027
|
children: [
|
|
9947
|
-
|
|
10028
|
+
browserVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9948
10029
|
"div",
|
|
9949
10030
|
{
|
|
9950
10031
|
"data-testid": "browser-panel",
|
|
9951
|
-
className:
|
|
10032
|
+
className: cn(
|
|
10033
|
+
"min-h-0 w-full overflow-hidden",
|
|
10034
|
+
bothPanesVisible ? "h-1/2 border-b border-line" : "h-full"
|
|
10035
|
+
),
|
|
9952
10036
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9953
10037
|
BrowserPane,
|
|
9954
10038
|
{
|
|
@@ -9959,11 +10043,11 @@ function AgentChat({
|
|
|
9959
10043
|
)
|
|
9960
10044
|
}
|
|
9961
10045
|
),
|
|
9962
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10046
|
+
workspaceVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9963
10047
|
"div",
|
|
9964
10048
|
{
|
|
9965
10049
|
"data-testid": "workspace-panel-frame",
|
|
9966
|
-
className:
|
|
10050
|
+
className: bothPanesVisible ? "h-1/2 min-h-0 w-full overflow-hidden" : "min-h-0 h-full",
|
|
9967
10051
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9968
10052
|
WorkspacePanel,
|
|
9969
10053
|
{
|
|
@@ -9973,7 +10057,7 @@ function AgentChat({
|
|
|
9973
10057
|
onSelectedPathChange: setWorkspacePath,
|
|
9974
10058
|
refreshSignal: runtime.workspaceRefreshKey,
|
|
9975
10059
|
disabled: effectiveDisabled,
|
|
9976
|
-
fillParent:
|
|
10060
|
+
fillParent: bothPanesVisible
|
|
9977
10061
|
}
|
|
9978
10062
|
)
|
|
9979
10063
|
}
|