@spzxg/cli-ui 0.6.13 → 0.6.17
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 +100 -2
- package/README.md +131 -7
- package/dist/{cli-ui-embed-CXaGT9e4.js → cli-ui-embed-REq-GvM7.js} +20350 -19892
- package/dist/{cli-ui-index-bMQJjEBW.js → cli-ui-index-p_XTnmsN.js} +2 -2
- package/dist/{cli-ui-jszip.min-D_w3a6AF.js → cli-ui-jszip.min-0mqaiYeK.js} +1 -1
- package/dist/{cli-ui-jszip.min-AMeWMDT5.js → cli-ui-jszip.min-CJa9yrKW.js} +2 -2
- package/dist/{cli-ui-xlsx-DMzew4IO.js → cli-ui-xlsx-BPL7P3mE.js} +1 -1
- package/dist/cli-ui.css +1 -1
- package/dist/cli-ui.js +1 -1
- package/package.json +1 -1
- package/src/board/BrowserPane.tsx +93 -30
- package/src/board/ChangesPane.tsx +86 -62
- package/src/board/CliBoard.tsx +62 -27
- package/src/board/FileViewer.tsx +49 -13
- package/src/board/context.ts +38 -7
- package/src/board/diffLines.ts +46 -0
- package/src/board/diffRefresh.ts +63 -0
- package/src/board/fileDiff.tsx +117 -0
- package/src/board/fileKind.ts +5 -3
- package/src/board/fileScope.ts +4 -2
- package/src/board/fileWatch.ts +59 -9
- package/src/board/linkage.ts +68 -0
- package/src/board/pathResolve.ts +108 -0
- package/src/board/useBoardUpload.tsx +7 -7
- package/src/board/workspace.ts +7 -1
- package/src/chat/CliChat.tsx +197 -216
- package/src/chat/Composer.tsx +10 -9
- package/src/chat/queueEdit.ts +27 -0
- package/src/components.tsx +2 -2
- package/src/core/blocks.ts +4 -1
- package/src/core/client.ts +86 -9
- package/src/core/config.ts +1 -1
- package/src/core/conversation.ts +23 -5
- package/src/core/documentUpload.ts +22 -5
- package/src/core/provider.tsx +14 -8
- package/src/core/store.ts +307 -63
- package/src/core/types.ts +49 -0
- package/src/elements.tsx +8 -5
- package/src/msglist/CliMsgList.tsx +30 -9
- package/src/operator/node/AgentConnect.tsx +28 -29
- package/src/operator/node/AppearancePanel.tsx +1 -1
- package/src/operator/node/BranchHistory.tsx +11 -7
- package/src/operator/node/BranchNavigator.tsx +1 -1
- package/src/operator/node/BrowserPane.tsx +7 -7
- package/src/operator/node/Chat.tsx +53 -272
- package/src/operator/node/CommandPalette.tsx +1 -1
- package/src/operator/node/Composer.tsx +13 -6
- package/src/operator/node/Layout.tsx +1 -1
- package/src/operator/node/Markdown.tsx +6 -36
- package/src/operator/node/Modal.tsx +1 -1
- package/src/operator/node/OnboardingWizard.tsx +11 -9
- package/src/operator/node/Orchestrator.tsx +18 -8
- package/src/operator/node/ProjectLanding.tsx +1 -1
- package/src/operator/node/ProjectsColumn.tsx +1 -1
- package/src/operator/node/ProviderAuth.tsx +16 -16
- package/src/operator/node/RunSwitch.tsx +1 -1
- package/src/operator/node/Services.tsx +1 -1
- package/src/operator/node/SessionRail.tsx +55 -19
- package/src/operator/node/SessionView.tsx +18 -16
- package/src/operator/node/SettingsView.tsx +1 -1
- package/src/operator/node/TaskBoard.tsx +1 -1
- package/src/operator/node/TaskChanges.tsx +83 -108
- package/src/operator/node/TaskHero.tsx +5 -5
- package/src/operator/node/TasksColumn.tsx +1 -1
- package/src/operator/node/Transcript.tsx +15 -250
- package/src/operator/node/Welcome.tsx +1 -1
- package/src/operator/node/WorktreePrune.tsx +1 -1
- package/src/operator/node/api.ts +17 -0
- package/src/operator/node/boardBackend.ts +4 -1
- package/src/operator/node/boardEvents.ts +17 -3
- package/src/operator/node/boardInteraction.ts +7 -4
- package/src/operator/node/boardState.ts +23 -14
- package/src/operator/node/composerDraft.ts +22 -0
- package/src/operator/node/fileLinks.ts +4 -38
- package/src/operator/node/format.ts +13 -104
- package/src/operator/node/github.tsx +14 -14
- package/src/operator/node/liveStream.ts +47 -6
- package/src/operator/node/modals.tsx +59 -22
- package/src/operator/node/recheckOnReturn.ts +28 -0
- package/src/operator/node/shared.tsx +10 -50
- package/src/operator/node/types.ts +9 -0
- package/src/operator/node/useOrchestrator.ts +9 -8
- package/src/operator/node/useRecaps.ts +15 -4
- package/src/operator/node/useTaskStream.ts +2 -2
- package/src/operator.base.css +9 -4
- package/src/operator.css +9 -4
- package/src/styles.css +22 -8
- package/src/ui/Markdown.tsx +36 -21
- package/src/ui/Popover.tsx +1 -1
- package/src/ui/QueuedMessages.tsx +58 -15
- package/src/ui/SubagentChat.tsx +42 -6
- package/src/ui/Transcript.tsx +19 -14
- package/src/ui/fileLinks.ts +6 -3
- package/src/ui/format.ts +27 -9
- package/src/ui/icons.tsx +2 -0
- package/src/ui/shared.tsx +11 -7
- package/src/ui/transcriptModel.ts +40 -9
- package/src/ui/useTranscriptWindow.ts +253 -0
- package/src/operator/node/icons.tsx +0 -88
- package/src/operator/node/transcriptModel.ts +0 -129
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
// Pure formatting + derivation helpers
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// Pure formatting + derivation helpers for the node adapter. The ones both adapters
|
|
2
|
+
// use (tokens, times, sessions, answers, model labels, attachment parsing) live in
|
|
3
|
+
// ui/format and are re-exported here.
|
|
4
|
+
export { buildSessions, clockTime, diffCls, fmtTokens, formatAnswersText, relTime, modelLabel } from "../../ui/format";
|
|
5
|
+
import { fmtTokens, splitAttachments as splitSharedAttachments, type AttachmentScope } from "../../ui/format";
|
|
6
|
+
import { taskFileApiUrl } from "./fileLinks";
|
|
7
|
+
|
|
8
|
+
// Attachment chips: parsed by the shared rule (ui/format), linked to the node's upload route.
|
|
9
|
+
export function splitAttachments(content: string, scope?: AttachmentScope): { text: string; attachments: MsgAttachment[] } {
|
|
10
|
+
const { text, attachments } = splitSharedAttachments(content, scope);
|
|
11
|
+
return { text, attachments: attachments.map(({ path, kind, name, taskId, workspace }) => ({ path, kind, name, url: workspace ? taskFileApiUrl(taskId, path) : `/api/tasks/${encodeURIComponent(taskId)}/uploads/${encodeURIComponent(name)}` })) };
|
|
12
|
+
}
|
|
13
|
+
import type { TaskRow, AgentCapabilities, AgentInfo } from "./types";
|
|
4
14
|
import type { InternalUsageEstimate } from "./types";
|
|
5
15
|
|
|
6
|
-
// Compact token count: 1234 → "1.2k", 1_200_000 → "1.2M".
|
|
7
|
-
export function fmtTokens(n: number): string {
|
|
8
|
-
if (n >= 1e6) return `${(n / 1e6).toFixed(n >= 1e7 ? 0 : 1)}M`;
|
|
9
|
-
if (n >= 1e3) return `${(n / 1e3).toFixed(n >= 1e4 ? 0 : 1)}k`;
|
|
10
|
-
return String(n);
|
|
11
|
-
}
|
|
12
16
|
// Human byte size: 1536 → "1.5 KB", 5_242_880 → "5.0 MB". Base-1024.
|
|
13
17
|
export function fmtBytes(n: number): string {
|
|
14
18
|
if (n <= 0) return "0 B";
|
|
@@ -137,61 +141,7 @@ export function contextPct(tokens: number, model: string | null | undefined, cap
|
|
|
137
141
|
return Math.round((tokens / contextWindowOf(model, caps)) * 1000) / 10;
|
|
138
142
|
}
|
|
139
143
|
|
|
140
|
-
// Friendly name for a resolved model id — the badge that answers "which model
|
|
141
|
-
// did this turn actually run on?". The VERSION is the point: family aliases move
|
|
142
|
-
// (today "opus" resolves to claude-opus-5, last month claude-opus-4-8), so a bare
|
|
143
|
-
// "Opus" badge tells you nothing. Parse family + version out of the id first
|
|
144
|
-
// ("claude-opus-5" -> "Opus 5", "claude-opus-4-8-20251101" -> "Opus 4.8") and
|
|
145
|
-
// keep the `[1m]` marker, since the 1M variant is a distinct run mode.
|
|
146
|
-
// Non-Claude ids (Codex's "gpt-5.1-codex-max") carry no such version shape —
|
|
147
|
-
// those fall through to the agent's capability labels, matched longest-first so
|
|
148
|
-
// a shorter value can't shadow a more specific one. Raw id is the last resort.
|
|
149
|
-
export function modelLabel(id: string | null, caps?: AgentCapabilities): string {
|
|
150
|
-
if (!id) return "";
|
|
151
|
-
const s = id.toLowerCase();
|
|
152
|
-
const long = s.includes("[1m]") ? " (1M)" : "";
|
|
153
|
-
const fam = ["fable", "opus", "sonnet", "haiku"].find((f) => s.includes(f));
|
|
154
|
-
if (fam) {
|
|
155
|
-
const cap = fam[0].toUpperCase() + fam.slice(1);
|
|
156
|
-
const v = s.match(new RegExp(`${fam}-(\\d+)(?:-(\\d+))?`));
|
|
157
|
-
// Deliberately NOT the capability label here: an id we can't read a version
|
|
158
|
-
// out of shouldn't be badged with a version we're only guessing at.
|
|
159
|
-
return v ? `${cap} ${v[1]}${v[2] ? `.${v[2]}` : ""}${long}` : `${cap}${long}`;
|
|
160
|
-
}
|
|
161
|
-
const hit = (caps?.models ?? [])
|
|
162
|
-
.filter((o) => s.includes(o.value.toLowerCase()))
|
|
163
|
-
.sort((a, b) => b.value.length - a.value.length)[0];
|
|
164
|
-
return hit ? hit.label : id;
|
|
165
|
-
}
|
|
166
144
|
|
|
167
|
-
// Phrase AskUserQuestion answers as a reply, for the reload fallback where the
|
|
168
|
-
// turn is no longer parked and we resume the session with a normal message.
|
|
169
|
-
export function formatAnswersText(questions: AskQuestion[], answers: AskAnswers): string {
|
|
170
|
-
const lines = questions.map((q, i) => {
|
|
171
|
-
const picked = (answers[i] ?? []).filter((s) => s && s.trim());
|
|
172
|
-
return `- ${q.header || q.question}:${picked.length ? picked.join("、") : "(未选择)"}`;
|
|
173
|
-
});
|
|
174
|
-
return `回答你的问题:\n${lines.join("\n")}`;
|
|
175
|
-
}
|
|
176
|
-
// Absolute wall-clock stamp for a transcript message ("3:42 PM", locale-aware).
|
|
177
|
-
// Messages from an earlier day prefix the date, so a task resumed days later
|
|
178
|
-
// still reads right. Absolute on purpose: MessageView is memoized, so a
|
|
179
|
-
// relative "2m ago" would freeze at whatever it said when the row rendered.
|
|
180
|
-
export function clockTime(ts: number): string {
|
|
181
|
-
const d = new Date(ts);
|
|
182
|
-
const time = d.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
|
|
183
|
-
if (d.toDateString() === new Date().toDateString()) return time;
|
|
184
|
-
return `${d.toLocaleDateString([], { month: "short", day: "numeric" })}, ${time}`;
|
|
185
|
-
}
|
|
186
|
-
export function relTime(ts: number): string {
|
|
187
|
-
const d = Date.now() - ts;
|
|
188
|
-
const m = Math.floor(d / 60000);
|
|
189
|
-
if (m < 1) return "刚刚";
|
|
190
|
-
if (m < 60) return `${m} 分钟前`;
|
|
191
|
-
const h = Math.floor(m / 60);
|
|
192
|
-
if (h < 24) return `${h} 小时前`;
|
|
193
|
-
return `${Math.floor(h / 24)} 天前`;
|
|
194
|
-
}
|
|
195
145
|
// How long a task has been waiting on the user, spelled out for the "need you"
|
|
196
146
|
// dropdown ("waiting for 3 hours"). Coarser and more verbose than relTime — this
|
|
197
147
|
// is the only subline a row gets, so it reads as prose rather than a chip.
|
|
@@ -233,24 +183,7 @@ export const blockerTitles = (t: TaskRow, byId: Map<string, TaskRow>): string[]
|
|
|
233
183
|
.filter((b): b is TaskRow => !!b && b.status !== "done" && b.status !== "cancelled")
|
|
234
184
|
.map((b) => b.title);
|
|
235
185
|
|
|
236
|
-
// add/del/ctx class for a diff line's sign — shared by the peek and full views.
|
|
237
|
-
export const diffCls = (sign: "+" | "-" | " ") => (sign === "+" ? "add" : sign === "-" ? "del" : "ctx");
|
|
238
186
|
|
|
239
|
-
// group flat messages into per-generation sessions, pulling out the /clear summaries
|
|
240
|
-
export function buildSessions(messages: Msg[]) {
|
|
241
|
-
const summaryByGen: Record<number, string> = {};
|
|
242
|
-
for (const m of messages) if (m.role === "session_break") summaryByGen[m.generation] = m.content;
|
|
243
|
-
// Queued follow-ups are excluded here — they haven't run yet, so SessionView
|
|
244
|
-
// renders them in a pinned block below the live "thinking" indicator instead
|
|
245
|
-
// of interleaved with the committed transcript.
|
|
246
|
-
const committed = messages.filter((m) => m.role !== "queued");
|
|
247
|
-
const gens = Array.from(new Set(committed.filter((m) => m.role !== "session_break").map((m) => m.generation))).sort((a, b) => a - b);
|
|
248
|
-
return gens.map((n) => ({
|
|
249
|
-
n,
|
|
250
|
-
summaryBefore: summaryByGen[n - 1] ?? null,
|
|
251
|
-
messages: committed.filter((m) => m.generation === n && m.role !== "session_break"),
|
|
252
|
-
}));
|
|
253
|
-
}
|
|
254
187
|
|
|
255
188
|
// ---------- chat attachments (images + large text pastes) ----------
|
|
256
189
|
// An upload travels inside the message text as one marker line per file:
|
|
@@ -263,30 +196,6 @@ export function buildSessions(messages: Msg[]) {
|
|
|
263
196
|
// uploads/<task>/<file> tail, so no extra columns or event fields are needed.
|
|
264
197
|
export const attachmentMarker = (absPath: string) => `[Attached image: ${absPath}]`;
|
|
265
198
|
export const fileAttachmentMarker = (absPath: string) => `[Attached file: ${absPath}]`;
|
|
266
|
-
const ATTACHMENT_RE = /^\[Attached (image|file): (.+)\]$/;
|
|
267
199
|
|
|
268
200
|
export interface MsgAttachment { path: string; url: string; kind: "image" | "file"; name: string }
|
|
269
201
|
|
|
270
|
-
// Split a user message into displayable text + attachment chips. Marker lines
|
|
271
|
-
// whose path doesn't end in uploads/<task>/<file> (hand-typed lookalikes) stay
|
|
272
|
-
// in the text untouched.
|
|
273
|
-
export function splitAttachments(content: string): { text: string; attachments: MsgAttachment[] } {
|
|
274
|
-
if (!content.includes("[Attached image: ") && !content.includes("[Attached file: ")) {
|
|
275
|
-
return { text: content, attachments: [] };
|
|
276
|
-
}
|
|
277
|
-
const attachments: MsgAttachment[] = [];
|
|
278
|
-
const kept: string[] = [];
|
|
279
|
-
for (const line of content.split("\n")) {
|
|
280
|
-
const m = ATTACHMENT_RE.exec(line.trim());
|
|
281
|
-
const parts = m ? m[2].split(/[\\/]/).filter(Boolean) : [];
|
|
282
|
-
const upload = parts.length >= 3 && parts[parts.length - 3] === "uploads";
|
|
283
|
-
const managed = parts.length >= 4 && parts[parts.length - 4] === ".workspace" && parts[parts.length - 3] === "attachments";
|
|
284
|
-
if (m && (upload || managed) && parts.slice(-2).every(part => part !== "." && part !== "..")) {
|
|
285
|
-
const [taskId, file] = parts.slice(-2);
|
|
286
|
-
attachments.push({ path: m[2], url: `/api/tasks/${encodeURIComponent(taskId)}/uploads/${encodeURIComponent(file)}`, kind: m[1] === "image" ? "image" : "file", name: file });
|
|
287
|
-
} else {
|
|
288
|
-
kept.push(line);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return { text: kept.join("\n").trim(), attachments };
|
|
292
|
-
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
-
import { Icon } from "
|
|
4
|
+
import { Icon } from "../../ui/icons";
|
|
5
5
|
import { jget, jsend } from "./api";
|
|
6
6
|
import { LoadNote, Skel, ErrNote } from "./shared";
|
|
7
7
|
import type { GhStatusT, GhLoginT, GhRepoT } from "./types";
|
|
8
|
+
import { useRecheckOnReturn } from "./recheckOnReturn";
|
|
8
9
|
|
|
9
10
|
// The "Clone from GitHub" pane of the new-project modal: shows the guided
|
|
10
11
|
// connect step when the workspace isn't logged in, the user's repo list when
|
|
@@ -69,17 +70,15 @@ export function GitHubConnect({ onConnected }: { onConnected: () => void }) {
|
|
|
69
70
|
setLogin(null);
|
|
70
71
|
};
|
|
71
72
|
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return () => clearInterval(t);
|
|
82
|
-
}, [login, onConnected]);
|
|
73
|
+
// Re-check while gh waits for the user to authorize on github.com — when the
|
|
74
|
+
// user comes back from github.com, or presses 检查状态 (no polling).
|
|
75
|
+
const checkLogin = () => {
|
|
76
|
+
jget<GhLoginT>("/api/github/login").then((l) => {
|
|
77
|
+
setLogin(l);
|
|
78
|
+
if (l.status === "success" && !done.current) { done.current = true; onConnected(); }
|
|
79
|
+
}).catch(() => {});
|
|
80
|
+
};
|
|
81
|
+
useRecheckOnReturn(!!login && (login.status === "starting" || login.status === "awaiting"), checkLogin);
|
|
83
82
|
|
|
84
83
|
const copyCode = () => {
|
|
85
84
|
if (!login?.code) return;
|
|
@@ -101,7 +100,7 @@ export function GitHubConnect({ onConnected }: { onConnected: () => void }) {
|
|
|
101
100
|
</div>
|
|
102
101
|
);
|
|
103
102
|
}
|
|
104
|
-
if (login.status === "starting") return <LoadNote style={{ padding: 0, marginBottom:
|
|
103
|
+
if (login.status === "starting") return <div className="field"><LoadNote style={{ padding: 0, marginBottom: 8 }}>正在启动 GitHub 登录…</LoadNote><button className="btn btn-ghost btn-sm" onClick={checkLogin} style={{ alignSelf: "flex-start" }}>检查状态</button></div>;
|
|
105
104
|
if (login.status === "awaiting") {
|
|
106
105
|
return (
|
|
107
106
|
<div className="field" style={{ border: "1px solid var(--line-strong)", borderRadius: "var(--r)", background: "var(--raise)", padding: "14px 16px" }}>
|
|
@@ -117,9 +116,10 @@ export function GitHubConnect({ onConnected }: { onConnected: () => void }) {
|
|
|
117
116
|
<a className="btn btn-accent" href={login.url ?? "https://github.com/login/device"} target="_blank" rel="noreferrer">
|
|
118
117
|
{Icon.github()} 打开 github.com/login/device
|
|
119
118
|
</a>
|
|
119
|
+
<button className="btn btn-line" onClick={checkLogin}>我已完成授权,检查状态</button>
|
|
120
120
|
<button className="btn btn-ghost" onClick={cancel}>取消</button>
|
|
121
121
|
</div>
|
|
122
|
-
<div className="hlp" style={{ marginBottom: 0 }}>等待你在 github.com
|
|
122
|
+
<div className="hlp" style={{ marginBottom: 0 }}>等待你在 github.com 上完成授权…回到这个页面时会自动检查一次。</div>
|
|
123
123
|
</div>
|
|
124
124
|
);
|
|
125
125
|
}
|
|
@@ -34,6 +34,8 @@ interface Sub {
|
|
|
34
34
|
es?: EventSource;
|
|
35
35
|
retry?: ReturnType<typeof setTimeout>;
|
|
36
36
|
fails: number;
|
|
37
|
+
/** Gave up retrying after MAX_STREAM_RETRIES; the next wake (online / visible / focus) restarts it. */
|
|
38
|
+
stalled?: boolean;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
// The server sends a keepalive every 20 s; a socket silent for longer than this
|
|
@@ -43,6 +45,18 @@ const CONNECT_TIMEOUT_MS = 10_000;
|
|
|
43
45
|
const BACKOFF_MS = [500, 1000, 2000, 4000, 8000];
|
|
44
46
|
/** While on the EventSource fallback, how often to try the socket again. */
|
|
45
47
|
const PROBE_MS = 30_000;
|
|
48
|
+
// No unbounded retry loops: every automatic retry has a budget. Once it is spent
|
|
49
|
+
// the transport stops and waits for an event — back online, the tab visible
|
|
50
|
+
// again, the window focused — which resets the budget and reconnects at once.
|
|
51
|
+
/** Socket reconnects in a row before stopping (≈1 minute with BACKOFF_MS). */
|
|
52
|
+
const MAX_RECONNECTS = 10;
|
|
53
|
+
/** Probes from the EventSource fallback back to the socket before stopping (≈5 minutes). */
|
|
54
|
+
const MAX_PROBES = 10;
|
|
55
|
+
/** Per-stream resubscribes / EventSource errors in a row before that stream stops. */
|
|
56
|
+
const MAX_STREAM_RETRIES = 5;
|
|
57
|
+
const MAX_EVENTSOURCE_ERRORS = 20;
|
|
58
|
+
const STOPPED = "实时事件连接多次失败,已停止自动重连;网络恢复、回到页面或切回窗口时会再连";
|
|
59
|
+
let probes = 0;
|
|
46
60
|
|
|
47
61
|
const subs = new Map<number, Sub>();
|
|
48
62
|
const observers = new Map<string, Set<(data: string) => void>>();
|
|
@@ -81,16 +95,27 @@ function currentMode(): "ws" | "sse" {
|
|
|
81
95
|
function listen() {
|
|
82
96
|
if (listening || typeof window === "undefined") return;
|
|
83
97
|
listening = true;
|
|
84
|
-
// Back from the background / back online: don't wait out the
|
|
98
|
+
// Back from the background / back online / window focused: don't wait out the
|
|
99
|
+
// backoff, and restart whatever stopped after spending its retry budget.
|
|
85
100
|
const wake = () => {
|
|
86
|
-
if (
|
|
101
|
+
if (subs.size === 0) return;
|
|
102
|
+
if (mode === "sse") {
|
|
103
|
+
probes = 0;
|
|
104
|
+
if (!probeTimer && !cancelProbe) probe();
|
|
105
|
+
for (const s of subs.values()) if (s.stalled) { s.stalled = false; s.fails = 0; openEventSource(s); }
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (mode !== "ws") return;
|
|
109
|
+
attempt = 0;
|
|
87
110
|
if (!ws) connect();
|
|
88
111
|
else if (wsOpen && Date.now() - lastFrame > SILENCE_MS) drop(ws);
|
|
112
|
+
else if (wsOpen) for (const s of subs.values()) if (s.stalled) { s.stalled = false; s.fails = 0; sendSub(s); }
|
|
89
113
|
};
|
|
90
114
|
const visible = () => { if (document.visibilityState === "visible") wake(); };
|
|
91
115
|
document.addEventListener("visibilitychange", visible);
|
|
92
116
|
window.addEventListener("online", wake);
|
|
93
|
-
|
|
117
|
+
window.addEventListener("focus", wake);
|
|
118
|
+
unlisten = () => { document.removeEventListener("visibilitychange", visible); window.removeEventListener("online", wake); window.removeEventListener("focus", wake); listening = false; };
|
|
94
119
|
}
|
|
95
120
|
|
|
96
121
|
function sendSub(s: Sub) {
|
|
@@ -106,6 +131,15 @@ function openEventSource(s: Sub) {
|
|
|
106
131
|
es.onmessage = (event) => { if (active()) deliver(s, event.data); };
|
|
107
132
|
es.onerror = () => {
|
|
108
133
|
if (!active()) return;
|
|
134
|
+
s.fails++;
|
|
135
|
+
// EventSource retries a CONNECTING stream by itself, forever: close it once
|
|
136
|
+
// the budget is spent and wait for a wake instead.
|
|
137
|
+
if (s.fails >= MAX_EVENTSOURCE_ERRORS || (es.readyState === 2 && s.fails >= MAX_STREAM_RETRIES)) {
|
|
138
|
+
es.close(); s.es = undefined; s.stalled = true;
|
|
139
|
+
if (s.retry) { clearTimeout(s.retry); s.retry = undefined; }
|
|
140
|
+
notifyCallback(s.h.onError, new Error(STOPPED));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
109
143
|
notifyCallback(s.h.onError, new Error("实时事件连接中断,正在等待恢复"));
|
|
110
144
|
// EventSource hides HTTP status. CONNECTING retries itself; CLOSED needs
|
|
111
145
|
// a bounded manual retry so renewed auth can recover without a reload.
|
|
@@ -133,7 +167,8 @@ function fallBackToEventSource() {
|
|
|
133
167
|
// restarting while this tab loaded) is gone a minute later. Keep trying the
|
|
134
168
|
// socket and move the streams back onto it as soon as it opens.
|
|
135
169
|
function scheduleProbe() {
|
|
136
|
-
if (probeTimer || subs.size === 0 || mode !== "sse") return;
|
|
170
|
+
if (probeTimer || subs.size === 0 || mode !== "sse" || probes >= MAX_PROBES) return;
|
|
171
|
+
probes++;
|
|
137
172
|
probeTimer = setTimeout(probe, PROBE_MS);
|
|
138
173
|
}
|
|
139
174
|
|
|
@@ -157,7 +192,8 @@ function probe() {
|
|
|
157
192
|
if (mode !== "sse") return;
|
|
158
193
|
mode = "ws";
|
|
159
194
|
failsBeforeOpen = 0;
|
|
160
|
-
|
|
195
|
+
probes = 0;
|
|
196
|
+
for (const s of subs.values()) { s.es?.close(); s.es = undefined; s.stalled = false; s.fails = 0; }
|
|
161
197
|
// Each stream re-snapshots on the socket, so the hand-over loses nothing.
|
|
162
198
|
connect();
|
|
163
199
|
};
|
|
@@ -167,6 +203,10 @@ function probe() {
|
|
|
167
203
|
|
|
168
204
|
function scheduleReconnect() {
|
|
169
205
|
if (reconnectTimer || subs.size === 0) return;
|
|
206
|
+
if (attempt >= MAX_RECONNECTS) {
|
|
207
|
+
for (const s of [...subs.values()]) notifyCallback(s.h.onError, new Error(STOPPED));
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
170
210
|
const delay = BACKOFF_MS[Math.min(attempt, BACKOFF_MS.length - 1)];
|
|
171
211
|
attempt++;
|
|
172
212
|
reconnectTimer = setTimeout(() => { reconnectTimer = undefined; connect(); }, delay);
|
|
@@ -193,6 +233,7 @@ function resubscribeLater(s: Sub, code: number) {
|
|
|
193
233
|
// slowly; permanent missing/invalid resources wait for a new subscription.
|
|
194
234
|
const auth = code === 401 || code === 403;
|
|
195
235
|
if (!auth && code !== 0 && code !== 408 && code !== 429 && code < 500) return;
|
|
236
|
+
if (s.fails >= MAX_STREAM_RETRIES) { s.stalled = true; notifyCallback(s.h.onError, new Error(STOPPED)); return; }
|
|
196
237
|
const delay = auth || code === 429 ? 30_000 : BACKOFF_MS[Math.min(s.fails, BACKOFF_MS.length - 1)] * 2;
|
|
197
238
|
s.fails++;
|
|
198
239
|
if (s.retry) clearTimeout(s.retry);
|
|
@@ -275,7 +316,7 @@ export function openLive(url: string, h: LiveHandlers): LiveSub {
|
|
|
275
316
|
const socket = ws; ws = null; wsOpen = false;
|
|
276
317
|
if (socket) { socket.onopen = socket.onmessage = socket.onclose = socket.onerror = null; try { socket.close(); } catch { /* already closed */ } }
|
|
277
318
|
unlisten?.(); unlisten = undefined;
|
|
278
|
-
mode = null; everOpened = false; failsBeforeOpen = attempt = 0;
|
|
319
|
+
mode = null; everOpened = false; failsBeforeOpen = attempt = probes = 0;
|
|
279
320
|
}
|
|
280
321
|
},
|
|
281
322
|
};
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import type { Priority } from "./protocol/types";
|
|
5
|
-
import { Icon } from "
|
|
5
|
+
import { Icon } from "../../ui/icons";
|
|
6
6
|
import { jget, jsend } from "./api";
|
|
7
7
|
import { relTime, duration, fmtJobCost } from "./format";
|
|
8
|
-
import { type ProjectRow, type ProjectSession, type TaskRow, type AgentsBundle, type InternalUsageEstimate } from "./types";
|
|
8
|
+
import { type ProjectRow, type ProjectSession, type TaskRow, type AgentsBundle, type InternalUsageEstimate, type ProjectDeletePreview } from "./types";
|
|
9
9
|
import { agentLabel, agentStateHint, defaultAgentFor, findAgent } from "./agents";
|
|
10
10
|
import { StatusDot, Skel, ErrNote } from "./shared";
|
|
11
11
|
import { Modal, BrowseDirButton, PrioritySeg, DepPicker } from "./Modal";
|
|
12
12
|
import { GitHubClonePicker } from "./github";
|
|
13
13
|
import { Markdown } from "./Markdown";
|
|
14
14
|
import { clientFeatures } from "./protocol/features";
|
|
15
|
+
import { useRecheckOnReturn } from "./recheckOnReturn";
|
|
15
16
|
|
|
16
17
|
// One-click copy, with the button itself confirming. Used for the project id and
|
|
17
18
|
// for the ready-to-run curl snippets below it.
|
|
@@ -330,10 +331,10 @@ export function EditTaskModal({ task, tasks, agents, onClose, onSave, onDelete,
|
|
|
330
331
|
}
|
|
331
332
|
|
|
332
333
|
// Mirror of the server's RefreshState (lib/contextRefresh.ts) — the detached
|
|
333
|
-
// "Refresh with AI" job state the modal
|
|
334
|
+
// "Refresh with AI" job state the modal re-reads (on return / 检查结果).
|
|
334
335
|
type RefreshState = { status: "idle" | "running" | "done" | "error"; draft: string; error: string; started_at: number; estimate?: InternalUsageEstimate | null };
|
|
335
336
|
|
|
336
|
-
export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSave, onDelete, onDeprecate }: { project: ProjectRow; agents: AgentsBundle; onSetDefaultAgent: (agent: string) => void; onClose: () => void; onSave: (p: { name: string; context: string; send_context: number; repo_path: string; branch: string; dev_command: string; setup_command: string; test_command: string }) => void; onDelete: () => void; onDeprecate: () => void }) {
|
|
337
|
+
export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSave, onDelete, onDeprecate }: { project: ProjectRow; agents: AgentsBundle; onSetDefaultAgent: (agent: string) => void; onClose: () => void; onSave: (p: { name: string; context: string; send_context: number; repo_path: string; branch: string; dev_command: string; setup_command: string; test_command: string }) => void; onDelete: (confirm?: { delete_storage: string }) => Promise<void> | void; onDeprecate: () => void }) {
|
|
337
338
|
const [name, setName] = useState(project.name);
|
|
338
339
|
const [context, setContext] = useState(project.context);
|
|
339
340
|
const [sendContext, setSendContext] = useState(project.send_context !== 0);
|
|
@@ -343,10 +344,33 @@ export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSa
|
|
|
343
344
|
const [setupCmd, setSetupCmd] = useState(project.setup_command);
|
|
344
345
|
const [testCmd, setTestCmd] = useState(project.test_command);
|
|
345
346
|
const [confirmDel, setConfirmDel] = useState(false);
|
|
347
|
+
// Two steps: the first click asks the node what deleting would remove from disk
|
|
348
|
+
// (a platform-created Job project owns directories; any other project keeps its
|
|
349
|
+
// repository), the second deletes and confirms exactly the root that was shown.
|
|
350
|
+
const [delPreview, setDelPreview] = useState<ProjectDeletePreview | null | "loading" | "unavailable">(null);
|
|
351
|
+
const [deleting, setDeleting] = useState(false);
|
|
352
|
+
const [deleteErr, setDeleteErr] = useState<string | null>(null);
|
|
353
|
+
const askDelete = () => {
|
|
354
|
+
setConfirmDel(true);
|
|
355
|
+
setDeleteErr(null);
|
|
356
|
+
setDelPreview("loading");
|
|
357
|
+
jget<ProjectDeletePreview>(`/api/projects/${project.id}/delete-preview`)
|
|
358
|
+
.then(setDelPreview)
|
|
359
|
+
// An older node has no preview: it never deletes directories with a project.
|
|
360
|
+
.catch(() => setDelPreview("unavailable"));
|
|
361
|
+
};
|
|
362
|
+
const delStorage = delPreview && typeof delPreview === "object" ? delPreview.storage : null;
|
|
363
|
+
const confirmDelete = async () => {
|
|
364
|
+
setDeleting(true);
|
|
365
|
+
setDeleteErr(null);
|
|
366
|
+
try { await onDelete(delStorage ? { delete_storage: delStorage.root } : undefined); }
|
|
367
|
+
catch (e) { setDeleteErr(e instanceof Error ? e.message : String(e)); }
|
|
368
|
+
finally { setDeleting(false); }
|
|
369
|
+
};
|
|
346
370
|
const showServices = clientFeatures().services;
|
|
347
371
|
// AI context refresh: let Claude read the repo and draft fresh context. The
|
|
348
372
|
// draft now runs as a DETACHED server-side job (it can take minutes and must
|
|
349
|
-
// survive sleep/reload), so the client starts it and
|
|
373
|
+
// survive sleep/reload), so the client starts it and re-reads the result
|
|
350
374
|
// rather than holding one long request open. The drafted text replaces the
|
|
351
375
|
// textarea but isn't saved until Save — we stash the prior text for Undo.
|
|
352
376
|
const [refreshing, setRefreshing] = useState(false);
|
|
@@ -359,18 +383,18 @@ export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSa
|
|
|
359
383
|
const showPreview = preview && !refreshing;
|
|
360
384
|
|
|
361
385
|
// Latest edited context, read inside async handlers without making them
|
|
362
|
-
// depend on `context` (which would churn the
|
|
386
|
+
// depend on `context` (which would churn the re-check effect / stale-close it).
|
|
363
387
|
const contextRef = useRef(context);
|
|
364
388
|
contextRef.current = context;
|
|
365
389
|
// started_at of the job whose result we've already applied — so a draft is
|
|
366
|
-
// consumed exactly once even if a POST reply and a
|
|
390
|
+
// consumed exactly once even if a POST reply and a re-check race.
|
|
367
391
|
const appliedRef = useRef(0);
|
|
368
392
|
|
|
369
393
|
const ackRefresh = useCallback(() => {
|
|
370
394
|
jsend(`/api/projects/${project.id}/refresh-context`, "DELETE").catch(() => {});
|
|
371
395
|
}, [project.id]);
|
|
372
396
|
|
|
373
|
-
// Fold a
|
|
397
|
+
// Fold a re-read job state into the UI. Idempotent: applies a finished draft at
|
|
374
398
|
// most once, then acks it so it doesn't resurface on the next modal open.
|
|
375
399
|
const handleState = useCallback((s: RefreshState) => {
|
|
376
400
|
setRefreshEstimate(s.estimate ?? null);
|
|
@@ -401,15 +425,13 @@ export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSa
|
|
|
401
425
|
return () => { alive = false; };
|
|
402
426
|
}, [project.id, handleState]);
|
|
403
427
|
|
|
404
|
-
// While a job runs,
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return () => clearInterval(t);
|
|
412
|
-
}, [refreshing, project.id, handleState]);
|
|
428
|
+
// While a job runs, re-check its result when the user comes back to this tab or
|
|
429
|
+
// presses 检查结果 (useRecheckOnReturn; no polling). Stops when refreshing flips
|
|
430
|
+
// false (terminal state) or the modal unmounts — the job keeps running server-side.
|
|
431
|
+
const checkRefresh = () => {
|
|
432
|
+
jget<RefreshState>(`/api/projects/${project.id}/refresh-context`).then(handleState).catch(() => {});
|
|
433
|
+
};
|
|
434
|
+
useRecheckOnReturn(refreshing, checkRefresh);
|
|
413
435
|
|
|
414
436
|
const refreshContext = async () => {
|
|
415
437
|
if (refreshing) return;
|
|
@@ -429,10 +451,13 @@ export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSa
|
|
|
429
451
|
<Modal title={<>项目上下文 <CopyIdChip id={project.id} /></>} sub={`会前置到 ${project.name} 的每个任务`} onClose={onClose} width={620}
|
|
430
452
|
footer={<>
|
|
431
453
|
{confirmDel ? (
|
|
432
|
-
<button className="btn-danger on" onClick={
|
|
454
|
+
<button className="btn-danger on" onClick={confirmDelete} disabled={delPreview === "loading" || deleting}
|
|
455
|
+
title={delStorage ? "永久删除该项目、任务和对话历史,以及下面列出的目录" : "永久删除该项目及其任务和对话历史"}>
|
|
456
|
+
{Icon.x()} {deleting ? "正在删除…" : delStorage ? `永久删除 ${project.name} 及其目录` : `永久删除 ${project.name}`}
|
|
457
|
+
</button>
|
|
433
458
|
) : (
|
|
434
459
|
<>
|
|
435
|
-
<button className="btn-danger" onClick={
|
|
460
|
+
<button className="btn-danger" onClick={askDelete}>{Icon.x()} 删除项目</button>
|
|
436
461
|
<button className="btn btn-line" onClick={onDeprecate} title="把该项目收进侧栏的已归档区域。不会删除任何内容 —— 随时可以恢复。">{Icon.archive()} 归档</button>
|
|
437
462
|
</>
|
|
438
463
|
)}
|
|
@@ -486,7 +511,8 @@ export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSa
|
|
|
486
511
|
) : refreshing ? (
|
|
487
512
|
<div className="hlp" style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
488
513
|
<span className="typing"><i /><i /><i /></span>
|
|
489
|
-
正在浏览 {repo.split("/").pop() || "仓库"} 以起草新的上下文 ——
|
|
514
|
+
正在浏览 {repo.split("/").pop() || "仓库"} 以起草新的上下文 —— 可能需要一分钟;切走再回来时会自动检查。
|
|
515
|
+
<button className="linkbtn" onClick={checkRefresh}>检查结果</button>
|
|
490
516
|
</div>
|
|
491
517
|
) : prevContext != null ? (
|
|
492
518
|
<div className="hlp">已根据仓库起草。请审阅并修改后保存 —— 或点击「撤销」还原。</div>
|
|
@@ -548,8 +574,19 @@ export function ContextModal({ project, agents, onSetDefaultAgent, onClose, onSa
|
|
|
548
574
|
)}
|
|
549
575
|
<ProjectApiSnippets projectId={project.id} />
|
|
550
576
|
{confirmDel && (
|
|
551
|
-
<div className="hlp" style={{ color: "var(--red)", marginTop: 16 }}>
|
|
552
|
-
|
|
577
|
+
<div className="hlp project-delete-confirm" style={{ color: "var(--red)", marginTop: 16 }}>
|
|
578
|
+
{delPreview === "loading" ? "正在确认删除范围…" : delStorage ? (
|
|
579
|
+
<>
|
|
580
|
+
这会从编排器中永久删除“{project.name}”及其任务和对话历史,并删除平台为这个大任务建立的以下目录,不可恢复:
|
|
581
|
+
<ul className="ctx-mono" style={{ margin: "6px 0", paddingLeft: 18 }}>
|
|
582
|
+
{delStorage.directories.map((dir) => <li key={dir}>{dir}</li>)}
|
|
583
|
+
</ul>
|
|
584
|
+
{typeof delPreview === "object" && delPreview?.material_root ? <>资料目录 {delPreview.material_root} 不会删除。</> : null}
|
|
585
|
+
</>
|
|
586
|
+
) : (
|
|
587
|
+
<>这会从编排器中永久删除“{project.name}”及其任务和对话历史。磁盘上{repo ? ` ${repo} 中` : ""}的代码不会被改动。</>
|
|
588
|
+
)}
|
|
589
|
+
{deleteErr && <div style={{ marginTop: 6 }}>{deleteErr}</div>}
|
|
553
590
|
</div>
|
|
554
591
|
)}
|
|
555
592
|
</Modal>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Re-check something that settles elsewhere (a browser-side login approval, a
|
|
7
|
+
* server job) without polling: no timer ever calls `check`. While `active`, it
|
|
8
|
+
* runs once whenever the user comes back — the tab becomes visible, the window
|
|
9
|
+
* regains focus, the network is back — which is when a login approved in
|
|
10
|
+
* another tab (or a job that finished meanwhile) has most likely settled.
|
|
11
|
+
* Callers also show an explicit "检查状态" button wired to the same `check`.
|
|
12
|
+
*/
|
|
13
|
+
export function useRecheckOnReturn(active: boolean, check: () => void): void {
|
|
14
|
+
const latest = useRef(check);
|
|
15
|
+
latest.current = check;
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!active) return;
|
|
18
|
+
const wake = () => { if (document.visibilityState !== "hidden") latest.current(); };
|
|
19
|
+
window.addEventListener("focus", wake);
|
|
20
|
+
window.addEventListener("online", wake);
|
|
21
|
+
document.addEventListener("visibilitychange", wake);
|
|
22
|
+
return () => {
|
|
23
|
+
window.removeEventListener("focus", wake);
|
|
24
|
+
window.removeEventListener("online", wake);
|
|
25
|
+
document.removeEventListener("visibilitychange", wake);
|
|
26
|
+
};
|
|
27
|
+
}, [active]);
|
|
28
|
+
}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import type { Priority, Status } from "./protocol/types";
|
|
4
|
-
import { Icon
|
|
4
|
+
import { Icon } from "../../ui/icons";
|
|
5
|
+
import { Spinner, StatusDot as SharedStatusDot } from "../../ui/shared";
|
|
5
6
|
import { SCLS, SLABEL, AWAIT_LABEL } from "./types";
|
|
6
7
|
|
|
8
|
+
// Signal language (mission-control): "needs your input" is an alert coral, a
|
|
9
|
+
// *live* working session is blue (both pulse), an idle status falls back to its
|
|
10
|
+
// base color; awaiting wins over running. Drawn by the shared dot (ui/shared),
|
|
11
|
+
// keyed here by the node's task status.
|
|
7
12
|
export function StatusDot({ status, running, awaiting, lg }: { status: Status; running?: boolean; awaiting?: boolean; lg?: boolean }) {
|
|
8
|
-
|
|
9
|
-
// *live* working session is blue (both pulse to draw the eye), and an idle
|
|
10
|
-
// status falls back to its base color. Awaiting wins over running — a turn
|
|
11
|
-
// parked on a question is technically live but it's really waiting on you.
|
|
12
|
-
const cls = awaiting ? "c" : running ? "b" : SCLS[status];
|
|
13
|
-
return (
|
|
14
|
-
<span
|
|
15
|
-
className={`sdot ${cls} ${lg ? "lg" : ""} ${awaiting || running ? "pulse" : ""}`}
|
|
16
|
-
title={awaiting ? AWAIT_LABEL : running ? "运行中" : SLABEL[status]}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
13
|
+
return <SharedStatusDot cls={SCLS[status]} running={running} awaiting={awaiting} lg={lg} title={awaiting ? AWAIT_LABEL : running ? "运行中" : SLABEL[status]} />;
|
|
19
14
|
}
|
|
20
15
|
|
|
21
16
|
export function PriPill({ p }: { p: Priority }) {
|
|
@@ -37,53 +32,18 @@ export function SearchBar({ value, onChange, placeholder }: { value: string; onC
|
|
|
37
32
|
);
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
export function Avatar({ who, agent }: { who: "user" | "cc"; agent?: string | null }) {
|
|
44
|
-
if (who === "user") return <span className="av you">A</span>;
|
|
45
|
-
const mark = agent ? AgentMark[agent] : undefined;
|
|
46
|
-
return <span className={`av cc${mark ? ` ${agent}` : ""}`}>{mark ? mark() : Icon.bolt()}</span>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Which agent driver a task runs under (Claude Code / Codex …). Hidden when only
|
|
50
|
-
// one agent is available (nothing to disambiguate) so single-agent workspaces
|
|
51
|
-
// stay clutter-free. `multi` is passed by the caller from the agents bundle.
|
|
52
|
-
export function AgentBadge({ label, multi }: { label: string; multi: boolean }) {
|
|
53
|
-
if (!multi) return null;
|
|
54
|
-
return <span className="agent-badge" title={`运行于 ${label}`}>{label}</span>;
|
|
55
|
-
}
|
|
35
|
+
// Avatar (the agent's brand mark), AgentBadge (hidden when only one agent is
|
|
36
|
+
// configured: pass `multi`), Spinner, Skel and ErrNote are the shared ones.
|
|
37
|
+
export { Avatar, AgentBadge, Spinner, Skel, ErrNote } from "../../ui/shared";
|
|
56
38
|
|
|
57
39
|
// ---- async-state primitives (pair with the .spinner/.load-note/.skel/.err-note
|
|
58
40
|
// styles in globals.css) — every panel that fetches uses these, so loading and
|
|
59
41
|
// error presentation stays uniform across the app. ----
|
|
60
42
|
|
|
61
|
-
export function Spinner({ size }: { size?: number }) {
|
|
62
|
-
return <span className="spinner" role="status" aria-label="加载中" style={size ? { width: size, height: size } : undefined} />;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
43
|
// Standard "we're fetching" line: spinner + quiet text. Replaces bare "Loading…".
|
|
66
44
|
export function LoadNote({ children, style }: { children: React.ReactNode; style?: React.CSSProperties }) {
|
|
67
45
|
return <div className="load-note" style={style}><Spinner size={13} />{children}</div>;
|
|
68
46
|
}
|
|
69
47
|
|
|
70
|
-
// One shimmer bar. Compose a few for card/list/transcript skeletons.
|
|
71
|
-
export function Skel({ w, h = 10, r, style }: { w: number | string; h?: number; r?: number | string; style?: React.CSSProperties }) {
|
|
72
|
-
return <span className="skel" aria-hidden style={{ width: w, height: h, ...(r !== undefined ? { borderRadius: r } : null), ...style }} />;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Recoverable-error line: the message plus an inline Retry when the caller can
|
|
76
|
-
// simply refetch. Same warm-red voice as transcript system errors.
|
|
77
|
-
export function ErrNote({ children, onRetry, retryLabel = "重试", style }: {
|
|
78
|
-
children: React.ReactNode; onRetry?: () => void; retryLabel?: string; style?: React.CSSProperties;
|
|
79
|
-
}) {
|
|
80
|
-
return (
|
|
81
|
-
<div className="err-note" style={style}>
|
|
82
|
-
<span className="err-msg">⚠ {children}</span>
|
|
83
|
-
{onRetry && <button className="btn btn-line btn-sm" onClick={onRetry}>{Icon.restore()} {retryLabel}</button>}
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
48
|
// One shared accessible popover for the full workspace and standalone controls.
|
|
89
49
|
export { Popover } from "../../ui/Popover";
|
|
@@ -27,6 +27,15 @@ export interface ProjectRow {
|
|
|
27
27
|
awaiting_count: number; // in-progress tasks waiting on the user (across this project)
|
|
28
28
|
cost_usd: number; // cumulative dollar spend across all this project's tasks
|
|
29
29
|
}
|
|
30
|
+
/** GET /api/projects/:id/delete-preview — what deleting the project removes from disk. */
|
|
31
|
+
export interface ProjectDeletePreview {
|
|
32
|
+
project_id: string;
|
|
33
|
+
repo_path: string;
|
|
34
|
+
/** Only for a project the platform created for one Job; null = the repository stays on disk. */
|
|
35
|
+
storage: { job_id: string; root: string; state: string; directories: string[] } | null;
|
|
36
|
+
/** The Job's material directory: never deleted with the project. */
|
|
37
|
+
material_root: string | null;
|
|
38
|
+
}
|
|
30
39
|
export interface TaskRow {
|
|
31
40
|
parent_task_id?: string|null; fork_commit?: string; fork_source_title?: string; fork_context?: string; fork_group_id?: string; work_branch?: string; created_at?: number;
|
|
32
41
|
id: string;
|