@tangle-network/agent-app 0.53.3 → 0.53.4
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/assistant/AssistantDock.d.ts +7 -5
- package/dist/assistant/index.d.ts +2 -1
- package/dist/assistant/index.js +86 -39
- package/dist/assistant/index.js.map +1 -1
- package/dist/assistant/launcher.d.ts +29 -7
- package/dist/assistant/page-context.d.ts +2 -1
- package/dist/assistant/usePanelPrefs.d.ts +33 -11
- package/dist/chat-react/index.js +1 -1
- package/dist/{chunk-36ZV7KIP.js → chunk-7HMDNSIA.js} +3 -2
- package/dist/chunk-7HMDNSIA.js.map +1 -0
- package/dist/web-react/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-36ZV7KIP.js.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The assistant's place in the app shell: a right-side panel that mirrors the
|
|
3
3
|
* left sidebar. A panel toggle opens and closes it (top right while closed,
|
|
4
|
-
* the header's inner edge while open) and ⌘E / Ctrl+E does the same.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* the header's inner edge while open) and ⌘E / Ctrl+E does the same. Wherever
|
|
5
|
+
* the page keeps a usable column beside it (the launcher's `reservedWidth` and
|
|
6
|
+
* `dockMediaQuery` say what the host's chrome takes), the panel docks beside
|
|
7
|
+
* the page: it is non-modal, resizable, and the launcher's `inset` tells the
|
|
8
|
+
* shell how far to pad its page column so the panel never covers page content.
|
|
9
|
+
* Where it would not fit, it opens as a modal sheet, full screen on phones.
|
|
10
|
+
* Width and open state persist per user.
|
|
9
11
|
*
|
|
10
12
|
* The dock owns the chat state (via useAssistantChat) so the conversation
|
|
11
13
|
* survives the panel closing. Host-shell concerns (the user, navigation,
|
|
@@ -18,6 +18,7 @@ export { AssistantDock, type AssistantDockProps } from "./AssistantDock";
|
|
|
18
18
|
export { AssistantPanel, type AssistantPanelProps } from "./AssistantPanel";
|
|
19
19
|
export { AssistantTranscript, type AssistantTranscriptProps, type AssistantTimelineOptions, buildAssistantTimeline, assistantIsThinking, } from "./transcript";
|
|
20
20
|
export { ProposalCard, type ProposalCardProps } from "./ProposalCard";
|
|
21
|
-
export { AssistantLauncherProvider, useAssistantLauncher, type AssistantLauncher, type AssistantPanelLayout, } from "./launcher";
|
|
21
|
+
export { AssistantLauncherProvider, useAssistantLauncher, useAssistantPageLabel, type AssistantLauncher, type AssistantPanelLayout, } from "./launcher";
|
|
22
|
+
export { MIN_PAGE_WIDTH, MIN_PANEL_WIDTH } from "./usePanelPrefs";
|
|
22
23
|
export { useDocumentPageContext, pageLabelFromTitle, type DocumentPageContextOptions, } from "./page-context";
|
|
23
24
|
export { AssistantPanelToggle, type AssistantPanelToggleProps, ASSISTANT_PANEL_ID, assistantShortcutLabel, } from "./panel-toggle";
|
package/dist/assistant/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import "../chunk-ENLRJYVW.js";
|
|
|
10
10
|
import "../chunk-GEYACSFW.js";
|
|
11
11
|
import {
|
|
12
12
|
ChatComposer
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-7HMDNSIA.js";
|
|
14
14
|
import "../chunk-L7MB2LLM.js";
|
|
15
15
|
import "../chunk-6FYFGQ6I.js";
|
|
16
16
|
import {
|
|
@@ -1925,8 +1925,17 @@ import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef3
|
|
|
1925
1925
|
var MIN_PANEL_WIDTH = 360;
|
|
1926
1926
|
var DEFAULT_PANEL_WIDTH = 480;
|
|
1927
1927
|
var MAX_PANEL_WIDTH = 800;
|
|
1928
|
-
var
|
|
1929
|
-
var
|
|
1928
|
+
var SHEET_MAX_WIDTH_FRACTION = 0.5;
|
|
1929
|
+
var MIN_PAGE_WIDTH = 400;
|
|
1930
|
+
var DEFAULT_RESERVED_WIDTH = 256;
|
|
1931
|
+
var DOCKED_MEDIA_QUERY = "(min-width: 64rem)";
|
|
1932
|
+
function canDock(viewportWidth, reservedWidth, hostAllows) {
|
|
1933
|
+
return hostAllows && viewportWidth - reservedWidth - MIN_PANEL_WIDTH >= MIN_PAGE_WIDTH;
|
|
1934
|
+
}
|
|
1935
|
+
var DEFAULT_GEOMETRY = {
|
|
1936
|
+
reservedWidth: DEFAULT_RESERVED_WIDTH,
|
|
1937
|
+
docked: true
|
|
1938
|
+
};
|
|
1930
1939
|
var LEGACY_WIDTH_KEY = "assistant.panel.width";
|
|
1931
1940
|
function prefsKey(userId) {
|
|
1932
1941
|
return userId ? `assistant:v1:${userId}:panel` : null;
|
|
@@ -1956,26 +1965,24 @@ function writePrefs(userId, next) {
|
|
|
1956
1965
|
} catch {
|
|
1957
1966
|
}
|
|
1958
1967
|
}
|
|
1959
|
-
function maxPanelWidth() {
|
|
1968
|
+
function maxPanelWidth(geometry) {
|
|
1960
1969
|
if (typeof window === "undefined") return MAX_PANEL_WIDTH;
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
Math.min(
|
|
1964
|
-
Math.round(window.innerWidth * MAX_PANEL_WIDTH_FRACTION),
|
|
1965
|
-
MAX_PANEL_WIDTH
|
|
1966
|
-
)
|
|
1967
|
-
);
|
|
1970
|
+
const room = geometry.docked ? window.innerWidth - geometry.reservedWidth - MIN_PAGE_WIDTH : Math.round(window.innerWidth * SHEET_MAX_WIDTH_FRACTION);
|
|
1971
|
+
return Math.max(MIN_PANEL_WIDTH, Math.min(room, MAX_PANEL_WIDTH));
|
|
1968
1972
|
}
|
|
1969
|
-
function clampWidth(value) {
|
|
1973
|
+
function clampWidth(value, geometry) {
|
|
1970
1974
|
return Math.min(
|
|
1971
1975
|
Math.max(Math.round(value), MIN_PANEL_WIDTH),
|
|
1972
|
-
maxPanelWidth()
|
|
1976
|
+
maxPanelWidth(geometry)
|
|
1973
1977
|
);
|
|
1974
1978
|
}
|
|
1975
|
-
function usePanelPrefs(userId) {
|
|
1979
|
+
function usePanelPrefs(userId, geometry = DEFAULT_GEOMETRY) {
|
|
1980
|
+
const { reservedWidth, docked } = geometry;
|
|
1981
|
+
const geometryRef = useRef3(geometry);
|
|
1982
|
+
geometryRef.current = { reservedWidth, docked };
|
|
1976
1983
|
const [storedOpen, setStoredOpen] = useState4(null);
|
|
1977
1984
|
const [width, setWidthState] = useState4(DEFAULT_PANEL_WIDTH);
|
|
1978
|
-
const [maxWidth, setMaxWidth] = useState4(() => maxPanelWidth());
|
|
1985
|
+
const [maxWidth, setMaxWidth] = useState4(() => maxPanelWidth(geometry));
|
|
1979
1986
|
const desiredRef = useRef3(DEFAULT_PANEL_WIDTH);
|
|
1980
1987
|
const userRef = useRef3(userId);
|
|
1981
1988
|
userRef.current = userId;
|
|
@@ -1986,32 +1993,33 @@ function usePanelPrefs(userId) {
|
|
|
1986
1993
|
Math.round(prefs.width ?? DEFAULT_PANEL_WIDTH),
|
|
1987
1994
|
MIN_PANEL_WIDTH
|
|
1988
1995
|
);
|
|
1989
|
-
setMaxWidth(maxPanelWidth());
|
|
1990
|
-
setWidthState(clampWidth(desiredRef.current));
|
|
1996
|
+
setMaxWidth(maxPanelWidth(geometryRef.current));
|
|
1997
|
+
setWidthState(clampWidth(desiredRef.current, geometryRef.current));
|
|
1991
1998
|
}, [userId]);
|
|
1992
1999
|
useEffect4(() => {
|
|
1993
|
-
const
|
|
1994
|
-
setMaxWidth(maxPanelWidth());
|
|
1995
|
-
setWidthState(clampWidth(desiredRef.current));
|
|
2000
|
+
const fit = () => {
|
|
2001
|
+
setMaxWidth(maxPanelWidth(geometryRef.current));
|
|
2002
|
+
setWidthState(clampWidth(desiredRef.current, geometryRef.current));
|
|
1996
2003
|
};
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2004
|
+
fit();
|
|
2005
|
+
window.addEventListener("resize", fit);
|
|
2006
|
+
return () => window.removeEventListener("resize", fit);
|
|
2007
|
+
}, [reservedWidth, docked]);
|
|
2000
2008
|
const persistOpen = useCallback3((open) => {
|
|
2001
2009
|
setStoredOpen(open);
|
|
2002
2010
|
writePrefs(userRef.current, { open });
|
|
2003
2011
|
}, []);
|
|
2004
2012
|
const setWidth = useCallback3((next) => {
|
|
2005
|
-
const clamped = clampWidth(next);
|
|
2013
|
+
const clamped = clampWidth(next, geometryRef.current);
|
|
2006
2014
|
desiredRef.current = clamped;
|
|
2007
2015
|
writePrefs(userRef.current, { width: clamped });
|
|
2008
2016
|
setWidthState(clamped);
|
|
2009
2017
|
}, []);
|
|
2010
2018
|
const previewWidth = useCallback3((next) => {
|
|
2011
|
-
setWidthState(clampWidth(next));
|
|
2019
|
+
setWidthState(clampWidth(next, geometryRef.current));
|
|
2012
2020
|
}, []);
|
|
2013
2021
|
const nudgeWidth = useCallback3((deltaPx) => {
|
|
2014
|
-
const clamped = clampWidth(desiredRef.current + deltaPx);
|
|
2022
|
+
const clamped = clampWidth(desiredRef.current + deltaPx, geometryRef.current);
|
|
2015
2023
|
desiredRef.current = clamped;
|
|
2016
2024
|
writePrefs(userRef.current, { width: clamped });
|
|
2017
2025
|
setWidthState(clamped);
|
|
@@ -2042,19 +2050,36 @@ function useMediaQuery(query, fallback = true) {
|
|
|
2042
2050
|
}, [query]);
|
|
2043
2051
|
return matches;
|
|
2044
2052
|
}
|
|
2053
|
+
function useViewportWidth() {
|
|
2054
|
+
const [width, setWidth] = useState4(
|
|
2055
|
+
() => typeof window === "undefined" ? Number.POSITIVE_INFINITY : window.innerWidth
|
|
2056
|
+
);
|
|
2057
|
+
useEffect4(() => {
|
|
2058
|
+
const update = () => setWidth(window.innerWidth);
|
|
2059
|
+
update();
|
|
2060
|
+
window.addEventListener("resize", update);
|
|
2061
|
+
return () => window.removeEventListener("resize", update);
|
|
2062
|
+
}, []);
|
|
2063
|
+
return width;
|
|
2064
|
+
}
|
|
2045
2065
|
|
|
2046
2066
|
// src/assistant/launcher.tsx
|
|
2047
2067
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
2048
2068
|
var AssistantLauncherContext = createContext2(null);
|
|
2049
2069
|
function AssistantLauncherProvider({
|
|
2050
2070
|
userId = null,
|
|
2071
|
+
reservedWidth = DEFAULT_RESERVED_WIDTH,
|
|
2072
|
+
dockMediaQuery = DOCKED_MEDIA_QUERY,
|
|
2051
2073
|
children
|
|
2052
2074
|
}) {
|
|
2053
2075
|
const [open, setOpen] = useState5(false);
|
|
2054
2076
|
const [seed, setSeed] = useState5(null);
|
|
2055
2077
|
const [openedOnLoad, setOpenedOnLoad] = useState5(false);
|
|
2056
|
-
const
|
|
2057
|
-
const
|
|
2078
|
+
const [pageLabel, setPageLabelState] = useState5(null);
|
|
2079
|
+
const hostAllowsDock = useMediaQuery(dockMediaQuery, true);
|
|
2080
|
+
const viewportWidth = useViewportWidth();
|
|
2081
|
+
const docked = canDock(viewportWidth, reservedWidth, hostAllowsDock);
|
|
2082
|
+
const prefs = usePanelPrefs(userId, { reservedWidth, docked });
|
|
2058
2083
|
const layout = docked ? "docked" : "sheet";
|
|
2059
2084
|
const { persistOpen, storedOpen } = prefs;
|
|
2060
2085
|
const restoredFor = useRef4(null);
|
|
@@ -2085,6 +2110,10 @@ function AssistantLauncherProvider({
|
|
|
2085
2110
|
persistOpen(!open);
|
|
2086
2111
|
}, [open, persistOpen]);
|
|
2087
2112
|
const clearSeed = useCallback4(() => setSeed(null), []);
|
|
2113
|
+
const setPageLabel = useCallback4(
|
|
2114
|
+
(update) => setPageLabelState(update),
|
|
2115
|
+
[]
|
|
2116
|
+
);
|
|
2088
2117
|
const { width, maxWidth, setWidth, previewWidth, nudgeWidth } = prefs;
|
|
2089
2118
|
const panel = useMemo2(
|
|
2090
2119
|
() => ({ width, maxWidth, setWidth, previewWidth, nudgeWidth }),
|
|
@@ -2102,7 +2131,9 @@ function AssistantLauncherProvider({
|
|
|
2102
2131
|
layout,
|
|
2103
2132
|
openedOnLoad,
|
|
2104
2133
|
inset,
|
|
2105
|
-
panel
|
|
2134
|
+
panel,
|
|
2135
|
+
pageLabel,
|
|
2136
|
+
setPageLabel
|
|
2106
2137
|
}),
|
|
2107
2138
|
[
|
|
2108
2139
|
open,
|
|
@@ -2114,7 +2145,9 @@ function AssistantLauncherProvider({
|
|
|
2114
2145
|
layout,
|
|
2115
2146
|
openedOnLoad,
|
|
2116
2147
|
inset,
|
|
2117
|
-
panel
|
|
2148
|
+
panel,
|
|
2149
|
+
pageLabel,
|
|
2150
|
+
setPageLabel
|
|
2118
2151
|
]
|
|
2119
2152
|
);
|
|
2120
2153
|
return /* @__PURE__ */ jsx3(AssistantLauncherContext.Provider, { value, children });
|
|
@@ -2131,6 +2164,15 @@ function useAssistantLauncher() {
|
|
|
2131
2164
|
}
|
|
2132
2165
|
return ctx;
|
|
2133
2166
|
}
|
|
2167
|
+
function useAssistantPageLabel(label) {
|
|
2168
|
+
const setPageLabel = useOptionalAssistantLauncher()?.setPageLabel;
|
|
2169
|
+
const trimmed = label?.trim() || null;
|
|
2170
|
+
useEffect5(() => {
|
|
2171
|
+
if (!setPageLabel || !trimmed) return;
|
|
2172
|
+
setPageLabel(() => trimmed);
|
|
2173
|
+
return () => setPageLabel((current) => current === trimmed ? null : current);
|
|
2174
|
+
}, [setPageLabel, trimmed]);
|
|
2175
|
+
}
|
|
2134
2176
|
|
|
2135
2177
|
// src/assistant/panel-toggle.tsx
|
|
2136
2178
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -2152,6 +2194,7 @@ function AssistantPanelToggle({
|
|
|
2152
2194
|
const open = openOverride ?? launcher?.open ?? false;
|
|
2153
2195
|
const toggleAssistant = onToggle ?? launcher?.toggleAssistant;
|
|
2154
2196
|
const label = open ? "Close assistant" : "Open assistant";
|
|
2197
|
+
const touch = useMediaQuery("(pointer: coarse)", false);
|
|
2155
2198
|
return /* @__PURE__ */ jsx4(
|
|
2156
2199
|
"button",
|
|
2157
2200
|
{
|
|
@@ -2162,7 +2205,7 @@ function AssistantPanelToggle({
|
|
|
2162
2205
|
"aria-expanded": open,
|
|
2163
2206
|
"aria-controls": open && launcher ? ASSISTANT_PANEL_ID : void 0,
|
|
2164
2207
|
"aria-keyshortcuts": "Meta+E Control+E",
|
|
2165
|
-
title: `${label} (${assistantShortcutLabel()})`,
|
|
2208
|
+
title: touch ? label : `${label} (${assistantShortcutLabel()})`,
|
|
2166
2209
|
style,
|
|
2167
2210
|
className: `flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--accent-surface-soft)] hover:text-foreground ${focusRing} ${className ?? ""}`,
|
|
2168
2211
|
children: /* @__PURE__ */ jsx4(PanelRight, { "aria-hidden": "true", className: "h-[18px] w-[18px] shrink-0" })
|
|
@@ -2555,7 +2598,7 @@ function AssistantTranscript({
|
|
|
2555
2598
|
[view, toolRenderers, renderConfirmedResult]
|
|
2556
2599
|
);
|
|
2557
2600
|
if (items.length === 0 && !view.isStreaming) return /* @__PURE__ */ jsx6(Fragment, { children: emptyState });
|
|
2558
|
-
return /* @__PURE__ */ jsx6(AgentTimeline, { items, isThinking: view.isThinking });
|
|
2601
|
+
return /* @__PURE__ */ jsx6(AgentTimeline, { items, isThinking: view.isThinking, className: "px-6" });
|
|
2559
2602
|
}
|
|
2560
2603
|
|
|
2561
2604
|
// src/assistant/use-stick-to-bottom.ts
|
|
@@ -2666,9 +2709,9 @@ function FirstRun({
|
|
|
2666
2709
|
onPick
|
|
2667
2710
|
}) {
|
|
2668
2711
|
const starters = hasPage ? [PAGE_STARTER, ...STARTERS] : STARTERS;
|
|
2669
|
-
return /* @__PURE__ */ jsxs4("div", { className: "px-
|
|
2670
|
-
/* @__PURE__ */ jsx7("h3", { className: "font-semibold text-[var(--font-size-lg)] text-foreground leading-snug", children: "What should the assistant do?" }),
|
|
2671
|
-
/* @__PURE__ */ jsx7("p", { className: "mt-1.5 text-[var(--font-size-base)] text-muted-foreground leading-[1.5]", children: "It creates workflows, checks usage, and manages API keys. Changes wait for your approval." }),
|
|
2712
|
+
return /* @__PURE__ */ jsxs4("div", { className: "px-6 pt-6 pb-4", children: [
|
|
2713
|
+
/* @__PURE__ */ jsx7("h3", { className: "font-semibold text-[length:var(--font-size-lg)] text-foreground leading-snug", children: "What should the assistant do?" }),
|
|
2714
|
+
/* @__PURE__ */ jsx7("p", { className: "mt-1.5 text-[length:var(--font-size-base)] text-muted-foreground leading-[1.5]", children: "It creates workflows, checks usage, and manages API keys. Changes wait for your approval." }),
|
|
2672
2715
|
/* @__PURE__ */ jsx7("ul", { className: "mt-5 flex flex-col gap-2", children: starters.map((starter) => /* @__PURE__ */ jsx7("li", { children: /* @__PURE__ */ jsxs4(
|
|
2673
2716
|
"button",
|
|
2674
2717
|
{
|
|
@@ -2849,7 +2892,7 @@ function AssistantPanel({
|
|
|
2849
2892
|
layout === "docked" && /* @__PURE__ */ jsx7(AssistantPanelToggle, { open: true, onToggle: onClose, buttonRef: toggleRef }),
|
|
2850
2893
|
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 flex-col justify-center", children: [
|
|
2851
2894
|
/* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 items-baseline gap-2", children: [
|
|
2852
|
-
/* @__PURE__ */ jsx7("h2", { className: "truncate font-semibold text-[var(--font-size-base)] text-foreground leading-tight", children: "Assistant" }),
|
|
2895
|
+
/* @__PURE__ */ jsx7("h2", { className: "truncate font-semibold text-[length:var(--font-size-base)] text-foreground leading-tight", children: "Assistant" }),
|
|
2853
2896
|
effectiveBalance != null && /* @__PURE__ */ jsx7(
|
|
2854
2897
|
"span",
|
|
2855
2898
|
{
|
|
@@ -3273,7 +3316,7 @@ function AssistantDock({
|
|
|
3273
3316
|
tabIndex: -1,
|
|
3274
3317
|
onKeyDown: trapTab,
|
|
3275
3318
|
style: { width: wideSheet ? `min(${width}px, 100vw)` : "100%" },
|
|
3276
|
-
className:
|
|
3319
|
+
className: `fixed inset-y-0 right-0 z-50 flex flex-col shadow-[var(--shadow-overlay)] focus:outline-none ${wideSheet ? "border-border border-l" : ""}`,
|
|
3277
3320
|
children: panel
|
|
3278
3321
|
}
|
|
3279
3322
|
)
|
|
@@ -3337,12 +3380,13 @@ function useDocumentPageContext({
|
|
|
3337
3380
|
ids
|
|
3338
3381
|
}) {
|
|
3339
3382
|
const title = useDocumentTitle();
|
|
3383
|
+
const pageLabel = useOptionalAssistantLauncher()?.pageLabel ?? null;
|
|
3340
3384
|
return useMemo5(() => {
|
|
3341
|
-
const label = pageLabelFromTitle(title, titleSuffix, ignoreTitles);
|
|
3385
|
+
const label = (pageLabel && pageLabelFromTitle(pageLabel)) ?? pageLabelFromTitle(title, titleSuffix, ignoreTitles);
|
|
3342
3386
|
if (!label) return null;
|
|
3343
3387
|
const pageIds = ids?.(path);
|
|
3344
3388
|
return { label, path, ...pageIds ? { ids: pageIds } : {} };
|
|
3345
|
-
}, [title, path, titleSuffix, ignoreTitles, ids]);
|
|
3389
|
+
}, [pageLabel, title, path, titleSuffix, ignoreTitles, ids]);
|
|
3346
3390
|
}
|
|
3347
3391
|
export {
|
|
3348
3392
|
ASSISTANT_PANEL_ID,
|
|
@@ -3353,6 +3397,8 @@ export {
|
|
|
3353
3397
|
AssistantPanel,
|
|
3354
3398
|
AssistantPanelToggle,
|
|
3355
3399
|
AssistantTranscript,
|
|
3400
|
+
MIN_PAGE_WIDTH,
|
|
3401
|
+
MIN_PANEL_WIDTH,
|
|
3356
3402
|
ProposalCard,
|
|
3357
3403
|
assistantIsThinking,
|
|
3358
3404
|
assistantShortcutLabel,
|
|
@@ -3363,6 +3409,7 @@ export {
|
|
|
3363
3409
|
useAssistantClient,
|
|
3364
3410
|
useAssistantLauncher,
|
|
3365
3411
|
useAssistantModels,
|
|
3412
|
+
useAssistantPageLabel,
|
|
3366
3413
|
useAssistantThreads,
|
|
3367
3414
|
useDocumentPageContext
|
|
3368
3415
|
};
|