@tt-a1i/hive 1.4.2 → 1.4.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/CHANGELOG.md +33 -0
- package/README.en.md +5 -4
- package/README.md +1 -1
- package/dist/src/cli/hive-update.d.ts +32 -0
- package/dist/src/cli/hive-update.js +113 -22
- package/dist/src/cli/hive.d.ts +32 -0
- package/dist/src/cli/hive.js +72 -17
- package/dist/src/cli/team.js +17 -5
- package/dist/src/server/agent-command-resolver.d.ts +10 -1
- package/dist/src/server/agent-command-resolver.js +48 -4
- package/dist/src/server/agent-launch-resolver.js +9 -3
- package/dist/src/server/agent-manager-support.d.ts +28 -0
- package/dist/src/server/agent-manager-support.js +58 -4
- package/dist/src/server/agent-run-bootstrap.d.ts +17 -1
- package/dist/src/server/agent-run-bootstrap.js +30 -2
- package/dist/src/server/agent-startup-instructions.js +1 -1
- package/dist/src/server/app.d.ts +1 -0
- package/dist/src/server/app.js +12 -2
- package/dist/src/server/fs-browse.d.ts +14 -1
- package/dist/src/server/fs-browse.js +48 -5
- package/dist/src/server/fs-pick-folder.js +54 -11
- package/dist/src/server/hive-team-guidance.js +5 -4
- package/dist/src/server/open-target-commands.js +30 -4
- package/dist/src/server/post-start-input-writer.js +6 -3
- package/dist/src/server/routes-team.js +10 -1
- package/dist/src/server/runtime-store.d.ts +3 -1
- package/dist/src/server/session-capture-claude.d.ts +23 -0
- package/dist/src/server/session-capture-claude.js +24 -1
- package/dist/src/server/session-capture-opencode.d.ts +18 -0
- package/dist/src/server/session-capture-opencode.js +27 -2
- package/dist/src/server/startup-command-parser.d.ts +15 -0
- package/dist/src/server/startup-command-parser.js +33 -2
- package/dist/src/server/tasks-file-watcher.d.ts +26 -0
- package/dist/src/server/tasks-file-watcher.js +29 -3
- package/dist/src/server/team-operations.d.ts +5 -1
- package/dist/src/server/team-operations.js +44 -3
- package/dist/src/server/terminal-input-profile.js +2 -8
- package/dist/src/server/terminal-ws-server.js +26 -8
- package/package.json +2 -2
- package/web/dist/assets/{AddWorkerDialog-D-XO6MoI.js → AddWorkerDialog-DeZhTQLi.js} +2 -2
- package/web/dist/assets/AddWorkspaceDialog-DDpXNEKf.js +1 -0
- package/web/dist/assets/{FirstRunWizard-xHiver2Q.js → FirstRunWizard-B5wLcat5.js} +1 -1
- package/web/dist/assets/{MarketplaceDrawer-CqE8_4ZP.js → MarketplaceDrawer-BC0eBOEW.js} +1 -1
- package/web/dist/assets/{WorkerModal-DgOuzZMW.js → WorkerModal-BwMHq-Bi.js} +1 -1
- package/web/dist/assets/WorkspaceTaskDrawer-CxvT4nqs.js +1 -0
- package/web/dist/assets/{WorkspaceTerminalPanels-BqEcvvSH.js → WorkspaceTerminalPanels-CvibsPSd.js} +1 -1
- package/web/dist/assets/index-Ddb7bDN5.js +75 -0
- package/web/dist/assets/path-join-S7qkXQtP.js +1 -0
- package/web/dist/index.html +1 -1
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/AddWorkspaceDialog-D4InpBpd.js +0 -1
- package/web/dist/assets/WorkspaceTaskDrawer-D0Y-Gyvw.js +0 -1
- package/web/dist/assets/chevron-right-Bmg7DcUj.js +0 -1
- package/web/dist/assets/index-CWW5vUjQ.js +0 -76
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the path OpenCode upstream writes `opencode.db` to. Branches
|
|
3
|
+
* by platform because XDG_DATA_HOME is not a Windows convention — the
|
|
4
|
+
* previous unconditional ~/.local/share/opencode/opencode.db default
|
|
5
|
+
* pointed at a path that never exists on Windows, silently breaking
|
|
6
|
+
* Layer A native session resume for OpenCode workers there.
|
|
7
|
+
*
|
|
8
|
+
* Resolution order:
|
|
9
|
+
* 1. HIVE_OPENCODE_DB_PATH override (any platform, for tests/users).
|
|
10
|
+
* 2. Windows: %LOCALAPPDATA%\opencode\opencode.db (with a homedir
|
|
11
|
+
* fallback when LOCALAPPDATA is missing — some shells strip env).
|
|
12
|
+
* 3. POSIX: $XDG_DATA_HOME/opencode/opencode.db, falling back to
|
|
13
|
+
* ~/.local/share/opencode/opencode.db.
|
|
14
|
+
*
|
|
15
|
+
* Exported so the path-resolution rules can be unit-tested without
|
|
16
|
+
* needing to mock the underlying SQLite open.
|
|
17
|
+
*/
|
|
18
|
+
export declare const getDefaultOpenCodeDbPath: (platform?: NodeJS.Platform) => string;
|
|
1
19
|
export declare const getOpenCodeDbPath: (pattern?: string) => string;
|
|
2
20
|
export declare const hasOpenCodeSession: (cwd: string, sessionId: string, pattern?: string) => boolean;
|
|
3
21
|
export declare const snapshotOpenCodeSessionIds: (cwd: string, dbPath?: string) => Set<string>;
|
|
@@ -4,8 +4,33 @@ import { join } from 'node:path';
|
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
5
|
import { captureSessionIdWithCoordinator } from './claude-session-coordinator.js';
|
|
6
6
|
const expandHome = (path) => path === '~' || path.startsWith('~/') ? join(homedir(), path.slice(2)) : path;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the path OpenCode upstream writes `opencode.db` to. Branches
|
|
9
|
+
* by platform because XDG_DATA_HOME is not a Windows convention — the
|
|
10
|
+
* previous unconditional ~/.local/share/opencode/opencode.db default
|
|
11
|
+
* pointed at a path that never exists on Windows, silently breaking
|
|
12
|
+
* Layer A native session resume for OpenCode workers there.
|
|
13
|
+
*
|
|
14
|
+
* Resolution order:
|
|
15
|
+
* 1. HIVE_OPENCODE_DB_PATH override (any platform, for tests/users).
|
|
16
|
+
* 2. Windows: %LOCALAPPDATA%\opencode\opencode.db (with a homedir
|
|
17
|
+
* fallback when LOCALAPPDATA is missing — some shells strip env).
|
|
18
|
+
* 3. POSIX: $XDG_DATA_HOME/opencode/opencode.db, falling back to
|
|
19
|
+
* ~/.local/share/opencode/opencode.db.
|
|
20
|
+
*
|
|
21
|
+
* Exported so the path-resolution rules can be unit-tested without
|
|
22
|
+
* needing to mock the underlying SQLite open.
|
|
23
|
+
*/
|
|
24
|
+
export const getDefaultOpenCodeDbPath = (platform = process.platform) => {
|
|
25
|
+
const override = process.env.HIVE_OPENCODE_DB_PATH;
|
|
26
|
+
if (override)
|
|
27
|
+
return override;
|
|
28
|
+
if (platform === 'win32') {
|
|
29
|
+
const localAppData = process.env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local');
|
|
30
|
+
return join(localAppData, 'opencode', 'opencode.db');
|
|
31
|
+
}
|
|
32
|
+
return join(process.env.XDG_DATA_HOME ?? join(homedir(), '.local', 'share'), 'opencode', 'opencode.db');
|
|
33
|
+
};
|
|
9
34
|
export const getOpenCodeDbPath = (pattern) => pattern === '~/.local/share/opencode/opencode.db' || !pattern
|
|
10
35
|
? getDefaultOpenCodeDbPath()
|
|
11
36
|
: expandHome(pattern);
|
|
@@ -3,3 +3,18 @@ export declare const createStartupCommandLaunch: (startupCommand: string, env?:
|
|
|
3
3
|
command: string;
|
|
4
4
|
};
|
|
5
5
|
export declare const getStartupCommandExecutable: (startupCommand: string) => string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Reduce an executable token to its canonical brand id for preset lookup
|
|
8
|
+
* and CLI-behavior dispatch. Splits on both '\\' and '/' so Windows paths
|
|
9
|
+
* normalize even when the host runs `node:path.posix` (macOS test runners,
|
|
10
|
+
* mixed-slash paths from npm-installed shims).
|
|
11
|
+
*
|
|
12
|
+
* Examples (return value in parens):
|
|
13
|
+
* 'claude' → 'claude'
|
|
14
|
+
* 'claude.CMD' → 'claude'
|
|
15
|
+
* 'C:\\Program Files\\nodejs\\claude.cmd' → 'claude'
|
|
16
|
+
* '/usr/local/bin/codex' → 'codex'
|
|
17
|
+
* 'C:/Users/me/opencode.CMD' → 'opencode'
|
|
18
|
+
* 'my-custom-runner.bat' → 'my-custom-runner'
|
|
19
|
+
*/
|
|
20
|
+
export declare const normalizeExecutableToken: (token: string | null | undefined) => string | null;
|
|
@@ -32,6 +32,37 @@ export const getStartupCommandExecutable = (startupCommand) => {
|
|
|
32
32
|
const command = startupCommand.trim();
|
|
33
33
|
if (!command)
|
|
34
34
|
return null;
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
// Match alternates, in order:
|
|
36
|
+
// 1. Double-quoted token (may contain spaces, backslashes, slashes)
|
|
37
|
+
// 2. Single-quoted token
|
|
38
|
+
// 3. Bare token: no whitespace, no embedded quotes
|
|
39
|
+
// An unbalanced opening quote falls through all three and returns null.
|
|
40
|
+
// The previous regex used `[^'"\s]+` for the captured run, which forbade
|
|
41
|
+
// spaces and therefore returned null for `"C:\Program Files\…claude.cmd"`
|
|
42
|
+
// — the standard Windows install layout. See the parser tests for the
|
|
43
|
+
// contract; brand identification belongs in agent-launch-resolver.
|
|
44
|
+
const match = /^"([^"]+)"|^'([^']+)'|^([^\s'"]+)/.exec(command);
|
|
45
|
+
return match?.[1] ?? match?.[2] ?? match?.[3] ?? null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Reduce an executable token to its canonical brand id for preset lookup
|
|
49
|
+
* and CLI-behavior dispatch. Splits on both '\\' and '/' so Windows paths
|
|
50
|
+
* normalize even when the host runs `node:path.posix` (macOS test runners,
|
|
51
|
+
* mixed-slash paths from npm-installed shims).
|
|
52
|
+
*
|
|
53
|
+
* Examples (return value in parens):
|
|
54
|
+
* 'claude' → 'claude'
|
|
55
|
+
* 'claude.CMD' → 'claude'
|
|
56
|
+
* 'C:\\Program Files\\nodejs\\claude.cmd' → 'claude'
|
|
57
|
+
* '/usr/local/bin/codex' → 'codex'
|
|
58
|
+
* 'C:/Users/me/opencode.CMD' → 'opencode'
|
|
59
|
+
* 'my-custom-runner.bat' → 'my-custom-runner'
|
|
60
|
+
*/
|
|
61
|
+
export const normalizeExecutableToken = (token) => {
|
|
62
|
+
if (!token)
|
|
63
|
+
return null;
|
|
64
|
+
const lastSegment = token.replace(/^.*[\\/]/, '');
|
|
65
|
+
if (!lastSegment)
|
|
66
|
+
return null;
|
|
67
|
+
return lastSegment.toLowerCase().replace(/\.(cmd|bat|exe|ps1)$/u, '');
|
|
37
68
|
};
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import { type ChokidarOptions } from 'chokidar';
|
|
2
|
+
/**
|
|
3
|
+
* Watcher configuration. The atomic-save option matters on Windows: VS
|
|
4
|
+
* Code, Cursor, Notepad++, and the editor inside Hive itself all save
|
|
5
|
+
* by writing a temp file and renaming it over the target. On
|
|
6
|
+
* ReadDirectoryChangesW (Windows' native fs-event backend) that rename
|
|
7
|
+
* invalidates the file-handle the chokidar watcher held for the
|
|
8
|
+
* single-file path, and subsequent edits would emit no events at all.
|
|
9
|
+
*
|
|
10
|
+
* `atomic: 100` tells chokidar to correlate an unlink+add pair within
|
|
11
|
+
* a 100ms window as a single `change` event — collapsing the rename
|
|
12
|
+
* into one logical "the file was modified" notification and rebinding
|
|
13
|
+
* the underlying watch handle. Without it the tasks panel goes deaf
|
|
14
|
+
* to changes the user makes outside the app after the first save.
|
|
15
|
+
*
|
|
16
|
+
* We intentionally do NOT set `awaitWriteFinish` here. It would help
|
|
17
|
+
* even more on Windows (waits for the file size to stabilise before
|
|
18
|
+
* emitting), but it also throttles every emission by `stabilityThreshold`
|
|
19
|
+
* — clashing with continuous-write workflows (a worker streaming
|
|
20
|
+
* updates into tasks.md every 100ms would never see an emit). The
|
|
21
|
+
* `atomic` option alone covers atomic-save; if a future workspace
|
|
22
|
+
* needs stronger settling behaviour we can promote it then.
|
|
23
|
+
*
|
|
24
|
+
* Exported so the configuration is testable in isolation.
|
|
25
|
+
*/
|
|
26
|
+
export declare const TASKS_WATCHER_OPTIONS: ChokidarOptions;
|
|
1
27
|
export interface TasksFileWatcher {
|
|
2
28
|
close: () => Promise<void>;
|
|
3
29
|
start: (workspaceId: string, workspacePath: string) => Promise<void>;
|
|
@@ -3,6 +3,34 @@ import { readFile } from 'node:fs/promises';
|
|
|
3
3
|
import chokidar from 'chokidar';
|
|
4
4
|
import { ensureProtocolFile, ensureTasksFile, getTasksFilePath } from './tasks-file.js';
|
|
5
5
|
const DEBOUNCE_MS = 100;
|
|
6
|
+
/**
|
|
7
|
+
* Watcher configuration. The atomic-save option matters on Windows: VS
|
|
8
|
+
* Code, Cursor, Notepad++, and the editor inside Hive itself all save
|
|
9
|
+
* by writing a temp file and renaming it over the target. On
|
|
10
|
+
* ReadDirectoryChangesW (Windows' native fs-event backend) that rename
|
|
11
|
+
* invalidates the file-handle the chokidar watcher held for the
|
|
12
|
+
* single-file path, and subsequent edits would emit no events at all.
|
|
13
|
+
*
|
|
14
|
+
* `atomic: 100` tells chokidar to correlate an unlink+add pair within
|
|
15
|
+
* a 100ms window as a single `change` event — collapsing the rename
|
|
16
|
+
* into one logical "the file was modified" notification and rebinding
|
|
17
|
+
* the underlying watch handle. Without it the tasks panel goes deaf
|
|
18
|
+
* to changes the user makes outside the app after the first save.
|
|
19
|
+
*
|
|
20
|
+
* We intentionally do NOT set `awaitWriteFinish` here. It would help
|
|
21
|
+
* even more on Windows (waits for the file size to stabilise before
|
|
22
|
+
* emitting), but it also throttles every emission by `stabilityThreshold`
|
|
23
|
+
* — clashing with continuous-write workflows (a worker streaming
|
|
24
|
+
* updates into tasks.md every 100ms would never see an emit). The
|
|
25
|
+
* `atomic` option alone covers atomic-save; if a future workspace
|
|
26
|
+
* needs stronger settling behaviour we can promote it then.
|
|
27
|
+
*
|
|
28
|
+
* Exported so the configuration is testable in isolation.
|
|
29
|
+
*/
|
|
30
|
+
export const TASKS_WATCHER_OPTIONS = {
|
|
31
|
+
atomic: 100,
|
|
32
|
+
ignoreInitial: true,
|
|
33
|
+
};
|
|
6
34
|
export const createTasksFileWatcher = ({ onTasksUpdated, }) => {
|
|
7
35
|
const watchers = new Map();
|
|
8
36
|
const timers = new Map();
|
|
@@ -39,9 +67,7 @@ export const createTasksFileWatcher = ({ onTasksUpdated, }) => {
|
|
|
39
67
|
await stop(workspaceId);
|
|
40
68
|
ensureTasksFile(workspacePath);
|
|
41
69
|
ensureProtocolFile(workspacePath);
|
|
42
|
-
const watcher = chokidar.watch(getTasksFilePath(workspacePath),
|
|
43
|
-
ignoreInitial: true,
|
|
44
|
-
});
|
|
70
|
+
const watcher = chokidar.watch(getTasksFilePath(workspacePath), TASKS_WATCHER_OPTIONS);
|
|
45
71
|
const scheduleEmit = () => {
|
|
46
72
|
clearTimer(workspaceId);
|
|
47
73
|
timers.set(workspaceId, setTimeout(() => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { TeamListItem } from '../shared/types.js';
|
|
1
2
|
import type { AgentRuntime } from './agent-runtime.js';
|
|
2
3
|
import type { DispatchRecord } from './dispatch-ledger-store.js';
|
|
3
4
|
import type { MessageLogHandle, MessageLogRecord } from './message-log-store.js';
|
|
4
5
|
import type { WorkspaceStore } from './workspace-store.js';
|
|
6
|
+
export declare const formatUnknownWorkerError: (workerName: string, roster: readonly TeamListItem[]) => string;
|
|
5
7
|
export interface TeamOperationsInput {
|
|
6
8
|
agentRuntime: AgentRuntime;
|
|
7
9
|
createDispatch: (input: {
|
|
@@ -62,7 +64,9 @@ export declare const createTeamOperations: ({ agentRuntime, createDispatch, dele
|
|
|
62
64
|
forwarded: boolean;
|
|
63
65
|
};
|
|
64
66
|
dispatchTask: (workspaceId: string, workerId: string, text: string, input?: DispatchTaskInput) => Promise<DispatchRecord>;
|
|
65
|
-
dispatchTaskByWorkerName(workspaceId: string, workerName: string, text: string, input?: DispatchTaskInput): Promise<DispatchRecord
|
|
67
|
+
dispatchTaskByWorkerName(workspaceId: string, workerName: string, text: string, input?: DispatchTaskInput): Promise<DispatchRecord & {
|
|
68
|
+
restartedWorker: boolean;
|
|
69
|
+
}>;
|
|
66
70
|
recordUserInput(workspaceId: string, orchestratorId: string, text: string): void;
|
|
67
71
|
statusTask(workspaceId: string, workerId: string, input?: StatusTaskInput): {
|
|
68
72
|
dispatch: null;
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { ConflictError, PtyInactiveError } from './http-errors.js';
|
|
2
2
|
import { createReportMessage, createSendMessage, createStatusMessage, createUserInputMessage, } from './runtime-message-builders.js';
|
|
3
|
+
/* Roster snapshot embedded in the 409 the orchestrator sees when it
|
|
4
|
+
dispatches to a missing name. Format prioritizes the orchestrator's
|
|
5
|
+
parsing path: bullet-per-member with role + live status + pending
|
|
6
|
+
count, plus an explicit retry hint that names both fix-up paths
|
|
7
|
+
(direct send to a listed name, or re-`team list` if it doubts the
|
|
8
|
+
snapshot). Keeping role/status/pending inline saves a follow-up
|
|
9
|
+
`team list` round-trip — the orchestrator can re-pick in the same
|
|
10
|
+
turn. */
|
|
11
|
+
export const formatUnknownWorkerError = (workerName, roster) => {
|
|
12
|
+
if (roster.length === 0) {
|
|
13
|
+
return [
|
|
14
|
+
`Unknown worker "${workerName}": this workspace currently has no workers.`,
|
|
15
|
+
'Ask the user to add a worker in the Hive UI (Add Worker), then run `team list` and retry.',
|
|
16
|
+
].join('\n');
|
|
17
|
+
}
|
|
18
|
+
const lines = roster.map((entry) => ` - ${entry.name} (${entry.role}, ${entry.status}, ${entry.pendingTaskCount} pending)`);
|
|
19
|
+
return [
|
|
20
|
+
`Unknown worker "${workerName}" in this workspace. Current members:`,
|
|
21
|
+
...lines,
|
|
22
|
+
'Retry with `team send "<one of the names above>" "<task>"`, or run `team list` to refresh the roster.',
|
|
23
|
+
].join('\n');
|
|
24
|
+
};
|
|
3
25
|
const reportForwardErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
4
26
|
export const createTeamOperations = ({ agentRuntime, createDispatch, deleteDispatch, deleteMessage, findOpenDispatch, findOpenDispatchById, insertMessage, markDispatchCancelled, markDispatchReportedByWorker, markDispatchSubmitted, workspaceStore, }) => {
|
|
5
27
|
const ensureWorkerRun = async (workspaceId, workerId, hivePort) => {
|
|
@@ -82,9 +104,28 @@ export const createTeamOperations = ({ agentRuntime, createDispatch, deleteDispa
|
|
|
82
104
|
return { dispatch, forwardError, forwarded };
|
|
83
105
|
},
|
|
84
106
|
dispatchTask,
|
|
85
|
-
dispatchTaskByWorkerName(workspaceId, workerName, text, input = {}) {
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
async dispatchTaskByWorkerName(workspaceId, workerName, text, input = {}) {
|
|
108
|
+
/* Build the roster once so a missing-name path can surface it without
|
|
109
|
+
a second store call. We deliberately don't go through
|
|
110
|
+
`getWorkerByName` because its underlying record helper throws a
|
|
111
|
+
bare Error — that bubbles as HTTP 500 and looks like a server bug
|
|
112
|
+
to the orchestrator, instead of the self-healing 409 we want. */
|
|
113
|
+
const roster = workspaceStore.listWorkers(workspaceId);
|
|
114
|
+
const worker = roster.find((entry) => entry.name === workerName);
|
|
115
|
+
if (!worker) {
|
|
116
|
+
throw new ConflictError(formatUnknownWorkerError(workerName, roster));
|
|
117
|
+
}
|
|
118
|
+
/* Capture the active-run state *before* dispatchTask runs, because
|
|
119
|
+
dispatchTask calls ensureWorkerRun on authenticated team-send calls
|
|
120
|
+
and may silently auto-start a stopped worker. Surfacing
|
|
121
|
+
`restartedWorker=true` to the orchestrator turns that silent state
|
|
122
|
+
change into a transparent one. Internal calls without `fromAgentId`
|
|
123
|
+
only queue work and do not wake a PTY, so they must not report a
|
|
124
|
+
restart. */
|
|
125
|
+
const restartedWorker = input.fromAgentId !== undefined &&
|
|
126
|
+
!agentRuntime.getActiveRunByAgentId(workspaceId, worker.id);
|
|
127
|
+
const dispatch = await dispatchTask(workspaceId, worker.id, text, input);
|
|
128
|
+
return Object.assign(dispatch, { restartedWorker });
|
|
88
129
|
},
|
|
89
130
|
recordUserInput(workspaceId, orchestratorId, text) {
|
|
90
131
|
workspaceStore.getAgent(workspaceId, orchestratorId);
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const normalizeExecutable = (value) => {
|
|
3
|
-
if (!value)
|
|
4
|
-
return null;
|
|
5
|
-
const normalized = basename(value).toLowerCase();
|
|
6
|
-
return normalized.replace(/\.(cmd|exe)$/u, '');
|
|
7
|
-
};
|
|
1
|
+
import { normalizeExecutableToken } from './startup-command-parser.js';
|
|
8
2
|
export const resolveTerminalInputProfile = (config) => {
|
|
9
3
|
if (!config)
|
|
10
4
|
return 'default';
|
|
11
5
|
if (config.commandPresetId === 'opencode')
|
|
12
6
|
return 'opencode';
|
|
13
|
-
const executable =
|
|
7
|
+
const executable = normalizeExecutableToken(config.interactiveCommand) ?? normalizeExecutableToken(config.command);
|
|
14
8
|
return executable === 'opencode' ? 'opencode' : 'default';
|
|
15
9
|
};
|
|
@@ -43,6 +43,26 @@ export const createTerminalWebSocketServer = (server, store, tasksFileService) =
|
|
|
43
43
|
const token = readCookie(cookieHeader, 'hive_ui_token');
|
|
44
44
|
return store.validateUiToken(token);
|
|
45
45
|
};
|
|
46
|
+
let closed = false;
|
|
47
|
+
const closeAll = () => {
|
|
48
|
+
if (closed)
|
|
49
|
+
return;
|
|
50
|
+
closed = true;
|
|
51
|
+
// Order matters: dispose the publisher first so no new frames are
|
|
52
|
+
// queued onto sockets that are about to be torn down. Then forcibly
|
|
53
|
+
// terminate any open WS clients (terminate() skips the close
|
|
54
|
+
// handshake, which is what we need — a polite ws.close() would wait
|
|
55
|
+
// on the remote side and re-introduce the hang we're fixing).
|
|
56
|
+
disposeTasksListener();
|
|
57
|
+
for (const ws of ioWss.clients)
|
|
58
|
+
ws.terminate();
|
|
59
|
+
for (const ws of controlWss.clients)
|
|
60
|
+
ws.terminate();
|
|
61
|
+
tasksWss.close();
|
|
62
|
+
ioWss.close();
|
|
63
|
+
controlWss.close();
|
|
64
|
+
hub.close();
|
|
65
|
+
};
|
|
46
66
|
server.on('upgrade', (request, socket, head) => {
|
|
47
67
|
const url = new URL(request.url ?? '/', 'http://127.0.0.1');
|
|
48
68
|
const pathname = url.pathname;
|
|
@@ -78,12 +98,10 @@ export const createTerminalWebSocketServer = (server, store, tasksFileService) =
|
|
|
78
98
|
hub.attachControl(match.runId, clientId, ws, getInitialSize(url));
|
|
79
99
|
});
|
|
80
100
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
return { close: () => hub.close() };
|
|
101
|
+
// Kept as an idempotent fallback for callers that drive
|
|
102
|
+
// `app.server.close()` directly (e.g. unit tests in tests/server/*)
|
|
103
|
+
// and never see the runHiveCommand close path. closeAll() is guarded
|
|
104
|
+
// by `closed` so calling both is a no-op.
|
|
105
|
+
server.on('close', closeAll);
|
|
106
|
+
return { close: closeAll };
|
|
89
107
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tt-a1i/hive",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Browser-native hive-mind for CLI coding agents — Claude Code, Codex, Gemini, and OpenCode collaborate as real PTY processes via a team protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.30.3",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"release:dry": "pnpm check && pnpm build && pnpm test && pnpm pack:check && pnpm pack:smoke",
|
|
65
65
|
"sync:marketplace": "node scripts/sync-marketplace.mjs",
|
|
66
66
|
"test": "vitest run",
|
|
67
|
-
"test:windows": "vitest run tests/unit/agent-command-resolver.test.ts tests/unit/session-capture-multi-cli.test.ts tests/unit/claude-session-support.test.ts tests/unit/worker-name-generator.test.ts tests/unit/open-target-commands.test.ts tests/unit/sw-template-substitution.test.ts tests/unit/build-sw-plugin.test.ts tests/server/fs-pick-folder.test.ts tests/server/fs-browse.test.ts tests/server/schema-version.test.ts tests/server/runtime-rehydration.test.ts tests/server/open-workspace-route.test.ts tests/server/static-pwa.test.ts tests/web/workspace-picker.test.tsx tests/web/confirm-dialog.test.tsx tests/web/toast.test.tsx tests/web/open-workspace-button.test.tsx tests/web/register-service-worker.test.ts tests/web/use-shortcut-action.test.ts tests/web/update-available-toast.test.tsx tests/web/runtime-offline-page.test.tsx tests/web/use-terminal-panel-height.test.ts tests/web/use-terminal-panel-tabs.test.ts tests/web/terminal-tabs.test.tsx tests/web/terminal-bottom-panel.test.tsx --no-file-parallelism --maxWorkers=1 --testTimeout=60000 --hookTimeout=60000",
|
|
67
|
+
"test:windows": "vitest run tests/unit/agent-command-resolver.test.ts tests/unit/agent-launch-resolver.test.ts tests/unit/format-port-in-use.test.ts tests/unit/opencode-db-path.test.ts tests/unit/post-start-input-writer.test.ts tests/unit/session-capture-multi-cli.test.ts tests/unit/startup-command-parser.test.ts tests/unit/claude-session-support.test.ts tests/unit/taskkill-process-tree.test.ts tests/unit/team-cmd-shim.test.ts tests/unit/terminal-input-profile.test.ts tests/unit/worker-name-generator.test.ts tests/unit/open-target-commands.test.ts tests/unit/sw-template-substitution.test.ts tests/unit/build-sw-plugin.test.ts tests/server/fs-pick-folder.test.ts tests/server/fs-browse.test.ts tests/server/schema-version.test.ts tests/server/runtime-rehydration.test.ts tests/server/open-workspace-route.test.ts tests/server/static-pwa.test.ts tests/web/is-standalone.test.ts tests/web/path-join.test.ts tests/web/workspace-picker.test.tsx tests/web/confirm-dialog.test.tsx tests/web/toast.test.tsx tests/web/open-workspace-button.test.tsx tests/web/register-service-worker.test.ts tests/web/use-shortcut-action.test.ts tests/web/update-available-toast.test.tsx tests/web/runtime-offline-page.test.tsx tests/web/use-terminal-panel-height.test.ts tests/web/use-terminal-panel-tabs.test.ts tests/web/terminal-tabs.test.tsx tests/web/terminal-bottom-panel.test.tsx --no-file-parallelism --maxWorkers=1 --testTimeout=60000 --hookTimeout=60000",
|
|
68
68
|
"test:watch": "vitest"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-
|
|
2
|
-
import{c as W,j as e,u as j,r as c,e as z,i as M,m as X,z as Y,A as Z,B as R,F as ee,G as te,a as ae,P as re,O as se,C as ne,b as le,D as oe,d as ie,_ as de}from"./index-CWW5vUjQ.js";const ce=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ue=W("bookmark-plus",ce);const xe=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],me=W("dices",xe);const pe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],he=W("search",pe);const fe=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],be=W("square-terminal",fe);const ge=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],ke=W("store",ge),ve=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],F=t=>`role.${t}`,C=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),je=({active:t,spec:a,onSelect:l})=>{const{t:n}=j();return e.jsxs("button",{type:"button",onClick:l,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(R,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:n(F(a.value))}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},ye=({onRoleChange:t,workerRole:a})=>{const{t:l}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:l("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(n=>e.jsx(je,{active:a===n.value,spec:n,onSelect:()=>t(n.value)},n.value))})]})},Ne=({customTemplates:t,disabledReason:a,onDeleteTemplate:l,onSelect:n,selectedTemplateId:i})=>{const{t:o}=j(),[f,x]=c.useState(!1),[m,u]=c.useState(""),[b,k]=c.useState(null),y=c.useRef(null),g=c.useMemo(()=>t.find(r=>r.id===i)??null,[t,i]),v=c.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(s=>s.name.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)):t},[t,m]);return c.useEffect(()=>{if(!f)return;const r=h=>{h.key==="Escape"&&x(!1)},s=h=>{const w=y.current;w&&!w.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",s),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",s)}},[f]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":f,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:g?g.name:o("addWorker.templatePickPlaceholder")}),e.jsx(z,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),f?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(he,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const s=r.id===i;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":s,"data-testid":`role-template-option-${r.id}`,onClick:()=>{n(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:s?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(X,{size:14,"aria-hidden":!0})})]},r.id)})}),i!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{n(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),l(r)}})]})},Ce=({canSaveAsTemplate:t,modified:a,onChange:l,onReset:n,onSaveAsTemplate:i,roleDescription:o,templateBusy:f,workerRole:x,writeDisabledReason:m})=>{const{t:u}=j(),[b,k]=c.useState(!1),[y,g]=c.useState(!1),[v,r]=c.useState("");return c.useEffect(()=>{(x==="custom"||a)&&k(!0)},[a,x]),c.useEffect(()=>{t||(g(!1),r(""))},[t]),e.jsxs("details",{open:b,onToggle:s=>k(s.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-sm text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(F(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-1",children:[t&&!y?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:s=>{s.preventDefault(),s.stopPropagation(),g(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ue,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:s=>{s.preventDefault(),s.stopPropagation(),n()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:s=>l(s.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:v,onChange:s=>r(s.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:f||!v.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const s=v.trim();if(s)try{await i(s),g(!1),r("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{g(!1),r("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:l,logoPresetId:n,notFound:i=!1,testId:o,onSelect:f})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(be,{size:13})});return e.jsxs("button",{type:"button",onClick:f,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(ee,{commandPresetId:n,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:l}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,i?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},We=({active:t,preset:a,onSelect:l})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:l}),we=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>e.jsx(Se,{commandPresetId:t,commandPresets:a,onPresetChange:l}),Se=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:n("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:n("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.map(i=>e.jsx(We,{active:t===i.id,preset:i,onSelect:()=>l(i.id)},i.id)),e.jsx(D,{active:t==="",command:n("addWorker.genericCommand"),displayName:n("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>l("")})]})]})},ze=({onChange:t,value:a})=>{const{t:l}=j(),n=a.trim();return e.jsxs("details",{className:"group flex flex-col gap-2",children:[e.jsx("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 shrink-0 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:l("addWorker.startupCommand")}),n?e.jsxs("span",{className:"truncate text-sm text-ter",children:["· ",l("addWorker.startupOverrides")]}):null]})}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:i=>t(i.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:l("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Me=c.lazy(()=>de(()=>import("./MarketplaceDrawer-CqE8_4ZP.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:l=!1,customTemplates:n,onApplyMarketplaceImport:i,onClose:o,onDeleteTemplate:f,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:g,onStartupCommandChange:v,onSubmit:r,onTemplateChange:s,roleDescription:h,roleDescriptionDefault:w,selectedTemplateId:_,startupCommand:P,templateBusy:I,workerName:A,workerRole:S,writeDisabledReason:N})=>{const{t:d}=j(),L=te(),[B,O]=c.useState(!1),[q,H]=c.useState(!1),K=c.useMemo(()=>new Set(n.map(p=>p.name)),[n]),V=p=>{i(p),L.show({kind:"success",message:d("marketplace.imported",{name:p.name})})},G=p=>{p||o()},Q=h!==w,E=t.find(p=>p.id===a),$=P.trim(),J=()=>N||(A.trim()?!a&&!$?d("addWorker.pickCliOrStartup"):E?.available===!1&&!$?d("addWorker.unavailable",{name:E.displayName}):h.trim()?null:d("addWorker.emptyInstructions"):d("addWorker.enterName")),U=p=>{const T=J();if(T){p.preventDefault(),L.show({kind:"warning",message:T});return}r(p)};return e.jsxs(ae,{open:!0,onOpenChange:G,children:[e.jsxs(re,{children:[e.jsx(se,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ne,{"data-testid":"add-worker-content",className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:e.jsxs("form",{onSubmit:U,"aria-label":d("addWorker.title"),className:"flex flex-col",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx(le,{className:"text-lg font-semibold text-pri",children:d("addWorker.title")}),e.jsx(oe,{className:"text-sm text-ter",children:d("addWorker.description",{command:"team send"})})]}),e.jsxs("div",{className:"flex flex-col gap-4 overflow-y-auto px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(C,{children:d("addWorker.name")}),e.jsx(ie,{label:d("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":d("addWorker.randomAria"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(me,{size:12,"aria-hidden":!0}),d("addWorker.random")]})})]}),e.jsx("input",{autoFocus:!0,value:A,onChange:p=>x(p.target.value),placeholder:d("addWorker.namePlaceholder"),className:"input"})]}),e.jsx(ye,{workerRole:S,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{H(!0),O(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-md border px-3 py-1.5 text-xs text-sec outline-none transition-colors focus-visible:ring-2",style:{background:"var(--bg-0)",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(ke,{size:14,"aria-hidden":!0}),d("marketplace.openFromAddWorker")]}),S==="custom"?e.jsx(Ne,{customTemplates:n,disabledReason:N,onDeleteTemplate:f,onSelect:s,selectedTemplateId:_}):null,e.jsx(Ce,{canSaveAsTemplate:S==="custom"&&!_&&h.trim().length>0,modified:Q,onChange:b,onReset:k,onSaveAsTemplate:g,roleDescription:h,templateBusy:I,workerRole:S,writeDisabledReason:N}),e.jsx(we,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(ze,{value:P,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:"icon-btn","data-testid":"add-worker-cancel",children:d("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:l||!!N,title:N??void 0,className:"icon-btn icon-btn--primary","data-testid":"add-worker-submit",children:d(l?"addWorker.creating":"addWorker.create")})]})]})})})]}),q?e.jsx(c.Suspense,{fallback:null,children:e.jsx(Me,{open:B,onClose:()=>O(!1),onImport:V,importedNames:K})}):null]})},Ae=Object.freeze(Object.defineProperty({__proto__:null,AddWorkerDialog:_e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,he as S};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-BC0eBOEW.js","assets/index-Ddb7bDN5.js","assets/index-BEsTmfrO.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as W,j as e,u as j,r as c,e as z,i as M,m as X,z as Y,A as Z,B as R,F as ee,G as te,a as ae,P as re,O as se,C as ne,b as le,D as oe,d as ie,_ as de}from"./index-Ddb7bDN5.js";const ce=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ue=W("bookmark-plus",ce);const xe=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],me=W("dices",xe);const pe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],he=W("search",pe);const fe=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],be=W("square-terminal",fe);const ge=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],ke=W("store",ge),ve=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],F=t=>`role.${t}`,C=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),je=({active:t,spec:a,onSelect:l})=>{const{t:n}=j();return e.jsxs("button",{type:"button",onClick:l,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(R,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:n(F(a.value))}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},ye=({onRoleChange:t,workerRole:a})=>{const{t:l}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:l("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(n=>e.jsx(je,{active:a===n.value,spec:n,onSelect:()=>t(n.value)},n.value))})]})},Ne=({customTemplates:t,disabledReason:a,onDeleteTemplate:l,onSelect:n,selectedTemplateId:i})=>{const{t:o}=j(),[f,x]=c.useState(!1),[m,u]=c.useState(""),[b,k]=c.useState(null),y=c.useRef(null),g=c.useMemo(()=>t.find(r=>r.id===i)??null,[t,i]),v=c.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(s=>s.name.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)):t},[t,m]);return c.useEffect(()=>{if(!f)return;const r=h=>{h.key==="Escape"&&x(!1)},s=h=>{const w=y.current;w&&!w.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",s),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",s)}},[f]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":f,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:g?g.name:o("addWorker.templatePickPlaceholder")}),e.jsx(z,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),f?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(he,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const s=r.id===i;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":s,"data-testid":`role-template-option-${r.id}`,onClick:()=>{n(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:s?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(X,{size:14,"aria-hidden":!0})})]},r.id)})}),i!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{n(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),l(r)}})]})},Ce=({canSaveAsTemplate:t,modified:a,onChange:l,onReset:n,onSaveAsTemplate:i,roleDescription:o,templateBusy:f,workerRole:x,writeDisabledReason:m})=>{const{t:u}=j(),[b,k]=c.useState(!1),[y,g]=c.useState(!1),[v,r]=c.useState("");return c.useEffect(()=>{(x==="custom"||a)&&k(!0)},[a,x]),c.useEffect(()=>{t||(g(!1),r(""))},[t]),e.jsxs("details",{open:b,onToggle:s=>k(s.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-sm text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(F(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-1",children:[t&&!y?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:s=>{s.preventDefault(),s.stopPropagation(),g(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ue,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:s=>{s.preventDefault(),s.stopPropagation(),n()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:s=>l(s.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:v,onChange:s=>r(s.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:f||!v.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const s=v.trim();if(s)try{await i(s),g(!1),r("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{g(!1),r("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:l,logoPresetId:n,notFound:i=!1,testId:o,onSelect:f})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(be,{size:13})});return e.jsxs("button",{type:"button",onClick:f,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(ee,{commandPresetId:n,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:l}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,i?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},We=({active:t,preset:a,onSelect:l})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:l}),we=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>e.jsx(Se,{commandPresetId:t,commandPresets:a,onPresetChange:l}),Se=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:n("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:n("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.map(i=>e.jsx(We,{active:t===i.id,preset:i,onSelect:()=>l(i.id)},i.id)),e.jsx(D,{active:t==="",command:n("addWorker.genericCommand"),displayName:n("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>l("")})]})]})},ze=({onChange:t,value:a})=>{const{t:l}=j(),n=a.trim();return e.jsxs("details",{className:"group flex flex-col gap-2",children:[e.jsx("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 shrink-0 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:l("addWorker.startupCommand")}),n?e.jsxs("span",{className:"truncate text-sm text-ter",children:["· ",l("addWorker.startupOverrides")]}):null]})}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:i=>t(i.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:l("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Me=c.lazy(()=>de(()=>import("./MarketplaceDrawer-BC0eBOEW.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:l=!1,customTemplates:n,onApplyMarketplaceImport:i,onClose:o,onDeleteTemplate:f,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:g,onStartupCommandChange:v,onSubmit:r,onTemplateChange:s,roleDescription:h,roleDescriptionDefault:w,selectedTemplateId:_,startupCommand:P,templateBusy:I,workerName:A,workerRole:S,writeDisabledReason:N})=>{const{t:d}=j(),L=te(),[B,O]=c.useState(!1),[q,H]=c.useState(!1),K=c.useMemo(()=>new Set(n.map(p=>p.name)),[n]),V=p=>{i(p),L.show({kind:"success",message:d("marketplace.imported",{name:p.name})})},G=p=>{p||o()},Q=h!==w,E=t.find(p=>p.id===a),$=P.trim(),J=()=>N||(A.trim()?!a&&!$?d("addWorker.pickCliOrStartup"):E?.available===!1&&!$?d("addWorker.unavailable",{name:E.displayName}):h.trim()?null:d("addWorker.emptyInstructions"):d("addWorker.enterName")),U=p=>{const T=J();if(T){p.preventDefault(),L.show({kind:"warning",message:T});return}r(p)};return e.jsxs(ae,{open:!0,onOpenChange:G,children:[e.jsxs(re,{children:[e.jsx(se,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ne,{"data-testid":"add-worker-content",className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:e.jsxs("form",{onSubmit:U,"aria-label":d("addWorker.title"),className:"flex flex-col",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx(le,{className:"text-lg font-semibold text-pri",children:d("addWorker.title")}),e.jsx(oe,{className:"text-sm text-ter",children:d("addWorker.description",{command:"team send"})})]}),e.jsxs("div",{className:"flex flex-col gap-4 overflow-y-auto px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(C,{children:d("addWorker.name")}),e.jsx(ie,{label:d("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":d("addWorker.randomAria"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(me,{size:12,"aria-hidden":!0}),d("addWorker.random")]})})]}),e.jsx("input",{autoFocus:!0,value:A,onChange:p=>x(p.target.value),placeholder:d("addWorker.namePlaceholder"),className:"input"})]}),e.jsx(ye,{workerRole:S,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{H(!0),O(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-md border px-3 py-1.5 text-xs text-sec outline-none transition-colors focus-visible:ring-2",style:{background:"var(--bg-0)",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(ke,{size:14,"aria-hidden":!0}),d("marketplace.openFromAddWorker")]}),S==="custom"?e.jsx(Ne,{customTemplates:n,disabledReason:N,onDeleteTemplate:f,onSelect:s,selectedTemplateId:_}):null,e.jsx(Ce,{canSaveAsTemplate:S==="custom"&&!_&&h.trim().length>0,modified:Q,onChange:b,onReset:k,onSaveAsTemplate:g,roleDescription:h,templateBusy:I,workerRole:S,writeDisabledReason:N}),e.jsx(we,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(ze,{value:P,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:"icon-btn","data-testid":"add-worker-cancel",children:d("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:l||!!N,title:N??void 0,className:"icon-btn icon-btn--primary","data-testid":"add-worker-submit",children:d(l?"addWorker.creating":"addWorker.create")})]})]})})})]}),q?e.jsx(c.Suspense,{fallback:null,children:e.jsx(Me,{open:B,onClose:()=>O(!1),onImport:V,importedNames:K})}):null]})},Ae=Object.freeze(Object.defineProperty({__proto__:null,AddWorkerDialog:_e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,he as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as V,u as D,r as c,j as e,o as se,e as $,i as Z,a as T,P as I,O as q,C as U,b as W,D as K,q as ae,s as re,t as ne,X as ce,v as le,w as oe,T as ie}from"./index-Ddb7bDN5.js";import{C as L,d as de}from"./path-join-S7qkXQtP.js";const pe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],xe=V("arrow-up",pe);const ue=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],me=V("folder-search",ue);const he=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",he);const fe=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Q=V("git-branch",fe),ee=({error:t,onChange:o,presets:x,value:a})=>{const{t:i}=D(),[d,n]=c.useState(!1),s=c.useRef(null),p=x.find(l=>l.id===a),r=a==="",k=p?[p.command,...p.args].join(" ").trim():i(r?"workspace.preset.genericPreview":"workspace.preset.loading"),g=p?.displayName??(r?i("workspace.preset.generic"):"Claude Code (CC)"),j=x.length===0&&!r;return c.useEffect(()=>{if(!d)return;const l=f=>{s.current?.contains(f.target)||n(!1)},m=f=>{f.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m)}},[d]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:i("workspace.preset.label")}),e.jsxs("div",{ref:s,className:"cli-select group relative",children:[e.jsx(se,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":d,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":a,disabled:j,onClick:()=>n(l=>!l),children:g}),e.jsx($,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),d&&x.length>0?e.jsxs("div",{role:"listbox","aria-label":i("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[x.map(l=>{const m=l.id===a,f=l.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${l.id}`,className:"cli-select__option",onClick:()=>{o(l.id),n(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[l.displayName,f?i("workspace.preset.notFoundSuffix"):""]})]},l.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{o(""),n(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:r?1:0}}),e.jsx("span",{children:i("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),be=({probe:t,pasteFallbackDefault:o=!1,commandPresetError:x,commandPresetId:a,commandPresets:i,onCancel:d,onCommandPresetChange:n,onCreate:s,onOpenServerBrowse:p})=>{const{t:r}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,l]=c.useState(g),[m,f]=c.useState(""),[C,P]=c.useState(o),[w,E]=c.useState(!1),[_,h]=c.useState("");c.useEffect(()=>{l(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const y=m.trim(),u=C&&y.length>0?y:t?.path??"",N=_.trim(),S=i.find(v=>v.id===a),R=i.length===0&&!x,A=!a&&N.length===0,F=S?.available===!1&&N.length===0,B=A?r("workspace.preset.genericRequiresStartup"):F?r("workspace.preset.notInstalled",{name:S.displayName}):null,O=j.trim().length>0&&u.length>0&&!R&&!A&&!F,H=()=>{O&&s({commandPresetId:a||null,name:j.trim(),path:u,...N?{startupCommand:N}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&d(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:r("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:r("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:r("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:r("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(Q,{size:12,"aria-hidden":!0}),t.current_branch??r("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:r("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:r("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:r("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>l(v.target.value),placeholder:G(t?.path??"")||r("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(ee,{error:x??B,onChange:n,presets:i,value:a}),e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[w?e.jsx($,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),r("workspace.advanced.startup")]}),w?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:r("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:r("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:r("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[C?e.jsx($,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),r("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:r("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:r("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:p,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(L,{size:12,"aria-hidden":!0}),r("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:d,className:"icon-btn",children:r("common.cancel")}),e.jsx("button",{type:"button",onClick:H,disabled:!O,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:r("workspace.confirm.create")})]})]})})]})})},ge=({entries:t,error:o,loading:x,onNavigate:a,onSelect:i,selected:d})=>{const{t:n}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:x?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:n("common.loading")}):o?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:o}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:n("workspace.browse.empty")}):e.jsx("ul",{children:t.map(s=>{const p=d===s.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${s.name}`,onClick:()=>i(s.path),onDoubleClick:()=>a(s.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:p?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:s.is_git_repository?e.jsx(Q,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:s.name}),s.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:n("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${s.name}`,onClick:()=>a(s.path),"aria-label":n("workspace.browse.openAria",{name:s.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},s.path)})})})},ke=({probe:t,suggestedName:o,onSuggestedNameChange:x})=>{const{t:a}=D(),i=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:a("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:a("workspace.git.short",{branch:t.current_branch??a("workspace.git.detached")})}):i?e.jsx("span",{className:"text-ter text-xs",children:a("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:a("workspace.field.name")}),e.jsx("input",{type:"text",value:o,onChange:d=>x(d.target.value),disabled:!i,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ve=t=>{const x=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),a=x[x.length-1];return a?`~ (${a})`:t},je=(t,o)=>{if(!o||!t)return[];const x=[{label:ve(o),path:o}];if(t===o)return x;const a=o.replace(/[\\/]+$/,""),i=t.startsWith(a)?t.slice(a.length).replace(/^[\\/]+/,""):"";if(!i)return x;const d=de(a),n=i.split(/[\\/]/).filter(Boolean);let s=a;for(const p of n)s=`${s}${d}${p}`,x.push({label:p,path:s});return x},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},we=t=>{const[o,x]=c.useState(J),[a,i]=c.useState(!1),[d,n]=c.useState(null),[s,p]=c.useState(null),r=c.useRef(0),k=c.useRef(0),g=c.useCallback(async l=>{const m=++r.current;i(!0);try{const f=await ae(l);if(r.current!==m)return;x(f),f.ok&&n(f.current_path)}catch{}finally{r.current===m&&i(!1)}},[]);c.useEffect(()=>{if(!t){r.current++,k.current++,x(J),n(null),p(null);return}g("")},[t,g]),c.useEffect(()=>{if(!d){p(null);return}const l=++k.current;re(d).then(m=>{k.current===l&&p(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[d]);const j=c.useCallback(l=>{n(l)},[]);return{browse:o,loading:a,navigate:g,probe:s,selectEntry:j,selected:d}},ye=({commandPresetError:t,commandPresetId:o,commandPresets:x,onClose:a,onCommandPresetChange:i,onCreate:d,open:n})=>{const{t:s}=D(),{browse:p,loading:r,navigate:k,probe:g,selectEntry:j,selected:l}=we(n),[m,f]=c.useState(""),[C,P]=c.useState(!1),[w,E]=c.useState(""),[_,h]=c.useState(!1),[y,u]=c.useState("");if(c.useEffect(()=>{n||(f(""),P(!1),E(""),h(!1),u(""))},[n]),c.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!n)return null;const N=je(p.current_path,p.root_path),S=x.find(b=>b.id===o),R=y.trim(),A=x.length===0&&!t,F=!o&&R.length===0,B=S?.available===!1&&R.length===0,O=F?s("workspace.preset.genericRequiresStartup"):B?s("workspace.preset.notInstalled",{name:S.displayName}):null,H=m.trim().length>0&&(g?.is_dir===!0||C&&w.trim().length>0)&&!A&&!F&&!B,v=()=>{const b=C&&w.trim().length>0?w.trim():g?.path??"";b&&d({commandPresetId:o||null,name:m.trim(),path:b,...R?{startupCommand:R}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&a(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:s("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:p.root_path?s("workspace.browse.root",{path:p.root_path}):s("workspace.browse.rootLoading")})]}),e.jsx(ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":s("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(ce,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":s("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>p.parent_path?k(p.parent_path):null,disabled:!p.parent_path,"aria-label":s("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(xe,{size:12,"aria-hidden":!0})," ",s("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),N.map((b,Y)=>{const te=Y===N.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:"/"}):null,te?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(ge,{entries:p.entries,error:p.ok?null:p.error,loading:r,onNavigate:k,onSelect:j,selected:l})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(ke,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(ee,{error:t??O,onChange:i,presets:x,value:o}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx($,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.startup"),e.jsx("input",{type:"text",value:y,onChange:b=>u(b.target.value),placeholder:s("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:s("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[C?e.jsx($,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:w,onChange:b=>E(b.target.value),placeholder:s("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:v,disabled:!H,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:s("workspace.confirm.create")})]})]})})]})})},z="claude",Ne=t=>t.some(o=>o.id===z&&o.available)?z:t.find(o=>o.available)?.id??t[0]?.id??z,Se=({trigger:t,onClose:o,onCreate:x})=>{const{t:a}=D(),i=c.useRef(a);c.useEffect(()=>{i.current=a},[a]);const[d,n]=c.useState({kind:"idle"}),[s,p]=c.useState([]),[r,k]=c.useState(z),[g,j]=c.useState(null),l=c.useRef({error:null,id:z,presets:[]}),m=c.useRef(o);c.useEffect(()=>{m.current=o},[o]),c.useEffect(()=>{if(t===0)return;let h=!1;j(null);const y=le().then(u=>{if(h)return;const N=u.some(S=>S.id===l.current.id&&S.available)?l.current.id:Ne(u);l.current={error:null,id:N,presets:u},p(u),k(N)}).catch(()=>{if(h)return;const u=i.current("workspace.preset.loadFailed");l.current={error:u,id:z,presets:[]},p([]),k(z),j(u)});return n({kind:"picking"}),oe().then(async u=>{if(await y,!h){if(u.canceled){if(u.error){n({kind:"error",message:u.error});return}n({kind:"idle"}),m.current();return}if(!u.supported){n({kind:"confirm",probe:null,pasteDefault:!0});return}if(!u.probe?.ok||!u.probe.is_dir){n({kind:"error",message:u.error??i.current("workspace.error.outsideSandbox")});return}n({kind:"confirm",probe:u.probe,pasteDefault:!1})}}).catch(u=>{if(h)return;const N=u instanceof Error?u.message:i.current("workspace.error.pickerFailed");n({kind:"error",message:N})}),()=>{h=!0}},[t]);const f=()=>{n({kind:"idle"}),o()},C=h=>{Promise.resolve(x(h)).then(()=>n({kind:"idle"})).catch(y=>{const u=y instanceof Error?y.message:a("workspace.error.createFailed");n({kind:"error",title:a("workspace.error.createTitle"),message:u})})},P=h=>{l.current={...l.current,id:h},k(h)},w=s.length>0||g?s:l.current.presets,E=r===""?"":w.length>0&&!w.some(h=>h.id===r&&h.available)?l.current.id:r,_=g??l.current.error;if(d.kind==="idle")return null;if(d.kind==="picking"){const h=()=>n({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:y=>!y&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:a("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(me,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:a("workspace.picking.message")})]})]})]})})}return d.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ie,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:d.title??a("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:d.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:a("common.close")}),e.jsx("button",{type:"button",onClick:()=>n({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:a("workspace.error.pastePathInstead")})]})]})})]})}):d.kind==="browse"?e.jsx(ye,{commandPresetError:_,commandPresetId:E,commandPresets:w,onClose:f,onCommandPresetChange:P,onCreate:C,open:!0}):e.jsx(be,{commandPresetError:_,commandPresetId:E,commandPresets:w,pasteFallbackDefault:d.pasteDefault,probe:d.probe,onCancel:f,onCommandPresetChange:P,onCreate:C,onOpenServerBrowse:()=>n({kind:"browse"})})};export{Se as AddWorkspaceDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as f,u as h,r as j,j as e,a as b,P as N,O as v,C as y,D as g,b as c}from"./index-
|
|
1
|
+
import{c as f,u as h,r as j,j as e,a as b,P as N,O as v,C as y,D as g,b as c}from"./index-Ddb7bDN5.js";const R=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],k=f("hexagon",R),w=({open:o,onClose:r,onAddWorkspace:x,onTryDemo:d})=>{const{t:s}=h(),[n,l]=j.useState(0),u=t=>{t||(l(0),r())},i=(t=!0)=>{l(0),r(t)},a=n===2;return e.jsx(b,{open:o,onOpenChange:u,children:e.jsxs(N,{children:[e.jsx(v,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(y,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[n===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(k,{size:32})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),n>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),n===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:m,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:m}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),n===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{x(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{d(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{w as FirstRunWizard};
|