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,6 +1,6 @@
|
|
|
1
1
|
import { useFilesHost } from "./FilesProvider.js";
|
|
2
2
|
import { filesRootOf } from "./headless/view.js";
|
|
3
|
-
import { editedPaths, sameEntries,
|
|
3
|
+
import { editedPaths, sameEntries, sameStatus } from "./headless/workspace-diff.js";
|
|
4
4
|
import { useFolderChanges } from "./useFolderChanges.js";
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
// src/files/useWorkspace.ts
|
|
@@ -9,7 +9,6 @@ const NO_FOLDERS = /* @__PURE__ */ new Map();
|
|
|
9
9
|
function useWorkspace(scope, showIgnored, visible, useEdits) {
|
|
10
10
|
const host = useFilesHost();
|
|
11
11
|
const [listed, setListed] = useState(null);
|
|
12
|
-
const [truncated, setTruncated] = useState(null);
|
|
13
12
|
const [opened, setOpened] = useState(NO_FOLDERS);
|
|
14
13
|
const openedRef = useRef(opened);
|
|
15
14
|
openedRef.current = opened;
|
|
@@ -41,7 +40,6 @@ function useWorkspace(scope, showIgnored, visible, useEdits) {
|
|
|
41
40
|
if (mine !== reads.current) return;
|
|
42
41
|
const list = listing.entries;
|
|
43
42
|
setListed((prev) => sameEntries(prev, list) ? prev : list);
|
|
44
|
-
setTruncated((prev) => sameTruncation(prev, listing.truncated) ? prev : listing.truncated ?? null);
|
|
45
43
|
setStatus((prev) => sameStatus(prev, git) ? prev : git);
|
|
46
44
|
if (folders.length > 0) setOpened((prev) => {
|
|
47
45
|
let changed = false;
|
|
@@ -63,7 +61,6 @@ function useWorkspace(scope, showIgnored, visible, useEdits) {
|
|
|
63
61
|
useEffect(() => {
|
|
64
62
|
generation.current++;
|
|
65
63
|
setListed(null);
|
|
66
|
-
setTruncated(null);
|
|
67
64
|
setOpened(NO_FOLDERS);
|
|
68
65
|
openedRef.current = NO_FOLDERS;
|
|
69
66
|
refresh();
|
|
@@ -118,14 +115,12 @@ function useWorkspace(scope, showIgnored, visible, useEdits) {
|
|
|
118
115
|
staleListing.current = false;
|
|
119
116
|
refresh();
|
|
120
117
|
}, [visible, refresh]);
|
|
121
|
-
const
|
|
122
|
-
const changedPaths = useMemo(() => {
|
|
118
|
+
const changedKey = useMemo(() => {
|
|
123
119
|
const set = editedPaths(edits);
|
|
124
120
|
for (const g of status) set.add(g.path);
|
|
125
|
-
|
|
126
|
-
lastChanged.current = set;
|
|
127
|
-
return set;
|
|
121
|
+
return [...set].sort().join("\0");
|
|
128
122
|
}, [edits, status]);
|
|
123
|
+
const changedPaths = useMemo(() => new Set(changedKey ? changedKey.split("\0") : []), [changedKey]);
|
|
129
124
|
return useMemo(() => ({
|
|
130
125
|
entries,
|
|
131
126
|
status,
|
|
@@ -133,7 +128,6 @@ function useWorkspace(scope, showIgnored, visible, useEdits) {
|
|
|
133
128
|
edits,
|
|
134
129
|
refresh,
|
|
135
130
|
onToolResult,
|
|
136
|
-
truncated,
|
|
137
131
|
openFolder
|
|
138
132
|
}), [
|
|
139
133
|
entries,
|
|
@@ -142,14 +136,9 @@ function useWorkspace(scope, showIgnored, visible, useEdits) {
|
|
|
142
136
|
edits,
|
|
143
137
|
refresh,
|
|
144
138
|
onToolResult,
|
|
145
|
-
truncated,
|
|
146
139
|
openFolder
|
|
147
140
|
]);
|
|
148
141
|
}
|
|
149
|
-
function sameTruncation(a, b) {
|
|
150
|
-
if (!a || !b) return !a && !b;
|
|
151
|
-
return a.shown === b.shown && a.total === b.total && a.atLeast === b.atLeast;
|
|
152
|
-
}
|
|
153
142
|
/**
|
|
154
143
|
* The listing with what each opened folder holds: an opened folder's own node (`dist/`) gives way to its contents,
|
|
155
144
|
* unless it holds nothing.
|
package/dist/git/GitBar.js
CHANGED
|
@@ -8,7 +8,7 @@ import { useGitLabels } from "./GitProvider.js";
|
|
|
8
8
|
import { compactCount } from "./headless/switcher.js";
|
|
9
9
|
import { GIT_BAR_ITEM, SyncChip } from "./SyncChip.js";
|
|
10
10
|
import { useGitBar } from "./useGitBar.js";
|
|
11
|
-
import { memo,
|
|
11
|
+
import { memo, useRef, useState } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
// src/git/GitBar.tsx
|
|
14
14
|
const openInBrowser = (url) => void window.open(url, "_blank");
|
|
@@ -64,9 +64,11 @@ function Bar({ info, pr, cwd, sessionId, running, onSwitched, onShowChanges, onO
|
|
|
64
64
|
const links = useLinkRouter();
|
|
65
65
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
66
66
|
const branchRef = useRef(null);
|
|
67
|
-
|
|
67
|
+
const [wasRunning, setWasRunning] = useState(running);
|
|
68
|
+
if (running !== wasRunning) {
|
|
69
|
+
setWasRunning(running);
|
|
68
70
|
if (running) setMenuOpen(false);
|
|
69
|
-
}
|
|
71
|
+
}
|
|
70
72
|
const { changes } = info;
|
|
71
73
|
return /* @__PURE__ */ jsxs("div", {
|
|
72
74
|
"data-testid": "git-bar",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* moveSession?.({ sessionId, cwd, kind, hasTurns: true });
|
|
22
22
|
*/
|
|
23
23
|
import { MoveSessionSubject } from "./headless/move.js";
|
|
24
|
-
import { CSSProperties } from "react";
|
|
24
|
+
import { CSSProperties, ReactNode } from "react";
|
|
25
|
+
/** The id of {@link MoveSessionDialog}'s heading, for the layer that labels itself with it. */
|
|
26
|
+
export declare const MOVE_SESSION_TITLE_ID = "move-session-title";
|
|
25
27
|
/** Props for {@link MoveSessionDialog}. */
|
|
26
28
|
export interface MoveSessionDialogProps {
|
|
27
29
|
/** The session to move. */
|
|
@@ -30,6 +32,20 @@ export interface MoveSessionDialogProps {
|
|
|
30
32
|
onDone: () => void;
|
|
31
33
|
/** Closed without moving. */
|
|
32
34
|
onCancel: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* The kind already picked (Move to…'s where menu): the dialog opens on its folder and confirmation, and Back goes
|
|
37
|
+
* to {@link MoveSessionDialogProps.onBack}. Absent: it opens on the list of kinds.
|
|
38
|
+
*/
|
|
39
|
+
initial?: {
|
|
40
|
+
kind: string;
|
|
41
|
+
branch?: string;
|
|
42
|
+
};
|
|
43
|
+
/** Back from the first step shown (with {@link MoveSessionDialogProps.initial}). */
|
|
44
|
+
onBack?: () => void;
|
|
45
|
+
/** Shown above the steps (what happened before this one). */
|
|
46
|
+
lead?: ReactNode;
|
|
47
|
+
/** The Cancel button's words. Default: Cancel. */
|
|
48
|
+
cancelLabel?: string;
|
|
33
49
|
/** Extra class names for the root. */
|
|
34
50
|
className?: string;
|
|
35
51
|
/** Inline styles on the root element. */
|
|
@@ -40,10 +56,4 @@ export interface MoveSessionDialogProps {
|
|
|
40
56
|
*
|
|
41
57
|
* @param props - The {@link MoveSessionDialogProps}.
|
|
42
58
|
*/
|
|
43
|
-
export declare function MoveSessionDialog({ subject, onDone, onCancel, className, style }: MoveSessionDialogProps): import("react").JSX.Element;
|
|
44
|
-
/**
|
|
45
|
-
* Opens the move dialog above whatever is open, over the `GitHost` in context. `undefined` without what it needs
|
|
46
|
-
* (`GitHost.moveSession` and `environments`, a modal layer): hide the control that calls it. The returned function
|
|
47
|
-
* resolves `true` once the session moved, `false` when closed.
|
|
48
|
-
*/
|
|
49
|
-
export declare function useMoveSession(): ((subject: MoveSessionSubject) => Promise<boolean>) | undefined;
|
|
59
|
+
export declare function MoveSessionDialog({ subject, onDone, onCancel, initial, onBack, lead, cancelLabel, className, style }: MoveSessionDialogProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useOptionalModal } from "../app/ModalProvider.js";
|
|
2
1
|
import { buttonClass } from "../components/button.js";
|
|
3
2
|
import { Checkbox, MetaChip } from "../components/Form.js";
|
|
4
3
|
import { MenuNote, MenuRow } from "../components/Menu.js";
|
|
@@ -11,10 +10,12 @@ import { environmentKindIcon } from "./headless/environment.js";
|
|
|
11
10
|
import { gitErrorText } from "./headless/labels.js";
|
|
12
11
|
import { leavesWorktree, moveChoices, moveListingCwd } from "./headless/move.js";
|
|
13
12
|
import { RemoteFolderBrowser } from "./RemoteFolderPicker.js";
|
|
14
|
-
import {
|
|
13
|
+
import { useEffect, useState } from "react";
|
|
15
14
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
// src/git/MoveSessionDialog.tsx
|
|
17
|
-
|
|
16
|
+
/** The id of {@link MoveSessionDialog}'s heading, for the layer that labels itself with it. */
|
|
17
|
+
const MOVE_SESSION_TITLE_ID = "move-session-title";
|
|
18
|
+
const TITLE_ID = MOVE_SESSION_TITLE_ID;
|
|
18
19
|
/** How a folder is picked on a target: browsed there, with the native dialog, or not at all. */
|
|
19
20
|
function folderPicking(host, choice, subject) {
|
|
20
21
|
if (!host) return null;
|
|
@@ -27,7 +28,7 @@ function folderPicking(host, choice, subject) {
|
|
|
27
28
|
*
|
|
28
29
|
* @param props - The {@link MoveSessionDialogProps}.
|
|
29
30
|
*/
|
|
30
|
-
function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
31
|
+
function MoveSessionDialog({ subject, onDone, onCancel, initial, onBack, lead, cancelLabel, className, style }) {
|
|
31
32
|
const host = useGitHost();
|
|
32
33
|
const labels = useGitLabels();
|
|
33
34
|
const [choices, setChoices] = useState(null);
|
|
@@ -42,6 +43,15 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
42
43
|
/** The session moved, its old worktree kept: why, shown before the dialog closes. */
|
|
43
44
|
const [kept, setKept] = useState(null);
|
|
44
45
|
const offersRemoval = leavesWorktree(subject);
|
|
46
|
+
const pick = (choice) => {
|
|
47
|
+
setPicked(choice);
|
|
48
|
+
setFolder(null);
|
|
49
|
+
setBranch("");
|
|
50
|
+
setError(null);
|
|
51
|
+
setRemoveWorktree(false);
|
|
52
|
+
setBrowsing(choice.needsFolder && folderPicking(host, choice, subject) === "browse");
|
|
53
|
+
if (choice.needsFolder && folderPicking(host, choice, subject) === "native") pickNative();
|
|
54
|
+
};
|
|
45
55
|
const listEnvironments = host?.environments;
|
|
46
56
|
const listingCwd = moveListingCwd(subject);
|
|
47
57
|
const { hostId } = subject;
|
|
@@ -53,7 +63,17 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
53
63
|
...listingCwd ? { cwd: listingCwd } : {},
|
|
54
64
|
...hostId !== void 0 ? { hostId } : {}
|
|
55
65
|
}).then((descriptors) => {
|
|
56
|
-
if (live)
|
|
66
|
+
if (!live) return;
|
|
67
|
+
const listed = moveChoices(descriptors, subject);
|
|
68
|
+
setChoices(listed);
|
|
69
|
+
const chosen = initial ? listed.find((choice) => choice.descriptor.kind === initial.kind) : void 0;
|
|
70
|
+
if (initial && chosen?.pickable) {
|
|
71
|
+
pick(chosen);
|
|
72
|
+
setBranch(initial.branch ?? "");
|
|
73
|
+
} else if (initial) setError({
|
|
74
|
+
message: labels.gitMoveUnavailable,
|
|
75
|
+
...chosen?.reason ? { detail: chosen.reason } : {}
|
|
76
|
+
});
|
|
57
77
|
}).catch((err) => {
|
|
58
78
|
if (!live) return;
|
|
59
79
|
setChoices([]);
|
|
@@ -70,21 +90,13 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
70
90
|
listingCwd,
|
|
71
91
|
hostId
|
|
72
92
|
]);
|
|
73
|
-
const pick = (choice) => {
|
|
74
|
-
setPicked(choice);
|
|
75
|
-
setFolder(null);
|
|
76
|
-
setBranch("");
|
|
77
|
-
setError(null);
|
|
78
|
-
setRemoveWorktree(false);
|
|
79
|
-
setBrowsing(choice.needsFolder && folderPicking(host, choice, subject) === "browse");
|
|
80
|
-
if (choice.needsFolder && folderPicking(host, choice, subject) === "native") pickNative();
|
|
81
|
-
};
|
|
82
93
|
async function pickNative() {
|
|
83
94
|
const chosen = await host?.pickFolder?.().catch(() => null);
|
|
84
95
|
if (chosen) setFolder(chosen);
|
|
85
96
|
}
|
|
86
97
|
const back = () => {
|
|
87
98
|
if (browsing && folder !== null) return setBrowsing(false);
|
|
99
|
+
if (onBack) return onBack();
|
|
88
100
|
setPicked(null);
|
|
89
101
|
setBrowsing(false);
|
|
90
102
|
setFolder(null);
|
|
@@ -135,7 +147,8 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
135
147
|
className: "m-0 mt-1 text-zg-ui text-[var(--zg-text-muted)]",
|
|
136
148
|
children: !picked ? labels.gitMoveWhere : browsing || shownFolder === null ? labels.gitMovePickFolder(picked.name) : subject.hasTurns ?? true ? labels.gitMoveConfirm(picked.name) : picked.name
|
|
137
149
|
})] }),
|
|
138
|
-
|
|
150
|
+
lead,
|
|
151
|
+
!picked && !initial && /* @__PURE__ */ jsx("div", {
|
|
139
152
|
role: "menu",
|
|
140
153
|
"aria-label": labels.gitMoveWhere,
|
|
141
154
|
className: "flex flex-col max-h-[min(360px,50vh)] overflow-y-auto",
|
|
@@ -156,6 +169,7 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
156
169
|
onClick: () => pick(choice)
|
|
157
170
|
}, choice.descriptor.kind))
|
|
158
171
|
}),
|
|
172
|
+
!picked && initial && choices === null && /* @__PURE__ */ jsx(MenuNote, { children: labels.gitMoveLoading }),
|
|
159
173
|
picked && browsing && /* @__PURE__ */ jsx(RemoteFolderBrowser, {
|
|
160
174
|
...subject.hostId !== void 0 ? { hostId: subject.hostId } : {},
|
|
161
175
|
...machine ? { machineId: machine.id } : {},
|
|
@@ -246,7 +260,7 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
246
260
|
className: buttonClass({ variant: "solid" }),
|
|
247
261
|
children: labels.gitMoveDone
|
|
248
262
|
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
249
|
-
picked && /* @__PURE__ */ jsx("button", {
|
|
263
|
+
(picked || onBack) && /* @__PURE__ */ jsx("button", {
|
|
250
264
|
type: "button",
|
|
251
265
|
onClick: back,
|
|
252
266
|
disabled: moving,
|
|
@@ -258,7 +272,7 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
258
272
|
onClick: onCancel,
|
|
259
273
|
disabled: moving,
|
|
260
274
|
className: buttonClass({ variant: "secondary" }),
|
|
261
|
-
children: labels.gitMoveCancel
|
|
275
|
+
children: cancelLabel ?? labels.gitMoveCancel
|
|
262
276
|
}),
|
|
263
277
|
/* @__PURE__ */ jsx("button", {
|
|
264
278
|
type: "button",
|
|
@@ -272,39 +286,4 @@ function MoveSessionDialog({ subject, onDone, onCancel, className, style }) {
|
|
|
272
286
|
})]
|
|
273
287
|
});
|
|
274
288
|
}
|
|
275
|
-
|
|
276
|
-
* Opens the move dialog above whatever is open, over the `GitHost` in context. `undefined` without what it needs
|
|
277
|
-
* (`GitHost.moveSession` and `environments`, a modal layer): hide the control that calls it. The returned function
|
|
278
|
-
* resolves `true` once the session moved, `false` when closed.
|
|
279
|
-
*/
|
|
280
|
-
function useMoveSession() {
|
|
281
|
-
const host = useGitHost();
|
|
282
|
-
const modal = useOptionalModal();
|
|
283
|
-
const openLayer = modal?.openLayer;
|
|
284
|
-
const closeLayer = modal?.closeLayer;
|
|
285
|
-
const offered = Boolean(host?.moveSession && host.environments && openLayer && closeLayer);
|
|
286
|
-
const open = useCallback((subject) => new Promise((resolve) => {
|
|
287
|
-
if (!openLayer || !closeLayer) return resolve(false);
|
|
288
|
-
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
289
|
-
const settle = (moved) => {
|
|
290
|
-
resolve(moved);
|
|
291
|
-
requestAnimationFrame(() => previousFocus?.focus());
|
|
292
|
-
};
|
|
293
|
-
openLayer(/* @__PURE__ */ jsx(MoveSessionDialog, {
|
|
294
|
-
subject,
|
|
295
|
-
onDone: () => {
|
|
296
|
-
closeLayer();
|
|
297
|
-
settle(true);
|
|
298
|
-
},
|
|
299
|
-
onCancel: () => {
|
|
300
|
-
closeLayer();
|
|
301
|
-
settle(false);
|
|
302
|
-
}
|
|
303
|
-
}), {
|
|
304
|
-
onDismiss: () => settle(false),
|
|
305
|
-
labelledBy: TITLE_ID
|
|
306
|
-
});
|
|
307
|
-
}), [openLayer, closeLayer]);
|
|
308
|
-
return offered ? open : void 0;
|
|
309
|
-
}
|
|
310
|
-
export { MoveSessionDialog, useMoveSession };
|
|
289
|
+
export { MOVE_SESSION_TITLE_ID, MoveSessionDialog };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Move to…": one dialog for every way a session can move (docs/TELEPORT.md, docs/ENVIRONMENTS.md), opened with
|
|
3
|
+
* `useMoveSession()`. Its first step is the new-chat where menu (`WhereMenu`): the hosts, their machines, and the
|
|
4
|
+
* ways to run there (the folder, a worktree, a sandbox), with where the session runs now checked.
|
|
5
|
+
*
|
|
6
|
+
* - Another way on the same host: the move (`MoveSessionDialog`: folder, branch, confirmation).
|
|
7
|
+
* - Another host: the teleport (`TeleportSessionDialog`: what changes, the work to bring, the folder there).
|
|
8
|
+
* - Another host and another way there: the teleport, then the move on the new host. A move that fails then leaves
|
|
9
|
+
* the session on the new host in its folder, and says so; "Keep it in its folder" ends there.
|
|
10
|
+
*
|
|
11
|
+
* Teleport needs the hosts (`MoveSessionOptions.hosts`) and `GitHost.teleportSession`; without them, the menu lists
|
|
12
|
+
* this host alone.
|
|
13
|
+
*
|
|
14
|
+
* const moveSession = useMoveSession()
|
|
15
|
+
* moveSession?.(moveSubject(session), { hosts, onMoved: done => open(done.sessionId) })
|
|
16
|
+
*/
|
|
17
|
+
import { HostView } from "../chat/headless/hosts.js";
|
|
18
|
+
import { MoveSessionSubject } from "./headless/move.js";
|
|
19
|
+
import { TeleportDone } from "./TeleportSessionDialog.js";
|
|
20
|
+
import { CSSProperties } from "react";
|
|
21
|
+
/** What {@link useMoveSession}'s dialog needs beyond the session. */
|
|
22
|
+
export interface MoveSessionOptions {
|
|
23
|
+
/** The hosts it may go to: This computer first, then the servers. Absent: its own host alone (no teleport). */
|
|
24
|
+
hosts?: readonly HostView[];
|
|
25
|
+
/** The session is on another host now: its id there (open it). */
|
|
26
|
+
onMoved?: (done: TeleportDone) => void;
|
|
27
|
+
}
|
|
28
|
+
/** Props for {@link MoveToDialog}. */
|
|
29
|
+
export interface MoveToDialogProps {
|
|
30
|
+
/** The session to move. */
|
|
31
|
+
subject: MoveSessionSubject;
|
|
32
|
+
/** The hosts it can go to, and what happens once it moved there. */
|
|
33
|
+
options?: MoveSessionOptions;
|
|
34
|
+
/** It moved: on its own host (`undefined`), or to another (where it is now). */
|
|
35
|
+
onDone: (done?: TeleportDone) => void;
|
|
36
|
+
/** Closed without a move. */
|
|
37
|
+
onCancel: () => void;
|
|
38
|
+
/** Whether a teleport is running (a dismiss then waits for its outcome). */
|
|
39
|
+
onBusy?: (busy: boolean) => void;
|
|
40
|
+
/** A teleport failed: its words, and the host's. */
|
|
41
|
+
onFailed?: (message: string, detail?: string) => void;
|
|
42
|
+
/** Whether the dialog was dismissed while a teleport ran: the teleport's outcome then ends it, with no step after. */
|
|
43
|
+
dismissed?: () => boolean;
|
|
44
|
+
/** Extra classes on the root. */
|
|
45
|
+
className?: string;
|
|
46
|
+
/** Inline styles on the root. */
|
|
47
|
+
style?: CSSProperties;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The Move to… dialog: where, then the move, the teleport, or both.
|
|
51
|
+
*
|
|
52
|
+
* @param props - The {@link MoveToDialogProps}.
|
|
53
|
+
*/
|
|
54
|
+
export declare function MoveToDialog({ subject, options, onDone, onCancel, onBusy, onFailed, dismissed, className, style }: MoveToDialogProps): import("react").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Opens Move to… above whatever is open, over the `GitHost` in context. `undefined` without what it needs
|
|
57
|
+
* (`GitHost.moveSession` and `environments`, a modal layer): hide the control that calls it. The returned function
|
|
58
|
+
* resolves `true` once the session moved (here or to another host, then `options.onMoved` says where), `false` when
|
|
59
|
+
* closed.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useMoveSession(): ((subject: MoveSessionSubject, options?: MoveSessionOptions) => Promise<boolean>) | undefined;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { useOptionalModal } from "../app/ModalProvider.js";
|
|
2
|
+
import { toast } from "../app/toast.js";
|
|
3
|
+
import { buttonClass } from "../components/button.js";
|
|
4
|
+
import { useGitHost, useGitLabels } from "./GitProvider.js";
|
|
5
|
+
import { resolveDraftDescriptor } from "./headless/environment.js";
|
|
6
|
+
import { moveListingCwd } from "./headless/move.js";
|
|
7
|
+
import { MOVE_SESSION_TITLE_ID, MoveSessionDialog } from "./MoveSessionDialog.js";
|
|
8
|
+
import { TeleportSessionDialog } from "./TeleportSessionDialog.js";
|
|
9
|
+
import { useEnvironmentChoices } from "./useEnvironmentChoices.js";
|
|
10
|
+
import { WhereMenu } from "./WherePicker.js";
|
|
11
|
+
import { useCallback, useState } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { isolationLabel } from "zidane/chat/pure";
|
|
14
|
+
// src/git/MoveToDialog.tsx
|
|
15
|
+
/** The id of This computer among the hosts (`HostView.id`). */
|
|
16
|
+
const LOCAL_ID = "local";
|
|
17
|
+
/** The session's own host, when the menu lists no other: from the hosts given (a web app's one server), else This computer. */
|
|
18
|
+
function ownHost(subject, hosts, localName) {
|
|
19
|
+
const id = subject.hostId ?? LOCAL_ID;
|
|
20
|
+
return hosts?.find((h) => h.id === id) ?? (hosts?.length === 1 ? {
|
|
21
|
+
...hosts[0],
|
|
22
|
+
id
|
|
23
|
+
} : void 0) ?? (subject.hostId ? {
|
|
24
|
+
id,
|
|
25
|
+
kind: "server",
|
|
26
|
+
name: subject.hostId,
|
|
27
|
+
status: "connected"
|
|
28
|
+
} : {
|
|
29
|
+
id,
|
|
30
|
+
kind: "local",
|
|
31
|
+
name: localName,
|
|
32
|
+
status: "local"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The Move to… dialog: where, then the move, the teleport, or both.
|
|
37
|
+
*
|
|
38
|
+
* @param props - The {@link MoveToDialogProps}.
|
|
39
|
+
*/
|
|
40
|
+
function MoveToDialog({ subject, options, onDone, onCancel, onBusy, onFailed, dismissed, className, style }) {
|
|
41
|
+
const host = useGitHost();
|
|
42
|
+
const labels = useGitLabels();
|
|
43
|
+
const hereId = subject.hostId ?? LOCAL_ID;
|
|
44
|
+
const nowKind = subject.kind ?? "local";
|
|
45
|
+
const hosts = Boolean(host?.teleportSession && host.teleportTargets) && options?.hosts?.some((h) => h.id === hereId) ? options.hosts : [ownHost(subject, options?.hosts, labels.gitRunsOnLocal)];
|
|
46
|
+
const [step, setStep] = useState({ kind: "where" });
|
|
47
|
+
const [hostId, setHostId] = useState(hereId);
|
|
48
|
+
const [draft, setDraft] = useState({
|
|
49
|
+
kind: nowKind,
|
|
50
|
+
branch: ""
|
|
51
|
+
});
|
|
52
|
+
const here = hostId === hereId;
|
|
53
|
+
const descriptors = useEnvironmentChoices(here ? moveListingCwd(subject) ?? "" : "", hostId === LOCAL_ID ? void 0 : hostId, here ? {} : { machineOnly: true });
|
|
54
|
+
const selected = resolveDraftDescriptor(descriptors, draft);
|
|
55
|
+
const same = here && (selected?.kind ?? "local") === nowKind;
|
|
56
|
+
const ready = !same && (!here || selected !== void 0);
|
|
57
|
+
const proceed = () => {
|
|
58
|
+
if (here && selected) return setStep({
|
|
59
|
+
kind: "move",
|
|
60
|
+
draft: {
|
|
61
|
+
kind: selected.kind,
|
|
62
|
+
branch: draft?.kind === selected.kind ? draft.branch : ""
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const extra = selected && !selected.isDefault && selected.kind !== "local" ? {
|
|
66
|
+
kind: selected.kind,
|
|
67
|
+
branch: draft?.kind === selected.kind ? draft.branch : ""
|
|
68
|
+
} : null;
|
|
69
|
+
setStep({
|
|
70
|
+
kind: "teleport",
|
|
71
|
+
hostId,
|
|
72
|
+
draft: extra,
|
|
73
|
+
label: extra && selected ? isolationLabel(selected) : void 0
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
if (step.kind === "move") return /* @__PURE__ */ jsx(MoveSessionDialog, {
|
|
77
|
+
subject,
|
|
78
|
+
initial: step.draft,
|
|
79
|
+
onBack: () => setStep({ kind: "where" }),
|
|
80
|
+
onDone: () => onDone(),
|
|
81
|
+
onCancel,
|
|
82
|
+
...className ? { className } : {},
|
|
83
|
+
...style ? { style } : {}
|
|
84
|
+
});
|
|
85
|
+
if (step.kind === "teleport") return /* @__PURE__ */ jsx(TeleportSessionDialog, {
|
|
86
|
+
subject: { sessionId: subject.sessionId },
|
|
87
|
+
target: step.hostId,
|
|
88
|
+
titleId: MOVE_SESSION_TITLE_ID,
|
|
89
|
+
...step.label ? { then: step.label } : {},
|
|
90
|
+
onBack: () => setStep({ kind: "where" }),
|
|
91
|
+
...onBusy ? { onBusy } : {},
|
|
92
|
+
...onFailed ? { onFailed } : {},
|
|
93
|
+
onDone: (done) => {
|
|
94
|
+
if (step.draft && step.label && !dismissed?.()) setStep({
|
|
95
|
+
kind: "then",
|
|
96
|
+
done,
|
|
97
|
+
draft: step.draft,
|
|
98
|
+
label: step.label
|
|
99
|
+
});
|
|
100
|
+
else onDone(done);
|
|
101
|
+
},
|
|
102
|
+
onCancel,
|
|
103
|
+
...className ? { className } : {},
|
|
104
|
+
...style ? { style } : {}
|
|
105
|
+
});
|
|
106
|
+
if (step.kind === "then") {
|
|
107
|
+
const { done } = step;
|
|
108
|
+
const there = hosts.find((h) => h.id === done.hostId)?.name ?? done.hostId;
|
|
109
|
+
return /* @__PURE__ */ jsx(MoveSessionDialog, {
|
|
110
|
+
subject: {
|
|
111
|
+
sessionId: done.sessionId,
|
|
112
|
+
cwd: done.cwd ?? "",
|
|
113
|
+
...done.hostId === LOCAL_ID ? {} : { hostId: done.hostId },
|
|
114
|
+
kind: "local",
|
|
115
|
+
hasTurns: true
|
|
116
|
+
},
|
|
117
|
+
initial: step.draft,
|
|
118
|
+
lead: /* @__PURE__ */ jsx("p", {
|
|
119
|
+
className: "m-0 text-zg-label text-[var(--zg-text-muted)]",
|
|
120
|
+
"data-testid": "move-then",
|
|
121
|
+
children: labels.gitMoveThen(there, step.label)
|
|
122
|
+
}),
|
|
123
|
+
cancelLabel: labels.gitMoveKeepThere,
|
|
124
|
+
onDone: () => onDone(done),
|
|
125
|
+
onCancel: () => onDone(done),
|
|
126
|
+
...className ? { className } : {},
|
|
127
|
+
...style ? { style } : {}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
className: `zg-modal-panel zg-float w-[400px] max-w-[92vw] flex flex-col overflow-hidden${className ? ` ${className}` : ""}`,
|
|
132
|
+
style,
|
|
133
|
+
"data-testid": "move-to-dialog",
|
|
134
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsxs("div", {
|
|
137
|
+
className: "px-5 pt-4 pb-2",
|
|
138
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
139
|
+
id: MOVE_SESSION_TITLE_ID,
|
|
140
|
+
className: "m-0 text-sm font-semibold text-[var(--zg-text)] zg-balance",
|
|
141
|
+
children: labels.gitMoveTitle
|
|
142
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
143
|
+
className: "m-0 mt-1 text-zg-ui text-[var(--zg-text-muted)]",
|
|
144
|
+
children: same ? labels.gitMoveHere : labels.gitMoveWhere
|
|
145
|
+
})]
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ jsx("div", {
|
|
148
|
+
className: "px-3 pb-2 max-h-[min(440px,60vh)] overflow-y-auto",
|
|
149
|
+
children: /* @__PURE__ */ jsx(WhereMenu, {
|
|
150
|
+
hosts,
|
|
151
|
+
hostId,
|
|
152
|
+
onHostChange: (next) => {
|
|
153
|
+
setHostId(next);
|
|
154
|
+
setDraft(next === hereId ? {
|
|
155
|
+
kind: nowKind,
|
|
156
|
+
branch: ""
|
|
157
|
+
} : null);
|
|
158
|
+
},
|
|
159
|
+
descriptors,
|
|
160
|
+
draft,
|
|
161
|
+
onChange: setDraft,
|
|
162
|
+
...hosts.some((h) => h.kind === "local") ? {} : { local: false }
|
|
163
|
+
})
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ jsxs("footer", {
|
|
166
|
+
className: "flex items-center justify-end gap-2 px-5 py-3 bg-[var(--zg-tray)]",
|
|
167
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
168
|
+
type: "button",
|
|
169
|
+
onClick: onCancel,
|
|
170
|
+
className: buttonClass({ variant: "secondary" }),
|
|
171
|
+
children: labels.gitMoveCancel
|
|
172
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
173
|
+
type: "button",
|
|
174
|
+
"data-testid": "move-continue",
|
|
175
|
+
disabled: !ready,
|
|
176
|
+
onClick: proceed,
|
|
177
|
+
className: buttonClass({ variant: "solid" }),
|
|
178
|
+
children: labels.gitMoveContinue
|
|
179
|
+
})]
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Opens Move to… above whatever is open, over the `GitHost` in context. `undefined` without what it needs
|
|
186
|
+
* (`GitHost.moveSession` and `environments`, a modal layer): hide the control that calls it. The returned function
|
|
187
|
+
* resolves `true` once the session moved (here or to another host, then `options.onMoved` says where), `false` when
|
|
188
|
+
* closed.
|
|
189
|
+
*/
|
|
190
|
+
function useMoveSession() {
|
|
191
|
+
const host = useGitHost();
|
|
192
|
+
const modal = useOptionalModal();
|
|
193
|
+
const openLayer = modal?.openLayer;
|
|
194
|
+
const closeLayer = modal?.closeLayer;
|
|
195
|
+
const offered = Boolean(host?.moveSession && host.environments && openLayer && closeLayer);
|
|
196
|
+
const open = useCallback((subject, options) => new Promise((resolve) => {
|
|
197
|
+
if (!openLayer || !closeLayer) return resolve(false);
|
|
198
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
199
|
+
let running = false;
|
|
200
|
+
let dismissed = false;
|
|
201
|
+
let settled = false;
|
|
202
|
+
const settle = (moved, done) => {
|
|
203
|
+
if (settled) return;
|
|
204
|
+
settled = true;
|
|
205
|
+
if (done) options?.onMoved?.(done);
|
|
206
|
+
resolve(moved);
|
|
207
|
+
requestAnimationFrame(() => previousFocus?.focus());
|
|
208
|
+
};
|
|
209
|
+
openLayer(/* @__PURE__ */ jsx(MoveToDialog, {
|
|
210
|
+
subject,
|
|
211
|
+
...options ? { options } : {},
|
|
212
|
+
dismissed: () => dismissed,
|
|
213
|
+
onBusy: (busy) => {
|
|
214
|
+
running = busy;
|
|
215
|
+
},
|
|
216
|
+
onFailed: (message, detail) => {
|
|
217
|
+
if (dismissed) {
|
|
218
|
+
toast.error(message, detail ? { description: detail } : void 0);
|
|
219
|
+
settle(false);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
onDone: (done) => {
|
|
223
|
+
if (!dismissed) closeLayer();
|
|
224
|
+
settle(true, done);
|
|
225
|
+
},
|
|
226
|
+
onCancel: () => {
|
|
227
|
+
closeLayer();
|
|
228
|
+
settle(false);
|
|
229
|
+
}
|
|
230
|
+
}), {
|
|
231
|
+
onDismiss: () => {
|
|
232
|
+
if (running) dismissed = true;
|
|
233
|
+
else settle(false);
|
|
234
|
+
},
|
|
235
|
+
labelledBy: MOVE_SESSION_TITLE_ID
|
|
236
|
+
});
|
|
237
|
+
}), [openLayer, closeLayer]);
|
|
238
|
+
return offered ? open : void 0;
|
|
239
|
+
}
|
|
240
|
+
export { MoveToDialog, useMoveSession };
|
|
@@ -30,6 +30,7 @@ const SandboxRow = memo(({ entry, source, onChanged, onOpenSession }) => {
|
|
|
30
30
|
const replacedTip = useTooltip(session && !session.current ? labels.sandboxReplacedHint(session.title) : null);
|
|
31
31
|
const linked = session?.current === true;
|
|
32
32
|
const stateWord = entry.state === "other" && entry.providerState ? entry.providerState : labels.sandboxStates[entry.state];
|
|
33
|
+
const stateTip = useTooltip(entry.state === "failed" && entry.reason ? entry.reason : null);
|
|
33
34
|
const age = entry.createdAt !== void 0 && readAt ? relativeTime(entry.createdAt, readAt, chatLabels) : void 0;
|
|
34
35
|
const act = (run, failed) => {
|
|
35
36
|
setBusy(true);
|
|
@@ -77,10 +78,14 @@ const SandboxRow = memo(({ entry, source, onChanged, onOpenSession }) => {
|
|
|
77
78
|
className: "text-zg-ui text-[var(--zg-text-muted)] truncate",
|
|
78
79
|
children: labels.sandboxUnlinked
|
|
79
80
|
}),
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
|
|
82
|
-
className: "
|
|
83
|
-
children:
|
|
81
|
+
/* @__PURE__ */ jsxs("span", {
|
|
82
|
+
...stateTip.anchorProps,
|
|
83
|
+
className: "inline-flex",
|
|
84
|
+
children: [/* @__PURE__ */ jsx(MetaChip, {
|
|
85
|
+
tone: entry.state === "running" ? "success" : entry.state === "failed" ? "danger" : entry.state === "other" ? "warn" : "muted",
|
|
86
|
+
className: "ml-0.5",
|
|
87
|
+
children: stateWord
|
|
88
|
+
}), stateTip.tip]
|
|
84
89
|
}),
|
|
85
90
|
session && !session.current && /* @__PURE__ */ jsxs("span", {
|
|
86
91
|
...replacedTip.anchorProps,
|
package/dist/git/SyncChip.js
CHANGED
|
@@ -31,10 +31,17 @@ function SyncChip({ status, cwd, sessionId, running, onSynced, confirm = true, o
|
|
|
31
31
|
const confirmRef = useRef(null);
|
|
32
32
|
const counts = status.ahead > 0 || status.behind > 0;
|
|
33
33
|
const level = status.upstream !== null && !counts;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const [seen, setSeen] = useState({
|
|
35
|
+
running,
|
|
36
|
+
cwd
|
|
37
|
+
});
|
|
38
|
+
if (seen.running !== running || seen.cwd !== cwd) {
|
|
39
|
+
setSeen({
|
|
40
|
+
running,
|
|
41
|
+
cwd
|
|
42
|
+
});
|
|
43
|
+
if (running || seen.cwd !== cwd) setPopover(null);
|
|
44
|
+
}
|
|
38
45
|
useEffect(() => {
|
|
39
46
|
if (!popover) return void 0;
|
|
40
47
|
if (popover.kind === "confirm") requestAnimationFrame(() => confirmRef.current?.focus());
|