zidane-ui 9.3.1 → 9.4.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/dist/adapters/live.d.ts +2 -0
- package/dist/adapters/live.js +3 -0
- package/dist/adapters/server-git-host.js +5 -2
- package/dist/adapters/server-host.js +17 -11
- package/dist/adapters/server-machines-host.js +7 -0
- package/dist/adapters/server-session-host.js +49 -0
- package/dist/adapters/server-settings-sections.js +4 -1
- package/dist/adapters/sse-host.js +3 -0
- package/dist/adapters/sse-protocol.d.ts +10 -0
- package/dist/appearance/ZoomIndicator.js +5 -8
- package/dist/chat/HostTranscript.js +15 -1
- package/dist/chat/SessionStreamsProvider.d.ts +1 -1
- package/dist/chat/Transcript.d.ts +3 -2
- package/dist/chat/Transcript.js +26 -7
- package/dist/chat/composer/ComposerEditor.js +1 -1
- package/dist/chat/composer/ModelOptionsPicker.js +6 -2
- package/dist/chat/composer/ModelPicker.d.ts +1 -1
- package/dist/chat/composer/PlacePicker.d.ts +3 -1
- package/dist/chat/composer/PlacePicker.js +5 -1
- package/dist/chat/composer/use-draft-target.js +15 -3
- package/dist/chat/headless/block-runs.js +26 -1
- package/dist/chat/headless/chip-views.js +1 -1
- package/dist/chat/headless/draft-target.d.ts +28 -1
- package/dist/chat/headless/draft-target.js +22 -1
- package/dist/chat/headless/hosts.d.ts +4 -0
- package/dist/chat/headless/index.d.ts +25 -25
- package/dist/chat/headless/index.js +6 -6
- package/dist/chat/headless/markdown-scan.d.ts +0 -2
- package/dist/chat/headless/markdown-scan.js +3 -8
- package/dist/chat/headless/markdown-stream.js +3 -3
- package/dist/chat/headless/prompt-origin.d.ts +2 -0
- package/dist/chat/headless/prompt-origin.js +6 -2
- package/dist/chat/headless/sidebar/directory.d.ts +10 -1
- package/dist/chat/headless/sidebar/directory.js +9 -1
- package/dist/chat/headless/sidebar/environment.d.ts +15 -4
- package/dist/chat/headless/sidebar/environment.js +27 -9
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/index.js +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +9 -2
- package/dist/chat/headless/sidebar/labels.js +8 -1
- package/dist/chat/headless/streams/actions.d.ts +2 -2
- package/dist/chat/headless/streams/actions.js +1 -1
- package/dist/chat/headless/streams/event-bytes.d.ts +12 -1
- package/dist/chat/headless/streams/event-bytes.js +13 -1
- package/dist/chat/headless/streams/store.d.ts +21 -5
- package/dist/chat/headless/streams/store.js +36 -7
- package/dist/chat/headless/streams/transcript-map.js +2 -5
- package/dist/chat/headless/streams/types.d.ts +2 -1
- package/dist/chat/headless/transcript/collapse.js +3 -0
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat/index.js +2 -2
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.js +2 -2
- package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
- package/dist/chat/sidebar/SessionSidebar.js +23 -16
- package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
- package/dist/chat/sidebar/SidebarFold.js +17 -16
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
- package/dist/chat/sidebar/session-menu.d.ts +4 -0
- package/dist/chat/sidebar/session-menu.js +14 -2
- package/dist/chat/sidebar/sidebar-live.js +28 -4
- package/dist/chat/sidebar/useInboxRows.js +6 -6
- package/dist/chat/sidebar/useInboxTriage.js +50 -47
- package/dist/chat/sidebar/useSessionSearch.js +19 -18
- package/dist/chat/transcript/FileChip.js +28 -0
- package/dist/chat/transcript/LazyRow.d.ts +1 -1
- package/dist/chat/transcript/LazyRow.js +3 -4
- package/dist/chat/transcript/PromptEcho.js +3 -11
- package/dist/chat/transcript/SessionChip.d.ts +11 -0
- package/dist/chat/transcript/SessionChip.js +34 -0
- package/dist/chat/transcript/TranscriptRail.d.ts +1 -1
- package/dist/chat/transcript/chip-details.d.ts +11 -0
- package/dist/chat/transcript/chip-details.js +17 -1
- package/dist/chat/transcript/fold-worker.js +2 -1
- package/dist/chat/transcript/fold.js +11 -3
- package/dist/chat/transcript/index.d.ts +2 -2
- package/dist/chat/transcript/index.js +2 -2
- package/dist/chat/transcript/markdown-cache.d.ts +10 -1
- package/dist/chat/transcript/markdown-cache.js +37 -4
- package/dist/chat/transcript/markdown.js +27 -34
- package/dist/chat/transcript/media-gallery.js +13 -16
- package/dist/chat/transcript/messages.js +5 -4
- package/dist/chat/transcript/prompt.d.ts +1 -1
- package/dist/chat/transcript/row-mount.d.ts +27 -8
- package/dist/chat/transcript/row-mount.js +114 -80
- package/dist/chat/transcript/row-parking.d.ts +27 -0
- package/dist/chat/transcript/row-parking.js +37 -1
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/tool-parts.js +0 -1
- package/dist/chat/transcript/use-transcript-rows.d.ts +1 -1
- package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
- package/dist/chat/transcript/useHistoryBackfill.js +170 -0
- package/dist/chat/transcript/useTranscriptFind.js +2 -4
- package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
- package/dist/chat/transcript/useTranscriptScroll.js +12 -1
- package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
- package/dist/chat/transcript/useTranscriptSearch.js +6 -6
- package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
- package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
- package/dist/code/editor/FileTree.d.ts +2 -0
- package/dist/code/editor/FileTree.js +1 -1
- package/dist/code/editor/FileView.js +16 -25
- package/dist/code/editor/find/useFind.js +17 -17
- package/dist/code/editor/useCodeDocument.js +22 -19
- package/dist/code/editor/useDetachCleanup.js +4 -3
- package/dist/code/use-highlighted-html.js +12 -13
- package/dist/components/IconButton.d.ts +3 -1
- package/dist/components/IconButton.js +7 -2
- package/dist/components/IconButtonTip.d.ts +3 -1
- package/dist/components/IconButtonTip.js +2 -1
- package/dist/components/RowActionsMenu.js +7 -14
- package/dist/components/Tooltip.d.ts +4 -1
- package/dist/components/Tooltip.js +8 -6
- package/dist/components/assign-ref.d.ts +8 -0
- package/dist/components/assign-ref.js +12 -0
- package/dist/components/floating/FloatingSurface.js +2 -2
- package/dist/components/floating/HoverCard.js +32 -14
- package/dist/components/floating/Popover.js +4 -7
- package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
- package/dist/components/floating/useAnchoredPosition.js +7 -7
- package/dist/components/object-key.d.ts +7 -0
- package/dist/components/object-key.js +18 -0
- package/dist/components/palette/PaletteList.js +2 -7
- package/dist/components/tooltip-arming.d.ts +3 -0
- package/dist/components/tooltip-arming.js +8 -1
- package/dist/core.css +3 -3
- package/dist/dist/{index-C6-t1SS9.d.ts → index-BheVJOLc.d.ts} +1 -0
- package/dist/dist/index.d.ts +2 -2
- package/dist/files/FilesTab.js +0 -1
- package/dist/files/TreeColumn.d.ts +2 -4
- package/dist/files/TreeColumn.js +0 -5
- package/dist/files/headless/host.d.ts +3 -7
- package/dist/files/headless/labels.d.ts +0 -1
- package/dist/files/headless/labels.js +0 -1
- package/dist/files/headless/workspace-diff.js +1 -1
- package/dist/files/useCodeReview.js +1 -3
- package/dist/files/useFilesDiagnostics.d.ts +1 -1
- package/dist/files/useFilesDiagnostics.js +4 -11
- package/dist/files/useOpenFiles.js +9 -12
- package/dist/files/useWorkspace.d.ts +5 -7
- package/dist/files/useWorkspace.js +4 -15
- package/dist/git/GitBar.js +5 -3
- package/dist/git/MoveSessionDialog.d.ts +18 -8
- package/dist/git/MoveSessionDialog.js +32 -53
- package/dist/git/MoveToDialog.d.ts +61 -0
- package/dist/git/MoveToDialog.js +240 -0
- package/dist/git/SandboxManager.js +9 -4
- package/dist/git/SyncChip.js +11 -4
- package/dist/git/TeleportSessionDialog.d.ts +69 -0
- package/dist/git/TeleportSessionDialog.js +440 -0
- package/dist/git/headless/host.d.ts +14 -0
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +44 -1
- package/dist/git/headless/labels.js +50 -0
- package/dist/git/headless/sandboxes.d.ts +1 -1
- package/dist/git/headless/sandboxes.js +4 -3
- package/dist/git/headless/teleport.d.ts +76 -0
- package/dist/git/headless/teleport.js +19 -0
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +4 -2
- package/dist/git/useEnvironmentChoices.d.ts +5 -2
- package/dist/git/useEnvironmentChoices.js +12 -4
- package/dist/hooks/useLatest.d.ts +8 -0
- package/dist/hooks/useLatest.js +17 -0
- package/dist/hooks/useMinuteTick.d.ts +6 -2
- package/dist/hooks/useMinuteTick.js +12 -6
- package/dist/hooks/useNearViewport.js +11 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/keybindings/KeybindingsProvider.js +3 -4
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +18 -0
- package/dist/machines/AddServerForm.js +55 -3
- package/dist/machines/Banners.d.ts +2 -2
- package/dist/machines/Banners.js +3 -3
- package/dist/machines/DaemonMenu.js +1 -3
- package/dist/machines/HostsSection.js +5 -1
- package/dist/machines/OrganizationPanel.d.ts +25 -0
- package/dist/machines/OrganizationPanel.js +266 -0
- package/dist/machines/PersonalLayerPanel.d.ts +32 -0
- package/dist/machines/PersonalLayerPanel.js +360 -0
- package/dist/machines/headless/fixture-host.d.ts +10 -0
- package/dist/machines/headless/fixture-host.js +44 -0
- package/dist/machines/headless/host.d.ts +21 -1
- package/dist/machines/headless/index.d.ts +3 -1
- package/dist/machines/headless/index.js +3 -1
- package/dist/machines/headless/labels.d.ts +55 -0
- package/dist/machines/headless/labels.js +58 -1
- package/dist/machines/headless/layer.d.ts +64 -0
- package/dist/machines/headless/layer.js +56 -0
- package/dist/machines/headless/organization.d.ts +38 -0
- package/dist/machines/headless/organization.js +44 -0
- package/dist/machines/index.d.ts +3 -1
- package/dist/machines/index.js +3 -1
- package/dist/machines/testing/contract.d.ts +25 -1
- package/dist/machines/testing/contract.js +97 -1
- package/dist/motion/grow.js +12 -13
- package/dist/motion/swap.js +2 -5
- package/dist/motion/use-flip-list.d.ts +14 -0
- package/dist/motion/use-flip-list.js +17 -12
- package/dist/palette/headless/app-sources.js +37 -0
- package/dist/palette/headless/labels.js +3 -0
- package/dist/server/sse-handler.js +25 -2
- package/dist/session/DiffFileTree.js +1 -4
- package/dist/session/OpenSessionsDialog.d.ts +46 -0
- package/dist/session/OpenSessionsDialog.js +170 -0
- package/dist/session/PlanTracker.js +1 -2
- package/dist/session/ProjectHome.js +10 -9
- package/dist/session/RemindersPanel.js +10 -12
- package/dist/session/SecretsPanel.js +2 -1
- package/dist/session/SessionPeopleStack.d.ts +23 -0
- package/dist/session/SessionPeopleStack.js +65 -0
- package/dist/session/SessionPlaceMenu.js +5 -4
- package/dist/session/ShareSessionDialog.d.ts +32 -0
- package/dist/session/ShareSessionDialog.js +342 -0
- package/dist/session/TypingLine.d.ts +22 -0
- package/dist/session/TypingLine.js +31 -0
- package/dist/session/headless/host.d.ts +40 -1
- package/dist/session/headless/index.d.ts +4 -2
- package/dist/session/headless/index.js +3 -1
- package/dist/session/headless/labels.d.ts +49 -0
- package/dist/session/headless/labels.js +56 -0
- package/dist/session/headless/people.d.ts +29 -0
- package/dist/session/headless/people.js +53 -0
- package/dist/session/headless/place.d.ts +5 -0
- package/dist/session/headless/place.js +5 -1
- package/dist/session/headless/typing.d.ts +37 -0
- package/dist/session/headless/typing.js +60 -0
- package/dist/session/index.d.ts +5 -1
- package/dist/session/index.js +5 -1
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/headless/sections-host.d.ts +7 -2
- package/dist/settings/section.d.ts +15 -3
- package/dist/settings/section.js +15 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
- package/dist/settings/sections/keybindings/labels.d.ts +3 -0
- package/dist/settings/sections/keybindings/labels.js +3 -0
- package/dist/settings/sections/keybindings/rows.js +12 -0
- package/dist/settings/sections/logs/LogsSection.js +5 -8
- package/dist/styles.css +32 -7
- package/dist/terminal/HostTerminalSurface.js +28 -30
- package/dist/terminal/TerminalPanel.js +4 -12
- package/dist/terminal/TerminalProvider.d.ts +10 -2
- package/dist/terminal/TerminalProvider.js +10 -2
- package/dist/terminal/headless/labels.d.ts +0 -1
- package/dist/terminal/headless/labels.js +1 -2
- package/dist/terminal/headless/store.js +5 -1
- package/dist/workspace/LayoutBudget.js +1 -7
- package/package.json +2 -2
- package/src/styles/chat.css +3 -1
- package/src/styles/palette.css +3 -3
- package/src/styles/transcript.css +17 -3
- /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLatest } from "../hooks/useLatest.js";
|
|
1
2
|
import { createFlipList } from "./flip-list.js";
|
|
2
3
|
import { Component, useCallback, useLayoutEffect, useRef } from "react";
|
|
3
4
|
// src/motion/use-flip-list.ts
|
|
@@ -11,30 +12,32 @@ import { Component, useCallback, useLayoutEffect, useRef } from "react";
|
|
|
11
12
|
*/
|
|
12
13
|
function useFlipList(layoutKey, options = {}) {
|
|
13
14
|
const controller = useRef(null);
|
|
14
|
-
const
|
|
15
|
-
opts.current = options;
|
|
15
|
+
const getOptions = useLatest(options);
|
|
16
16
|
const ref = useCallback((el) => {
|
|
17
17
|
if (!el) return;
|
|
18
|
+
const o = getOptions();
|
|
18
19
|
const flip = createFlipList(el, {
|
|
19
|
-
...
|
|
20
|
-
keyOf: (node) => (
|
|
21
|
-
...
|
|
22
|
-
...
|
|
23
|
-
...
|
|
24
|
-
...
|
|
20
|
+
...o.selector ? { selector: o.selector } : {},
|
|
21
|
+
keyOf: (node) => (getOptions().keyOf ?? ((n) => n.getAttribute("data-flip-key")))(node),
|
|
22
|
+
...o.isSticky ? { isSticky: (node) => getOptions().isSticky(node) } : {},
|
|
23
|
+
...o.maxChanges !== void 0 ? { maxChanges: o.maxChanges } : {},
|
|
24
|
+
...o.maxTravel !== void 0 ? { maxTravel: o.maxTravel } : {},
|
|
25
|
+
...o.prefs ? { prefs: o.prefs } : {}
|
|
25
26
|
});
|
|
26
27
|
controller.current = flip;
|
|
27
28
|
return () => {
|
|
28
29
|
flip.dispose();
|
|
29
30
|
if (controller.current === flip) controller.current = null;
|
|
30
31
|
};
|
|
31
|
-
}, []);
|
|
32
|
+
}, [getOptions]);
|
|
32
33
|
useLayoutEffect(() => {
|
|
33
34
|
const flip = controller.current;
|
|
34
35
|
if (!flip) return;
|
|
35
|
-
|
|
36
|
+
const options = getOptions();
|
|
37
|
+
const { animate = true, mode = "list" } = options.plan ? options.plan() : options;
|
|
38
|
+
if (animate) flip.update(true, mode);
|
|
36
39
|
else flip.recordLater();
|
|
37
|
-
}, [layoutKey]);
|
|
40
|
+
}, [layoutKey, getOptions]);
|
|
38
41
|
return {
|
|
39
42
|
ref,
|
|
40
43
|
controller
|
|
@@ -62,7 +65,9 @@ var FlipSnapshot = class extends Component {
|
|
|
62
65
|
* @returns Nothing: React needs a value.
|
|
63
66
|
*/
|
|
64
67
|
getSnapshotBeforeUpdate(prev) {
|
|
65
|
-
if (prev.layoutKey
|
|
68
|
+
if (prev.layoutKey === this.props.layoutKey) return null;
|
|
69
|
+
const { animate, mode } = this.props.plan ? this.props.plan() : this.props;
|
|
70
|
+
if (animate !== false) this.props.flip.current?.snapshot(mode);
|
|
66
71
|
return null;
|
|
67
72
|
}
|
|
68
73
|
componentDidUpdate() {}
|
|
@@ -45,6 +45,43 @@ const ACTIONS = {
|
|
|
45
45
|
icon: "i-ph-star",
|
|
46
46
|
keywords: ["star", "pin"]
|
|
47
47
|
},
|
|
48
|
+
sessionMove: {
|
|
49
|
+
group: "session",
|
|
50
|
+
icon: "i-ph-arrow-square-out",
|
|
51
|
+
keywords: [
|
|
52
|
+
"teleport",
|
|
53
|
+
"host",
|
|
54
|
+
"server",
|
|
55
|
+
"machine",
|
|
56
|
+
"sandbox",
|
|
57
|
+
"worktree",
|
|
58
|
+
"environment",
|
|
59
|
+
"transfer"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
sessionShare: {
|
|
63
|
+
group: "session",
|
|
64
|
+
icon: "i-ph-users",
|
|
65
|
+
keywords: [
|
|
66
|
+
"invite",
|
|
67
|
+
"members",
|
|
68
|
+
"people",
|
|
69
|
+
"team",
|
|
70
|
+
"multiplayer",
|
|
71
|
+
"collaborate"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
openSessions: {
|
|
75
|
+
group: "navigate",
|
|
76
|
+
icon: "i-ph-door-open",
|
|
77
|
+
keywords: [
|
|
78
|
+
"join",
|
|
79
|
+
"channel",
|
|
80
|
+
"team",
|
|
81
|
+
"organization",
|
|
82
|
+
"shared"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
48
85
|
sessionDelete: {
|
|
49
86
|
group: "session",
|
|
50
87
|
icon: "i-ph-trash"
|
|
@@ -49,6 +49,9 @@ const DEFAULT_PALETTE_LABELS = {
|
|
|
49
49
|
paletteModelGroup: "Model",
|
|
50
50
|
paletteViewGroup: "View",
|
|
51
51
|
paletteActionTitles: {
|
|
52
|
+
sessionMove: "Move session to…",
|
|
53
|
+
sessionShare: "Share session…",
|
|
54
|
+
openSessions: "Open sessions",
|
|
52
55
|
newSession: "New session",
|
|
53
56
|
openMainSession: "Go to main session",
|
|
54
57
|
openSessionDetails: "Session details",
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { applyLiveEvent, finishLive } from "../chat/headless/streams/live-events.js";
|
|
2
2
|
import { SSE_PROTOCOL_HEADER, attachmentsFromPreviews, encodeSseRecord, formatCursor, parseCursor } from "../adapters/sse-protocol.js";
|
|
3
|
-
import { applyHistoryOp, checkSessionInboxPatch, readSessionInbox } from "zidane/chat/pure";
|
|
3
|
+
import { applyHistoryOp, checkSessionInboxPatch, readSessionInbox, replaceTurnText } from "zidane/chat/pure";
|
|
4
4
|
import { createChatHost, eventsFromTurns } from "zidane/chat";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
// src/server/sse-handler.ts
|
|
7
|
+
function withTurnText(events, { turnId, childId, text }) {
|
|
8
|
+
return replaceTurnText(events, childId ?? "parent", turnId, text);
|
|
9
|
+
}
|
|
7
10
|
function json(body, status = 200) {
|
|
8
11
|
return new Response(JSON.stringify(body), {
|
|
9
12
|
status,
|
|
@@ -105,6 +108,22 @@ function createSseHandler(options) {
|
|
|
105
108
|
pushSession(sessionId);
|
|
106
109
|
return;
|
|
107
110
|
}
|
|
111
|
+
case "turn:end": {
|
|
112
|
+
if (!Array.isArray(signal.text) || typeof signal.turnId !== "string") return;
|
|
113
|
+
const turnText = {
|
|
114
|
+
turnId: signal.turnId,
|
|
115
|
+
...typeof signal.childId === "string" ? { childId: signal.childId } : {},
|
|
116
|
+
text: signal.text
|
|
117
|
+
};
|
|
118
|
+
const ch = channels.get(sessionId);
|
|
119
|
+
if (ch.loaded) ch.events = withTurnText(ch.events, turnText);
|
|
120
|
+
else ch.early.push({ turnText });
|
|
121
|
+
record(sessionId, {
|
|
122
|
+
type: "turn-text",
|
|
123
|
+
data: turnText
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
108
127
|
case "interaction:request":
|
|
109
128
|
record(sessionId, {
|
|
110
129
|
type: "interaction",
|
|
@@ -190,6 +209,10 @@ function createSseHandler(options) {
|
|
|
190
209
|
if (i > held) events = applyLiveEvent(events, item.event);
|
|
191
210
|
continue;
|
|
192
211
|
}
|
|
212
|
+
if ("turnText" in item) {
|
|
213
|
+
events = withTurnText(events, item.turnText);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
193
216
|
if (reloadDue) continue;
|
|
194
217
|
const applied = applyHistoryOp(events, item.change, at);
|
|
195
218
|
if ("refetch" in applied) {
|
|
@@ -301,7 +324,7 @@ function createSseHandler(options) {
|
|
|
301
324
|
const encoder = new TextEncoder();
|
|
302
325
|
const last = parseCursor(request.headers.get("Last-Event-ID"));
|
|
303
326
|
const version = Number(request.headers.get("X-Zidane-Chat-Protocol")) || 1;
|
|
304
|
-
const known = (rec) => rec.type !== "history" || version >= 2;
|
|
327
|
+
const known = (rec) => rec.type !== "history" && rec.type !== "turn-text" || version >= 2;
|
|
305
328
|
let cleanup = () => {};
|
|
306
329
|
const body = new ReadableStream({
|
|
307
330
|
start(controller) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assignRef } from "../components/assign-ref.js";
|
|
1
2
|
import { DiffCounts } from "../components/PanelRows.js";
|
|
2
3
|
import { useSessionLabels } from "./useSessionLabels.js";
|
|
3
4
|
import { memo, useCallback, useEffect, useState } from "react";
|
|
@@ -15,10 +16,6 @@ const STEP = 6;
|
|
|
15
16
|
const NO_ANCHOR = { overflowAnchor: "none" };
|
|
16
17
|
/** A row's height before one is measured (`.zg-menu-row[data-size='sm']`). */
|
|
17
18
|
const ROW_GUESS = 26;
|
|
18
|
-
function assignRef(ref, value) {
|
|
19
|
-
if (typeof ref === "function") ref(value);
|
|
20
|
-
else if (ref) ref.current = value;
|
|
21
|
-
}
|
|
22
19
|
/**
|
|
23
20
|
* The rows of a long list to render: the ones in the list's view and a margin, with the height the
|
|
24
21
|
* rows above and below stand for. A list of {@link WINDOW_ABOVE} rows or fewer renders them all.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Open sessions" (docs/MULTIPLAYER.md, Membership): the sessions people of
|
|
3
|
+
* the organization opened to everyone, to join with their default grant.
|
|
4
|
+
* Opened with `useOpenSessions()` over `SessionHost.sharing.directory`;
|
|
5
|
+
* `OpenSessionsButton` is the sidebar footer's entry to it.
|
|
6
|
+
*/
|
|
7
|
+
import { CSSProperties } from "react";
|
|
8
|
+
/** Props for {@link OpenSessionsDialog}. */
|
|
9
|
+
export interface OpenSessionsDialogProps {
|
|
10
|
+
/** Closes the dialog. */
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
/** A session joined (or already joined): the app opens it. */
|
|
13
|
+
onOpen?: (sessionId: string) => void;
|
|
14
|
+
/** Extra classes on the root. */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Inline styles on the root. */
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The directory of open sessions.
|
|
21
|
+
*
|
|
22
|
+
* @param props - The {@link OpenSessionsDialogProps}.
|
|
23
|
+
*/
|
|
24
|
+
export declare function OpenSessionsDialog({ onClose, onOpen, className, style }: OpenSessionsDialogProps): import("react").JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* Opens the directory; `undefined` without `sharing.directory` or a modal layer.
|
|
27
|
+
*
|
|
28
|
+
* @param onOpen - Gets the session joined (or already joined): the app opens it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useOpenSessions(onOpen?: (sessionId: string) => void): (() => void) | undefined;
|
|
31
|
+
/** Props for {@link OpenSessionsButton}. */
|
|
32
|
+
export interface OpenSessionsButtonProps {
|
|
33
|
+
/** A session joined (or already joined): the app opens it. */
|
|
34
|
+
onOpen?: (sessionId: string) => void;
|
|
35
|
+
/** Extra classes on the root. */
|
|
36
|
+
className?: string;
|
|
37
|
+
/** Inline styles on the root. */
|
|
38
|
+
style?: CSSProperties;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The sidebar footer's "Open sessions": shown only when there are some (nothing without organization mode). The
|
|
42
|
+
* count is read again when who shares a session changes (`sharing.onChanged`).
|
|
43
|
+
*
|
|
44
|
+
* @param props - The {@link OpenSessionsButtonProps}.
|
|
45
|
+
*/
|
|
46
|
+
export declare function OpenSessionsButton({ onOpen, className, style }: OpenSessionsButtonProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { useOptionalModal } from "../app/ModalProvider.js";
|
|
2
|
+
import { buttonClass } from "../components/button.js";
|
|
3
|
+
import { MetaChip } from "../components/Form.js";
|
|
4
|
+
import { Notice } from "../components/Notice.js";
|
|
5
|
+
import { errorMessage } from "../components/report-error.js";
|
|
6
|
+
import { useSessionHost } from "./SessionProvider.js";
|
|
7
|
+
import { useSessionLabels } from "./useSessionLabels.js";
|
|
8
|
+
import { useCallback, useEffect, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/session/OpenSessionsDialog.tsx
|
|
11
|
+
const TITLE_ID = "open-sessions-title";
|
|
12
|
+
/**
|
|
13
|
+
* The directory of open sessions.
|
|
14
|
+
*
|
|
15
|
+
* @param props - The {@link OpenSessionsDialogProps}.
|
|
16
|
+
*/
|
|
17
|
+
function OpenSessionsDialog({ onClose, onOpen, className, style }) {
|
|
18
|
+
const sharing = useSessionHost().sharing;
|
|
19
|
+
const labels = useSessionLabels();
|
|
20
|
+
const [rows, setRows] = useState(null);
|
|
21
|
+
const [error, setError] = useState(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
let live = true;
|
|
24
|
+
sharing?.directory?.().then((found) => live && setRows(found)).catch((err) => live && setError({
|
|
25
|
+
message: labels.openSessionsLoadFailed,
|
|
26
|
+
detail: errorMessage(err)
|
|
27
|
+
}));
|
|
28
|
+
return () => {
|
|
29
|
+
live = false;
|
|
30
|
+
};
|
|
31
|
+
}, [sharing, labels]);
|
|
32
|
+
const open = async (row) => {
|
|
33
|
+
setError(null);
|
|
34
|
+
try {
|
|
35
|
+
if (!row.joined) await sharing?.join?.(row.sessionId);
|
|
36
|
+
onOpen?.(row.sessionId);
|
|
37
|
+
onClose();
|
|
38
|
+
} catch (err) {
|
|
39
|
+
setError({
|
|
40
|
+
message: labels.openSessionsJoinFailed,
|
|
41
|
+
detail: errorMessage(err)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: `zg-modal-panel zg-float w-[460px] max-w-[92vw] flex flex-col overflow-hidden${className ? ` ${className}` : ""}`,
|
|
47
|
+
style,
|
|
48
|
+
"data-testid": "open-sessions-dialog",
|
|
49
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
50
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
51
|
+
className: "px-5 pt-4 pb-4 flex flex-col gap-3 min-h-0",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx("h2", {
|
|
54
|
+
id: TITLE_ID,
|
|
55
|
+
className: "m-0 text-sm font-semibold text-[var(--zg-text)]",
|
|
56
|
+
children: labels.openSessionsTitle
|
|
57
|
+
}),
|
|
58
|
+
rows === null && !error && /* @__PURE__ */ jsx("p", {
|
|
59
|
+
className: "m-0 text-zg-label text-[var(--zg-text-muted)]",
|
|
60
|
+
children: labels.openSessionsLoading
|
|
61
|
+
}),
|
|
62
|
+
rows?.length === 0 && /* @__PURE__ */ jsx("p", {
|
|
63
|
+
className: "m-0 text-zg-label text-[var(--zg-text-muted)]",
|
|
64
|
+
children: labels.openSessionsNone
|
|
65
|
+
}),
|
|
66
|
+
rows && rows.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
67
|
+
className: "m-0 p-0 list-none flex flex-col gap-1.5",
|
|
68
|
+
children: rows.map((row) => /* @__PURE__ */ jsxs("li", {
|
|
69
|
+
className: "flex items-center gap-2 min-w-0",
|
|
70
|
+
"data-testid": `open-session-${row.sessionId}`,
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("span", {
|
|
73
|
+
className: "flex-1 min-w-0 truncate text-zg-label text-[var(--zg-text)]",
|
|
74
|
+
children: row.title
|
|
75
|
+
}),
|
|
76
|
+
row.owner && /* @__PURE__ */ jsx("span", {
|
|
77
|
+
className: "truncate text-zg-label text-[var(--zg-text-muted)]",
|
|
78
|
+
children: row.owner.name ?? row.owner.email
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsx(MetaChip, { children: labels.openSessionsMembers(row.members + (row.owner ? 1 : 0)) }),
|
|
81
|
+
/* @__PURE__ */ jsx("button", {
|
|
82
|
+
type: "button",
|
|
83
|
+
className: buttonClass({
|
|
84
|
+
variant: row.joined ? "ghost" : "secondary",
|
|
85
|
+
size: "xs"
|
|
86
|
+
}),
|
|
87
|
+
onClick: () => void open(row),
|
|
88
|
+
children: row.joined ? labels.openSessionsOpen : labels.openSessionsJoin
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
}, row.sessionId))
|
|
92
|
+
}),
|
|
93
|
+
error && /* @__PURE__ */ jsx(Notice, {
|
|
94
|
+
tone: "error",
|
|
95
|
+
detail: error.detail,
|
|
96
|
+
children: error.message
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
}), /* @__PURE__ */ jsx("footer", {
|
|
100
|
+
className: "flex items-center justify-end gap-2 px-5 py-3 bg-[var(--zg-tray)]",
|
|
101
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
onClick: onClose,
|
|
104
|
+
className: buttonClass({ variant: "solid" }),
|
|
105
|
+
children: labels.shareDone
|
|
106
|
+
})
|
|
107
|
+
})]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Opens the directory; `undefined` without `sharing.directory` or a modal layer.
|
|
112
|
+
*
|
|
113
|
+
* @param onOpen - Gets the session joined (or already joined): the app opens it.
|
|
114
|
+
*/
|
|
115
|
+
function useOpenSessions(onOpen) {
|
|
116
|
+
const sharing = useSessionHost().sharing;
|
|
117
|
+
const modal = useOptionalModal();
|
|
118
|
+
const openLayer = modal?.openLayer;
|
|
119
|
+
const closeLayer = modal?.closeLayer;
|
|
120
|
+
const open = useCallback(() => {
|
|
121
|
+
if (!openLayer || !closeLayer) return;
|
|
122
|
+
openLayer(/* @__PURE__ */ jsx(OpenSessionsDialog, {
|
|
123
|
+
onClose: () => closeLayer(),
|
|
124
|
+
...onOpen ? { onOpen } : {}
|
|
125
|
+
}), {
|
|
126
|
+
onDismiss: () => {},
|
|
127
|
+
labelledBy: TITLE_ID
|
|
128
|
+
});
|
|
129
|
+
}, [
|
|
130
|
+
openLayer,
|
|
131
|
+
closeLayer,
|
|
132
|
+
onOpen
|
|
133
|
+
]);
|
|
134
|
+
return sharing?.directory && openLayer && closeLayer ? open : void 0;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The sidebar footer's "Open sessions": shown only when there are some (nothing without organization mode). The
|
|
138
|
+
* count is read again when who shares a session changes (`sharing.onChanged`).
|
|
139
|
+
*
|
|
140
|
+
* @param props - The {@link OpenSessionsButtonProps}.
|
|
141
|
+
*/
|
|
142
|
+
function OpenSessionsButton({ onOpen, className, style }) {
|
|
143
|
+
const labels = useSessionLabels();
|
|
144
|
+
const sharing = useSessionHost().sharing;
|
|
145
|
+
const open = useOpenSessions(onOpen);
|
|
146
|
+
const [count, setCount] = useState(0);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
let live = true;
|
|
149
|
+
const read = () => void sharing?.directory?.().then((rows) => live && setCount(rows.length)).catch(() => live && setCount(0));
|
|
150
|
+
read();
|
|
151
|
+
const off = sharing?.onChanged?.(read);
|
|
152
|
+
return () => {
|
|
153
|
+
live = false;
|
|
154
|
+
off?.();
|
|
155
|
+
};
|
|
156
|
+
}, [sharing]);
|
|
157
|
+
if (!open || count === 0) return null;
|
|
158
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
159
|
+
type: "button",
|
|
160
|
+
"data-testid": "open-sessions",
|
|
161
|
+
className: `${buttonClass({
|
|
162
|
+
variant: "ghost",
|
|
163
|
+
size: "xs"
|
|
164
|
+
})}${className ? ` ${className}` : ""}`,
|
|
165
|
+
style,
|
|
166
|
+
onClick: open,
|
|
167
|
+
children: [labels.openSessionsTitle, /* @__PURE__ */ jsx(MetaChip, { children: count })]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
export { OpenSessionsButton, OpenSessionsDialog, useOpenSessions };
|
|
@@ -345,8 +345,7 @@ function PlanTracker({ sessionId, plan, hideHeader = false, className, style })
|
|
|
345
345
|
function RecentPlans({ sessionId, plans, className, style }) {
|
|
346
346
|
const labels = useSessionLabels();
|
|
347
347
|
const [open, setOpen] = useState(null);
|
|
348
|
-
useMinuteTick();
|
|
349
|
-
const now = Date.now();
|
|
348
|
+
const now = useMinuteTick();
|
|
350
349
|
return /* @__PURE__ */ jsx("ul", {
|
|
351
350
|
className: ["m-0 p-0 list-none flex flex-col gap-1", className].filter(Boolean).join(" "),
|
|
352
351
|
style,
|
|
@@ -9,6 +9,7 @@ import { RowActionsMenu } from "../components/RowActionsMenu.js";
|
|
|
9
9
|
import { SegmentSpinner } from "../components/SegmentSpinner.js";
|
|
10
10
|
import { ExtensionSlot } from "../extensions/ExtensionSlot.js";
|
|
11
11
|
import { useDisplayPath } from "../hooks/useDisplayPath.js";
|
|
12
|
+
import { useLatest } from "../hooks/useLatest.js";
|
|
12
13
|
import { readPersisted, writePersisted } from "../hooks/usePersistedState.js";
|
|
13
14
|
import { SavedViewRenameContext, SavedViewTitle } from "../views/SavedViewTitle.js";
|
|
14
15
|
import { ViewChromeContext } from "../views/view-chrome.js";
|
|
@@ -101,7 +102,7 @@ const HomeBlockCard = memo(({ panels, cwd, block, view, first, last, editing, on
|
|
|
101
102
|
const renaming = renamingNow && editing;
|
|
102
103
|
const menuAnchor = useRef(null);
|
|
103
104
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
104
|
-
const { open: iconOpen, setOpen: openIcon, close: closeIcon, triggerRef:
|
|
105
|
+
const { open: iconOpen, setOpen: openIcon, close: closeIcon, triggerRef: iconTriggerRef, surfaceRef: iconSurfaceRef } = usePopover();
|
|
105
106
|
const viewsHost = useViewsHost();
|
|
106
107
|
const savedView = block.view && isSavedViewBlockId(block.panel) && viewsHost?.renameSaved ? block.view : null;
|
|
107
108
|
const [titleEditing, setTitleEditing] = useState(false);
|
|
@@ -235,7 +236,7 @@ const HomeBlockCard = memo(({ panels, cwd, block, view, first, last, editing, on
|
|
|
235
236
|
children: [
|
|
236
237
|
/* @__PURE__ */ jsx("span", {
|
|
237
238
|
ref: (node) => {
|
|
238
|
-
|
|
239
|
+
iconTriggerRef.current = node;
|
|
239
240
|
},
|
|
240
241
|
className: "shrink-0 inline-flex items-center justify-center w-4 h-4 text-[var(--zg-text-muted)]",
|
|
241
242
|
children: /* @__PURE__ */ jsx(BlockGlyph, { block })
|
|
@@ -267,10 +268,10 @@ const HomeBlockCard = memo(({ panels, cwd, block, view, first, last, editing, on
|
|
|
267
268
|
}),
|
|
268
269
|
/* @__PURE__ */ jsx(FloatingSurface, {
|
|
269
270
|
ref: (node) => {
|
|
270
|
-
|
|
271
|
+
iconSurfaceRef.current = node;
|
|
271
272
|
},
|
|
272
273
|
open: iconOpen,
|
|
273
|
-
anchor: {
|
|
274
|
+
anchor: { ref: iconTriggerRef },
|
|
274
275
|
side: "bottom",
|
|
275
276
|
align: "start",
|
|
276
277
|
offset: 4,
|
|
@@ -681,8 +682,7 @@ function useHomeBlock(panels, cwd, id, view, search) {
|
|
|
681
682
|
const key = `${cwd}\u0000${id}\u0000${viewKey}\u0000${search}\u0000${rev}`;
|
|
682
683
|
const [paged, setPaged] = useState(null);
|
|
683
684
|
const [loadingMore, setLoadingMore] = useState(false);
|
|
684
|
-
const
|
|
685
|
-
keyRef.current = key;
|
|
685
|
+
const currentKey = useLatest(key);
|
|
686
686
|
const [loaded, setLoaded] = useState({
|
|
687
687
|
key: "",
|
|
688
688
|
content: null,
|
|
@@ -748,11 +748,11 @@ function useHomeBlock(panels, cwd, id, view, search) {
|
|
|
748
748
|
...blockContext(viewKey, search),
|
|
749
749
|
cursor
|
|
750
750
|
}).then((page) => {
|
|
751
|
-
if (
|
|
751
|
+
if (currentKey() === key) setPaged({
|
|
752
752
|
key,
|
|
753
753
|
content: appendPanelPage(shown, page)
|
|
754
754
|
});
|
|
755
|
-
}, (err) =>
|
|
755
|
+
}, (err) => currentKey() === key && setLoaded((s) => ({
|
|
756
756
|
...s,
|
|
757
757
|
error: errorMessage(err)
|
|
758
758
|
}))).finally(() => setLoadingMore(false));
|
|
@@ -764,7 +764,8 @@ function useHomeBlock(panels, cwd, id, view, search) {
|
|
|
764
764
|
search,
|
|
765
765
|
key,
|
|
766
766
|
shown,
|
|
767
|
-
loadingMore
|
|
767
|
+
loadingMore,
|
|
768
|
+
currentKey
|
|
768
769
|
]);
|
|
769
770
|
return {
|
|
770
771
|
content: shown ?? loaded.content,
|
|
@@ -14,7 +14,7 @@ import { useMinuteTick } from "../hooks/useMinuteTick.js";
|
|
|
14
14
|
import { canKeepSchedule, isScheduleFinished, readReminderWhen, sortSchedules } from "./headless/schedules.js";
|
|
15
15
|
import { useAllSchedules, useSchedulesStatus, useSessionHost, useSessionSchedules } from "./SessionProvider.js";
|
|
16
16
|
import { useSessionLabels } from "./useSessionLabels.js";
|
|
17
|
-
import { useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
17
|
+
import { useContext, useEffect, useEffectEvent, useId, useMemo, useRef, useState } from "react";
|
|
18
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
import { describeTime, describeTrigger, scheduleLabel, scheduleTargetSession } from "zidane/chat/pure";
|
|
20
20
|
// src/session/RemindersPanel.tsx
|
|
@@ -73,22 +73,20 @@ function RemindersPanel({ sessionId, initialScope = "session", onOpenSession, re
|
|
|
73
73
|
const [revealTurn, setRevealTurn] = useState(0);
|
|
74
74
|
const listRef = useRef(null);
|
|
75
75
|
useMinuteTick();
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const [taken, setTaken] = useState(null);
|
|
77
|
+
if (revealRequest === null && taken !== null) setTaken(null);
|
|
78
|
+
if (revealRequest && revealRequest !== taken && status !== null && (!status.enabled || all !== null && mine !== null)) {
|
|
79
|
+
setTaken(revealRequest);
|
|
78
80
|
if (status.enabled) {
|
|
79
|
-
if (all === null || mine === null) return;
|
|
80
81
|
if (!mine.some((s) => s.id === revealRequest) && all.some((s) => s.id === revealRequest)) setScope("all");
|
|
81
82
|
setRevealed(revealRequest);
|
|
82
83
|
setRevealTurn((n) => n + 1);
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
all,
|
|
90
|
-
onRevealTaken
|
|
91
|
-
]);
|
|
85
|
+
}
|
|
86
|
+
const tookReveal = useEffectEvent(() => onRevealTaken?.());
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (taken !== null) tookReveal();
|
|
89
|
+
}, [taken]);
|
|
92
90
|
useEffect(() => {
|
|
93
91
|
if (!revealed) return;
|
|
94
92
|
const rows = listRef.current?.querySelectorAll("[data-schedule-id]") ?? [];
|
|
@@ -110,7 +110,8 @@ function SecretsPanel({ sessionId, className = "", style }) {
|
|
|
110
110
|
}
|
|
111
111
|
function SecretRow({ entry, sessionId, onRevoke, onReplace }) {
|
|
112
112
|
const labels = useSessionLabels();
|
|
113
|
-
const
|
|
113
|
+
const now = useMinuteTick();
|
|
114
|
+
const left = secretTimeLeft(entry.expiresAt, now);
|
|
114
115
|
return /* @__PURE__ */ jsxs("li", {
|
|
115
116
|
className: `${PANEL_ROW} ${PANEL_ROW_HOVER} items-center`,
|
|
116
117
|
"data-secret-name": entry.name,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who else has the session open (organization mode, docs/MULTIPLAYER.md): a small stack of avatars at the right of
|
|
3
|
+
* its header, from the host's `sharing.people`. Nothing when nobody else is there, or without `people`.
|
|
4
|
+
*
|
|
5
|
+
* At most three avatars, then "+N". A photo that fails to load falls back to the person's initial. Hovering names
|
|
6
|
+
* everyone; a screen reader hears the same line.
|
|
7
|
+
*/
|
|
8
|
+
import { CSSProperties } from "react";
|
|
9
|
+
/** Props for {@link SessionPeopleStack}. */
|
|
10
|
+
export interface SessionPeopleStackProps {
|
|
11
|
+
/** The session shown. */
|
|
12
|
+
sessionId: string;
|
|
13
|
+
/** Extra classes on the root. */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Inline styles on the root. */
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Renders who else has `sessionId` open, or nothing.
|
|
20
|
+
*
|
|
21
|
+
* @param props - The {@link SessionPeopleStackProps}.
|
|
22
|
+
*/
|
|
23
|
+
export declare function SessionPeopleStack(props: SessionPeopleStackProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Tooltip } from "../components/Tooltip.js";
|
|
2
|
+
import { useSessionHost } from "./SessionProvider.js";
|
|
3
|
+
import { useSessionLabels } from "./useSessionLabels.js";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/session/SessionPeopleStack.tsx
|
|
7
|
+
/** The most avatars drawn; more show as "+N". */
|
|
8
|
+
const SHOWN = 3;
|
|
9
|
+
const NOBODY = [];
|
|
10
|
+
/** One person: their photo, else their initial, ringed in the header's color so the stack reads as separate faces. */
|
|
11
|
+
function PersonAvatar({ person }) {
|
|
12
|
+
const [failed, setFailed] = useState(false);
|
|
13
|
+
const ring = "ring-2 ring-[var(--zg-bg)]";
|
|
14
|
+
if (person.avatar && !failed) return /* @__PURE__ */ jsx("img", {
|
|
15
|
+
src: person.avatar,
|
|
16
|
+
alt: "",
|
|
17
|
+
width: 20,
|
|
18
|
+
height: 20,
|
|
19
|
+
decoding: "async",
|
|
20
|
+
referrerPolicy: "no-referrer",
|
|
21
|
+
onError: () => setFailed(true),
|
|
22
|
+
className: `size-5 shrink-0 rounded-full object-cover bg-[var(--zg-raised)] ${ring}`
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx("span", {
|
|
25
|
+
"aria-hidden": true,
|
|
26
|
+
className: `size-5 shrink-0 rounded-full inline-flex items-center justify-center bg-[var(--zg-raised)] text-zg-badge font-semibold leading-none text-[var(--zg-text-muted)] select-none ${ring}`,
|
|
27
|
+
children: (person.name.trim()[0] ?? "?").toUpperCase()
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Renders who else has `sessionId` open, or nothing.
|
|
32
|
+
*
|
|
33
|
+
* @param props - The {@link SessionPeopleStackProps}.
|
|
34
|
+
*/
|
|
35
|
+
function SessionPeopleStack(props) {
|
|
36
|
+
const { sessionId, className = "", style } = props;
|
|
37
|
+
const people = useSessionHost().sharing?.people;
|
|
38
|
+
const labels = useSessionLabels();
|
|
39
|
+
const [here, setHere] = useState(NOBODY);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!people) return void 0;
|
|
42
|
+
return people.watch(sessionId, setHere);
|
|
43
|
+
}, [people, sessionId]);
|
|
44
|
+
if (!people || here.length === 0) return null;
|
|
45
|
+
const names = here.map((person) => person.name);
|
|
46
|
+
const line = labels.peopleHere(names);
|
|
47
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
48
|
+
label: line,
|
|
49
|
+
align: "end",
|
|
50
|
+
className,
|
|
51
|
+
style,
|
|
52
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
53
|
+
role: "img",
|
|
54
|
+
"aria-label": line,
|
|
55
|
+
"data-testid": "session-people",
|
|
56
|
+
className: "flex items-center -space-x-1.5 px-1",
|
|
57
|
+
children: [here.slice(0, SHOWN).map((person) => /* @__PURE__ */ jsx(PersonAvatar, { person }, person.userId)), here.length > SHOWN && /* @__PURE__ */ jsx("span", {
|
|
58
|
+
"aria-hidden": true,
|
|
59
|
+
className: "size-5 shrink-0 rounded-full inline-flex items-center justify-center bg-[var(--zg-raised)] ring-2 ring-[var(--zg-bg)] text-zg-badge leading-none text-[var(--zg-text-muted)]",
|
|
60
|
+
children: labels.peopleMore(here.length - SHOWN)
|
|
61
|
+
})]
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export { SessionPeopleStack };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useOptionalConfirm } from "../app/useConfirm.js";
|
|
2
2
|
import { StatusOrb } from "../chat/DaemonOrb.js";
|
|
3
3
|
import { hostStatusLabel } from "../chat/headless/hosts.js";
|
|
4
|
-
import {
|
|
4
|
+
import { environmentLabel, runsInRemoteSandbox } from "../chat/headless/sidebar/environment.js";
|
|
5
5
|
import { useEnvironmentActions, useEnvironmentCommands } from "../chat/sidebar/session-menu.js";
|
|
6
6
|
import { useSidebarNotice } from "../chat/sidebar/SidebarHostProvider.js";
|
|
7
7
|
import { useSidebarLabels } from "../chat/sidebar/useSidebarLabels.js";
|
|
@@ -49,10 +49,11 @@ function PlaceMenu({ sessionId, environment, server, className = "", style }) {
|
|
|
49
49
|
const commands = useEnvironmentCommands();
|
|
50
50
|
const confirm = useOptionalConfirm();
|
|
51
51
|
const [open, setOpen] = useState(false);
|
|
52
|
-
const
|
|
52
|
+
const busy = environment?.state === "ready" && environment.busy !== void 0;
|
|
53
|
+
const actions = useEnvironmentActions(sessionId, open && environment?.state === "ready" && !busy);
|
|
53
54
|
const tone = sessionPlaceTone(environment, server);
|
|
54
55
|
const serverName = server ? server.name : labels.placeServerGone;
|
|
55
|
-
const where = environment ?
|
|
56
|
+
const where = environment ? environmentLabel(environment, sidebarLabels) : labels.placeOnServer(serverName);
|
|
56
57
|
const state = environment ? environmentStateLabel(labels, environment, sessionPlaceTone(environment, void 0)) : labels.placeServerTones[tone];
|
|
57
58
|
const step = environment?.progress?.step;
|
|
58
59
|
const steps = environment?.state === "provisioning" || environment?.state === "failed" ? environment.progress?.steps ?? [] : [];
|
|
@@ -240,7 +241,7 @@ function PlaceMenu({ sessionId, environment, server, className = "", style }) {
|
|
|
240
241
|
commands.pause?.(sessionId);
|
|
241
242
|
}
|
|
242
243
|
}),
|
|
243
|
-
actions.map((action) => /* @__PURE__ */ jsx(MenuRow, {
|
|
244
|
+
!busy && actions.map((action) => /* @__PURE__ */ jsx(MenuRow, {
|
|
244
245
|
role: "menuitem",
|
|
245
246
|
size: "lg",
|
|
246
247
|
title: action.label,
|