@agimon-ai/po-artifact 0.0.0-alpha.2 → 0.0.0-alpha.21
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/LICENSE +149 -21
- package/README.md +1 -1
- package/dist/apiContracts.cjs +10 -2
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +10 -2
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{artifactFiles-Bo5Mhwq0.cjs → artifactFiles-BmBU9Olm.cjs} +138 -76
- package/dist/artifactFiles-BmBU9Olm.cjs.map +1 -0
- package/dist/{artifactFiles-B8w_HQXv.mjs → artifactFiles-DyIkevXc.mjs} +119 -57
- package/dist/artifactFiles-DyIkevXc.mjs.map +1 -0
- package/dist/artifactFiles.cjs +7 -1
- package/dist/artifactFiles.d.mts +14 -1
- package/dist/artifactFiles.d.mts.map +1 -1
- package/dist/artifactFiles.mjs +3 -1
- package/dist/artifacts-Bhobz1nK.mjs +38 -0
- package/dist/artifacts-Bhobz1nK.mjs.map +1 -0
- package/dist/artifacts-DG_b7DZH.cjs +85 -0
- package/dist/artifacts-DG_b7DZH.cjs.map +1 -0
- package/dist/artifacts-sIj4Xaeu.d.mts +32 -0
- package/dist/artifacts-sIj4Xaeu.d.mts.map +1 -0
- package/dist/extensions/native.mjs +640 -32
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +163 -44
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +161 -42
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +848 -136
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.d.mts +8 -19
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +20 -20
- package/dist/artifactFiles-B8w_HQXv.mjs.map +0 -1
- package/dist/artifactFiles-Bo5Mhwq0.cjs.map +0 -1
package/dist/extensions/web.mjs
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import { createApiClient, defineActivityGroup, defineChannelFile, defineFill, defineSessionStore, defineWebPlugin, sessionApiAddress } from "@agimon-ai/po-core/web";
|
|
2
|
-
import { Breadcrumb, Button, CodeEditor, EmptyState, FileIcon, Markdown, MediaPreview } from "@agimon-ai/po-web-components";
|
|
1
|
+
import { createApiClient, defineActivityGroup, defineChannelFile, defineFileLinks, defineFill, defineGlobalStore, defineSessionStore, defineWebPlugin, sessionApiAddress } from "@agimon-ai/po-core/web";
|
|
2
|
+
import { Breadcrumb, Button, ChevronDownIcon, ChevronRightIcon, CloseIcon, CodeEditor, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, EmptyState, FileIcon, FolderIcon, GridIcon, ImageIcon, Input, ListIcon, Markdown, MediaPreview, SearchIcon, SlidersIcon, tabVariants } from "@agimon-ai/po-web-components";
|
|
3
3
|
import { useStore } from "@tanstack/react-store";
|
|
4
|
-
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { sealedTransport } from "@agimon-ai/po-web-security/browser";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/constants/artifacts.ts
|
|
8
|
+
/** Autocompact mirrors compaction history here; the recent-artifacts card leaves it out. */
|
|
9
|
+
const COMPACTION_ARTIFACT_DIRECTORY = "compaction";
|
|
10
|
+
const ARTIFACT_REFRESH_MS = 2e3;
|
|
7
11
|
const api = createApiClient({
|
|
8
12
|
list: {
|
|
9
13
|
method: "GET",
|
|
10
14
|
path: "/",
|
|
15
|
+
query: ["scope"],
|
|
11
16
|
response: void 0
|
|
12
17
|
},
|
|
13
18
|
preview: {
|
|
14
19
|
method: "GET",
|
|
15
20
|
path: "/preview",
|
|
16
|
-
query: ["path"],
|
|
21
|
+
query: ["path", "scope"],
|
|
17
22
|
response: void 0
|
|
18
23
|
},
|
|
19
24
|
content: {
|
|
20
25
|
method: "GET",
|
|
21
26
|
path: "/content",
|
|
22
|
-
query: ["path"],
|
|
27
|
+
query: ["path", "scope"],
|
|
23
28
|
raw: true
|
|
24
29
|
}
|
|
25
30
|
}, {
|
|
@@ -33,9 +38,103 @@ const api = createApiClient({
|
|
|
33
38
|
const artifactsChannelType = "artifacts";
|
|
34
39
|
//#endregion
|
|
35
40
|
//#region src/extensions/workspaces/sessions/(frontend)/_lib/artifactView.ts
|
|
41
|
+
function isArtifactLayout(value) {
|
|
42
|
+
return value === "tree" || value === "list" || value === "grid";
|
|
43
|
+
}
|
|
44
|
+
function artifactKind(path) {
|
|
45
|
+
if (/\.(?:md|markdown)$/iu.test(path)) return "Markdown";
|
|
46
|
+
if (/\.(?:png|jpe?g|gif|webp|avif|bmp|svg|ico|tiff?)$/iu.test(path)) return "Image";
|
|
47
|
+
if (/\.(?:jsonl?|csv|tsv|ya?ml|xml|toml|parquet|sqlite|db)$/iu.test(path)) return "Data";
|
|
48
|
+
if (/\.(?:[cm]?[jt]sx?|html?|css|scss|sass|less|py|sh|bash|go|rs|rb|java|c|cpp|cc|h|hpp|sql|swift|kt|kts|php|vue|svelte)$/iu.test(path)) return "Code";
|
|
49
|
+
if (/\.(?:pdf|txt|rtf|docx?|xlsx?|pptx?|odt|ods|odp)$/iu.test(path)) return "Document";
|
|
50
|
+
return "Other";
|
|
51
|
+
}
|
|
52
|
+
/** Time is supplied by the caller. Today starts at local midnight; day windows are inclusive. */
|
|
53
|
+
function filterArtifacts(items, filters, now) {
|
|
54
|
+
const query = (filters.query ?? "").trim().toLowerCase();
|
|
55
|
+
const modified = filters.modified ?? "any";
|
|
56
|
+
const day = 864e5;
|
|
57
|
+
const midnight = new Date(now);
|
|
58
|
+
midnight.setHours(0, 0, 0, 0);
|
|
59
|
+
const since = modified === "today" ? midnight.getTime() : now - (modified === "7days" ? 7 : 30) * day;
|
|
60
|
+
return items.filter((item) => item.path.toLowerCase().includes(query) && (!filters.type || filters.type === "any" || artifactKind(item.path) === filters.type) && (modified === "any" || item.modifiedAt >= since && item.modifiedAt <= now));
|
|
61
|
+
}
|
|
62
|
+
/** Sort a copy, with an ascending full-path tie breaker in either direction. */
|
|
63
|
+
function sortArtifacts(items, sort, direction) {
|
|
64
|
+
return [...items].sort((left, right) => {
|
|
65
|
+
return (sort === "name" ? comparePaths(left.name.toLowerCase(), right.name.toLowerCase()) : sort === "size" ? left.size - right.size : left.modifiedAt - right.modifiedAt) * (direction === "asc" ? 1 : -1) || comparePaths(left.path, right.path);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function comparePaths(left, right) {
|
|
69
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
70
|
+
}
|
|
71
|
+
/** Derive folders from already filtered, sorted files. Folders precede files and compact single-child chains. */
|
|
72
|
+
function artifactTree(items, isOpen) {
|
|
73
|
+
const root = {
|
|
74
|
+
path: "",
|
|
75
|
+
dirs: /* @__PURE__ */ new Map(),
|
|
76
|
+
files: [],
|
|
77
|
+
count: 0
|
|
78
|
+
};
|
|
79
|
+
for (const item of items) {
|
|
80
|
+
let dir = root;
|
|
81
|
+
dir.count++;
|
|
82
|
+
for (const segment of item.path.split("/").slice(0, -1)) {
|
|
83
|
+
let next = dir.dirs.get(segment);
|
|
84
|
+
if (!next) {
|
|
85
|
+
next = {
|
|
86
|
+
path: dir.path ? `${dir.path}/${segment}` : segment,
|
|
87
|
+
dirs: /* @__PURE__ */ new Map(),
|
|
88
|
+
files: [],
|
|
89
|
+
count: 0
|
|
90
|
+
};
|
|
91
|
+
dir.dirs.set(segment, next);
|
|
92
|
+
}
|
|
93
|
+
dir = next;
|
|
94
|
+
dir.count++;
|
|
95
|
+
}
|
|
96
|
+
dir.files.push(item);
|
|
97
|
+
}
|
|
98
|
+
const rows = [];
|
|
99
|
+
const walk = (dir, depth) => {
|
|
100
|
+
for (const [segment, child] of [...dir.dirs].sort(([left], [right]) => comparePaths(left, right))) {
|
|
101
|
+
let name = segment;
|
|
102
|
+
let node = child;
|
|
103
|
+
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
104
|
+
const [[nextName, next]] = [...node.dirs];
|
|
105
|
+
name = `${name}/${nextName}`;
|
|
106
|
+
node = next;
|
|
107
|
+
}
|
|
108
|
+
const open = isOpen(node.path);
|
|
109
|
+
rows.push({
|
|
110
|
+
kind: "dir",
|
|
111
|
+
path: node.path,
|
|
112
|
+
name,
|
|
113
|
+
depth,
|
|
114
|
+
open,
|
|
115
|
+
count: node.count
|
|
116
|
+
});
|
|
117
|
+
if (open) walk(node, depth + 1);
|
|
118
|
+
}
|
|
119
|
+
for (const item of dir.files) rows.push({
|
|
120
|
+
kind: "file",
|
|
121
|
+
item,
|
|
122
|
+
depth
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
walk(root, 0);
|
|
126
|
+
return rows;
|
|
127
|
+
}
|
|
128
|
+
function sizeLabel(size) {
|
|
129
|
+
return size < 1024 ? `${size} B` : size < 1048576 ? `${Math.ceil(size / 1024)} KB` : `${(size / 1048576).toFixed(1)} MB`;
|
|
130
|
+
}
|
|
36
131
|
function sortedArtifacts(items) {
|
|
37
132
|
return [...items].sort((left, right) => right.modifiedAt - left.modifiedAt || (left.path < right.path ? -1 : left.path > right.path ? 1 : 0));
|
|
38
133
|
}
|
|
134
|
+
/** The recent card shows the person's documents; compaction history stays in the full grid. */
|
|
135
|
+
function recentArtifacts(items) {
|
|
136
|
+
return sortedArtifacts(items.filter((item) => !item.path.startsWith(`${COMPACTION_ARTIFACT_DIRECTORY}/`))).slice(0, 3);
|
|
137
|
+
}
|
|
39
138
|
function artifactTabId(sessionId, path) {
|
|
40
139
|
return `artifact:${encodeURIComponent(sessionId)}:${encodeURIComponent(path)}`;
|
|
41
140
|
}
|
|
@@ -76,6 +175,7 @@ function parseArtifactSnapshot(input) {
|
|
|
76
175
|
}
|
|
77
176
|
return {
|
|
78
177
|
items: sortedArtifacts(items),
|
|
178
|
+
..."temporaryRoot" in input && typeof input.temporaryRoot === "string" ? { temporaryRoot: input.temporaryRoot } : {},
|
|
79
179
|
..."error" in input && typeof input.error === "string" ? { error: input.error } : {}
|
|
80
180
|
};
|
|
81
181
|
}
|
|
@@ -101,6 +201,22 @@ const artifactActivitySource = {
|
|
|
101
201
|
},
|
|
102
202
|
isActive: () => false
|
|
103
203
|
};
|
|
204
|
+
const LAYOUT_KEY = "po.artifacts.layout.v1";
|
|
205
|
+
function readArtifactLayout() {
|
|
206
|
+
try {
|
|
207
|
+
const value = globalThis.localStorage.getItem(LAYOUT_KEY);
|
|
208
|
+
return isArtifactLayout(value) ? value : "tree";
|
|
209
|
+
} catch {
|
|
210
|
+
return "tree";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const artifactLayout = defineGlobalStore(readArtifactLayout());
|
|
214
|
+
function setArtifactLayout(layout) {
|
|
215
|
+
artifactLayout.update(() => layout);
|
|
216
|
+
try {
|
|
217
|
+
globalThis.localStorage.setItem(LAYOUT_KEY, layout);
|
|
218
|
+
} catch {}
|
|
219
|
+
}
|
|
104
220
|
//#endregion
|
|
105
221
|
//#region src/extensions/workspaces/sessions/(frontend)/_lib/artifactsApi.ts
|
|
106
222
|
async function refreshArtifacts(sessionId, signal) {
|
|
@@ -125,9 +241,22 @@ async function refreshArtifacts(sessionId, signal) {
|
|
|
125
241
|
}));
|
|
126
242
|
}
|
|
127
243
|
}
|
|
128
|
-
async function
|
|
244
|
+
async function fetchArtifacts(sessionId, signal, scope = "artifacts") {
|
|
245
|
+
const result = await api.session(sessionId).list({
|
|
246
|
+
...scope === "temporary" ? { query: { scope } } : {},
|
|
247
|
+
signal
|
|
248
|
+
});
|
|
249
|
+
if (!result.ok) throw new Error(result.error || "Files could not be loaded.");
|
|
250
|
+
const snapshot = parseArtifactSnapshot(result.data);
|
|
251
|
+
if (!snapshot) throw new Error("The session returned an invalid file list.");
|
|
252
|
+
return snapshot;
|
|
253
|
+
}
|
|
254
|
+
async function fetchArtifactPreview(sessionId, path, signal, scope = "artifacts") {
|
|
129
255
|
const result = await api.session(sessionId).preview({
|
|
130
|
-
query: {
|
|
256
|
+
query: {
|
|
257
|
+
path,
|
|
258
|
+
...scope === "temporary" ? { scope } : {}
|
|
259
|
+
},
|
|
131
260
|
signal
|
|
132
261
|
});
|
|
133
262
|
if (!result.ok) throw new Error(result.error || "This artifact could not be read.");
|
|
@@ -136,16 +265,19 @@ async function fetchArtifactPreview(sessionId, path, signal) {
|
|
|
136
265
|
return preview;
|
|
137
266
|
}
|
|
138
267
|
/** Generated raw calls keep media and Markdown asset reads on the sealed artifact transport. */
|
|
139
|
-
async function artifactBlob(sessionId, path, signal) {
|
|
268
|
+
async function artifactBlob(sessionId, path, signal, scope = "artifacts") {
|
|
140
269
|
const result = await api.session(sessionId).content({
|
|
141
|
-
query: {
|
|
270
|
+
query: {
|
|
271
|
+
path,
|
|
272
|
+
...scope === "temporary" ? { scope } : {}
|
|
273
|
+
},
|
|
142
274
|
...signal ? { signal } : {}
|
|
143
275
|
});
|
|
144
276
|
if (!result.ok) throw new Error(result.error || "This artifact could not be loaded.");
|
|
145
277
|
return result.response.blob();
|
|
146
278
|
}
|
|
147
|
-
async function loadArtifactImage(sessionId, documentPath, imagePath) {
|
|
148
|
-
const blob = await artifactBlob(sessionId, artifactAssetPath(documentPath, imagePath));
|
|
279
|
+
async function loadArtifactImage(sessionId, documentPath, imagePath, scope = "artifacts") {
|
|
280
|
+
const blob = await artifactBlob(sessionId, artifactAssetPath(documentPath, imagePath), void 0, scope);
|
|
149
281
|
if (!blob.type.startsWith("image/")) throw new Error("This artifact asset is not an image.");
|
|
150
282
|
const url = URL.createObjectURL(blob);
|
|
151
283
|
return {
|
|
@@ -154,34 +286,48 @@ async function loadArtifactImage(sessionId, documentPath, imagePath) {
|
|
|
154
286
|
};
|
|
155
287
|
}
|
|
156
288
|
//#endregion
|
|
289
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/authorSourceAction.ts
|
|
290
|
+
const authorSourceActionSlot = {
|
|
291
|
+
slot: "author.open-source",
|
|
292
|
+
parse(input) {
|
|
293
|
+
if (typeof input !== "object" || input === null) return null;
|
|
294
|
+
const action = input;
|
|
295
|
+
return action.version === 1 && typeof action.createTab === "function" ? action : null;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
/** Author's open action when the installed plugin contributes it. */
|
|
299
|
+
function authorSourceAction(props) {
|
|
300
|
+
return props.sessionId !== null ? props.slotData?.(authorSourceActionSlot)?.[0]?.data : void 0;
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
157
303
|
//#region src/extensions/workspaces/sessions/(frontend)/_components/ArtifactPreviewView.tsx
|
|
158
304
|
function ArtifactPreviewView({ path, preview, error, media, loadImage }) {
|
|
159
305
|
const mode = artifactPreviewMode(path);
|
|
160
306
|
return /* @__PURE__ */ jsxs("div", {
|
|
161
307
|
"data-testid": "artifact-preview",
|
|
162
308
|
"data-artifact-path": path,
|
|
163
|
-
className: "flex min-h-0 flex-1 flex-col bg-
|
|
309
|
+
className: "flex min-h-0 flex-1 flex-col bg-po-bg text-po-text",
|
|
164
310
|
children: [/* @__PURE__ */ jsxs("header", {
|
|
165
|
-
className: "flex shrink-0 items-center gap-2 border-b border-
|
|
311
|
+
className: "flex shrink-0 items-center gap-2 border-b border-po-border px-4 py-3",
|
|
166
312
|
children: [/* @__PURE__ */ jsx(Breadcrumb, {
|
|
167
313
|
path,
|
|
168
314
|
className: "min-w-0 flex-1"
|
|
169
315
|
}), /* @__PURE__ */ jsx("span", {
|
|
170
|
-
className: "text-sm text-
|
|
316
|
+
className: "text-sm text-po-dim",
|
|
171
317
|
children: "Artifact"
|
|
172
318
|
})]
|
|
173
319
|
}), /* @__PURE__ */ jsx("div", {
|
|
174
320
|
className: "min-h-0 flex-1 overflow-auto p-4",
|
|
175
321
|
children: error ? /* @__PURE__ */ jsx("p", {
|
|
176
322
|
role: "alert",
|
|
177
|
-
className: "text-sm text-
|
|
323
|
+
className: "text-sm text-po-red",
|
|
178
324
|
children: error
|
|
179
325
|
}) : !preview ? /* @__PURE__ */ jsx("p", {
|
|
180
326
|
role: "status",
|
|
181
|
-
className: "text-sm text-
|
|
327
|
+
className: "text-sm text-po-dim",
|
|
182
328
|
children: "Reading this artifact..."
|
|
183
329
|
}) : mode === "media" ? media : preview.unavailable ? /* @__PURE__ */ jsx("p", {
|
|
184
|
-
className: "text-sm text-
|
|
330
|
+
className: "text-sm text-po-dim",
|
|
185
331
|
children: preview.reason ?? "This artifact cannot be previewed."
|
|
186
332
|
}) : mode === "markdown" ? /* @__PURE__ */ jsx(Markdown, {
|
|
187
333
|
text: preview.content,
|
|
@@ -190,14 +336,14 @@ function ArtifactPreviewView({ path, preview, error, media, loadImage }) {
|
|
|
190
336
|
title: path,
|
|
191
337
|
sandbox: "",
|
|
192
338
|
srcDoc: preview.content,
|
|
193
|
-
className: "h-96 w-full rounded-md border border-
|
|
339
|
+
className: "h-96 w-full rounded-md border border-po-border bg-po-deep"
|
|
194
340
|
}) : mode === "code" ? /* @__PURE__ */ jsx(CodeEditor, {
|
|
195
341
|
value: preview.content,
|
|
196
342
|
path,
|
|
197
343
|
readOnly: true,
|
|
198
|
-
className: "min-h-64 rounded-md border border-
|
|
344
|
+
className: "min-h-64 rounded-md border border-po-border"
|
|
199
345
|
}) : /* @__PURE__ */ jsx("pre", {
|
|
200
|
-
className: "whitespace-pre-wrap break-words font-mono text-sm text-
|
|
346
|
+
className: "whitespace-pre-wrap break-words font-mono text-sm text-po-text",
|
|
201
347
|
children: preview.content
|
|
202
348
|
})
|
|
203
349
|
})]
|
|
@@ -205,13 +351,13 @@ function ArtifactPreviewView({ path, preview, error, media, loadImage }) {
|
|
|
205
351
|
}
|
|
206
352
|
//#endregion
|
|
207
353
|
//#region src/extensions/workspaces/sessions/(frontend)/_components/ArtifactPreviewPanel.tsx
|
|
208
|
-
function ArtifactMedia({ sessionId, path, revision }) {
|
|
354
|
+
function ArtifactMedia({ sessionId, path, revision, scope }) {
|
|
209
355
|
const [loaded, setLoaded] = useState();
|
|
210
|
-
const source = `${sessionId}:${path}:${revision}`;
|
|
356
|
+
const source = `${scope}:${sessionId}:${path}:${revision}`;
|
|
211
357
|
useEffect(() => {
|
|
212
358
|
const controller = new AbortController();
|
|
213
359
|
let url;
|
|
214
|
-
artifactBlob(sessionId, path, controller.signal).then((blob) => {
|
|
360
|
+
artifactBlob(sessionId, path, controller.signal, scope).then((blob) => {
|
|
215
361
|
if (controller.signal.aborted) return;
|
|
216
362
|
url = URL.createObjectURL(blob);
|
|
217
363
|
setLoaded({
|
|
@@ -232,7 +378,8 @@ function ArtifactMedia({ sessionId, path, revision }) {
|
|
|
232
378
|
}, [
|
|
233
379
|
sessionId,
|
|
234
380
|
path,
|
|
235
|
-
source
|
|
381
|
+
source,
|
|
382
|
+
scope
|
|
236
383
|
]);
|
|
237
384
|
const current = loaded?.source === source ? loaded : void 0;
|
|
238
385
|
return current?.url ? /* @__PURE__ */ jsx(MediaPreview, {
|
|
@@ -241,19 +388,19 @@ function ArtifactMedia({ sessionId, path, revision }) {
|
|
|
241
388
|
contentType: current.mimeType
|
|
242
389
|
}) : /* @__PURE__ */ jsx("p", {
|
|
243
390
|
role: current?.error ? "alert" : "status",
|
|
244
|
-
className: current?.error ? "text-sm text-
|
|
391
|
+
className: current?.error ? "text-sm text-po-red" : "text-sm text-po-dim",
|
|
245
392
|
children: current?.error ?? "Loading artifact media..."
|
|
246
393
|
});
|
|
247
394
|
}
|
|
248
|
-
function ArtifactPreviewPanel({ path, sessionId }) {
|
|
395
|
+
function ArtifactPreviewPanel({ path, sessionId, scope = "artifacts" }) {
|
|
249
396
|
const snapshot = useStore(artifacts.store, (state) => artifacts.select(state, sessionId));
|
|
250
397
|
const item = snapshot.items.find((candidate) => candidate.path === path);
|
|
251
|
-
const revision = item ? `${item.modifiedAt}:${item.size}` : snapshot.loaded ? "missing" : "initial";
|
|
398
|
+
const revision = scope === "temporary" ? "temporary" : item ? `${item.modifiedAt}:${item.size}` : snapshot.loaded ? "missing" : "initial";
|
|
252
399
|
const [loaded, setLoaded] = useState();
|
|
253
400
|
useEffect(() => {
|
|
254
401
|
if (sessionId === null || revision === "missing") return;
|
|
255
402
|
const controller = new AbortController();
|
|
256
|
-
fetchArtifactPreview(sessionId, path, controller.signal).then((preview) => {
|
|
403
|
+
fetchArtifactPreview(sessionId, path, controller.signal, scope).then((preview) => {
|
|
257
404
|
if (!controller.signal.aborted) setLoaded({
|
|
258
405
|
sessionId,
|
|
259
406
|
path,
|
|
@@ -272,13 +419,18 @@ function ArtifactPreviewPanel({ path, sessionId }) {
|
|
|
272
419
|
}, [
|
|
273
420
|
sessionId,
|
|
274
421
|
path,
|
|
275
|
-
revision
|
|
422
|
+
revision,
|
|
423
|
+
scope
|
|
276
424
|
]);
|
|
277
425
|
const current = loaded?.sessionId === sessionId && loaded.path === path && loaded.revision === revision ? loaded : void 0;
|
|
278
426
|
const loadImage = useCallback((imagePath) => {
|
|
279
427
|
if (sessionId === null) return Promise.reject(/* @__PURE__ */ new Error("The session is unavailable."));
|
|
280
|
-
return loadArtifactImage(sessionId, path, imagePath);
|
|
281
|
-
}, [
|
|
428
|
+
return loadArtifactImage(sessionId, path, imagePath, scope);
|
|
429
|
+
}, [
|
|
430
|
+
sessionId,
|
|
431
|
+
path,
|
|
432
|
+
scope
|
|
433
|
+
]);
|
|
282
434
|
return /* @__PURE__ */ jsx(ArtifactPreviewView, {
|
|
283
435
|
path,
|
|
284
436
|
preview: current?.preview,
|
|
@@ -287,138 +439,500 @@ function ArtifactPreviewPanel({ path, sessionId }) {
|
|
|
287
439
|
media: sessionId === null ? void 0 : /* @__PURE__ */ jsx(ArtifactMedia, {
|
|
288
440
|
sessionId,
|
|
289
441
|
path,
|
|
290
|
-
revision
|
|
442
|
+
revision,
|
|
443
|
+
scope
|
|
291
444
|
})
|
|
292
445
|
});
|
|
293
446
|
}
|
|
294
|
-
function artifactTab(sessionId, path) {
|
|
447
|
+
function artifactTab(sessionId, path, scope = "artifacts") {
|
|
295
448
|
return {
|
|
296
|
-
id: artifactTabId(sessionId, path)
|
|
449
|
+
id: `${scope === "temporary" ? "temporary:" : ""}${artifactTabId(sessionId, path)}`,
|
|
297
450
|
label: path.split("/").at(-1) ?? path,
|
|
298
451
|
panel: (props) => /* @__PURE__ */ jsx(ArtifactPreviewPanel, {
|
|
299
452
|
...props,
|
|
300
453
|
sessionId,
|
|
301
|
-
path
|
|
454
|
+
path,
|
|
455
|
+
scope
|
|
302
456
|
})
|
|
303
457
|
};
|
|
304
458
|
}
|
|
305
459
|
//#endregion
|
|
306
460
|
//#region src/extensions/workspaces/sessions/(frontend)/_components/ArtifactsView.tsx
|
|
307
|
-
function
|
|
308
|
-
return
|
|
461
|
+
function ArtifactFileButton({ item, onOpen }) {
|
|
462
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
463
|
+
variant: "ghost",
|
|
464
|
+
size: "card",
|
|
465
|
+
"data-artifact-path": item.path,
|
|
466
|
+
onClick: () => onOpen(item),
|
|
467
|
+
className: "gap-0.5 px-2 py-1.5",
|
|
468
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
469
|
+
className: "flex min-w-0 items-center gap-2 text-base text-po-text",
|
|
470
|
+
children: [/* @__PURE__ */ jsx(FileIcon, {
|
|
471
|
+
"aria-hidden": true,
|
|
472
|
+
className: "size-3.5 text-po-dim"
|
|
473
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
474
|
+
className: "truncate",
|
|
475
|
+
children: item.name
|
|
476
|
+
})]
|
|
477
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
478
|
+
className: "truncate font-mono text-sm text-po-dim",
|
|
479
|
+
title: item.path,
|
|
480
|
+
children: item.path
|
|
481
|
+
})]
|
|
482
|
+
});
|
|
309
483
|
}
|
|
310
484
|
function RecentArtifactsView({ items, loading, error, onOpen }) {
|
|
485
|
+
const recent = recentArtifacts(items);
|
|
311
486
|
return /* @__PURE__ */ jsxs("div", {
|
|
312
487
|
"data-testid": "artifacts-recent-items",
|
|
313
488
|
className: "flex flex-col gap-1",
|
|
314
489
|
children: [
|
|
315
490
|
error ? /* @__PURE__ */ jsx("p", {
|
|
316
491
|
role: "alert",
|
|
317
|
-
className: "text-sm text-
|
|
492
|
+
className: "text-sm text-po-red",
|
|
318
493
|
children: error
|
|
319
494
|
}) : null,
|
|
320
|
-
loading ? /* @__PURE__ */ jsx("
|
|
321
|
-
|
|
322
|
-
className: "text-sm text-doom-dim",
|
|
495
|
+
loading ? /* @__PURE__ */ jsx("output", {
|
|
496
|
+
className: "text-sm text-po-dim",
|
|
323
497
|
children: "Loading artifacts..."
|
|
324
498
|
}) : null,
|
|
325
|
-
!loading && !error &&
|
|
326
|
-
className: "text-sm text-
|
|
499
|
+
!loading && !error && recent.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
500
|
+
className: "text-sm text-po-dim",
|
|
327
501
|
children: "No artifacts yet"
|
|
328
502
|
}) : null,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
"data-artifact-path": item.path,
|
|
333
|
-
onClick: () => onOpen(item),
|
|
334
|
-
className: "gap-0.5 px-2 py-1.5",
|
|
335
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
336
|
-
className: "flex min-w-0 items-center gap-2 text-base text-doom-text",
|
|
337
|
-
children: [/* @__PURE__ */ jsx(FileIcon, {
|
|
338
|
-
"aria-hidden": true,
|
|
339
|
-
className: "size-3.5 text-doom-dim"
|
|
340
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
341
|
-
className: "truncate",
|
|
342
|
-
children: item.name
|
|
343
|
-
})]
|
|
344
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
345
|
-
className: "truncate font-mono text-sm text-doom-dim",
|
|
346
|
-
title: item.path,
|
|
347
|
-
children: item.path
|
|
348
|
-
})]
|
|
503
|
+
recent.map((item) => /* @__PURE__ */ jsx(ArtifactFileButton, {
|
|
504
|
+
item,
|
|
505
|
+
onOpen
|
|
349
506
|
}, item.path))
|
|
350
507
|
]
|
|
351
508
|
});
|
|
352
509
|
}
|
|
353
|
-
function
|
|
354
|
-
return /* @__PURE__ */ jsxs(
|
|
355
|
-
|
|
510
|
+
function ArtifactFilter({ label, value, options, active, onChange }) {
|
|
511
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
512
|
+
asChild: true,
|
|
513
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
514
|
+
variant: "ghost",
|
|
515
|
+
size: "sm",
|
|
516
|
+
className: active ? "bg-po-tint-magenta text-po-magenta" : "text-po-dim",
|
|
517
|
+
children: [label, /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
518
|
+
"aria-hidden": true,
|
|
519
|
+
className: "size-3"
|
|
520
|
+
})]
|
|
521
|
+
})
|
|
522
|
+
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
523
|
+
align: "start",
|
|
524
|
+
children: /* @__PURE__ */ jsx(DropdownMenuRadioGroup, {
|
|
525
|
+
value,
|
|
526
|
+
onValueChange: onChange,
|
|
527
|
+
children: options.map((option) => /* @__PURE__ */ jsx(DropdownMenuRadioItem, {
|
|
528
|
+
value: option,
|
|
529
|
+
children: option
|
|
530
|
+
}, option))
|
|
531
|
+
})
|
|
532
|
+
})] });
|
|
533
|
+
}
|
|
534
|
+
/** Controlled presentation. Production data and loading stay in the panel. */
|
|
535
|
+
function ArtifactLibraryView(props) {
|
|
536
|
+
const { items, loading, error, layout, onLayoutChange, query, onQueryChange, type, onTypeChange, modified, onModifiedChange, sort, direction, onSortChange, expanded, onToggleFolder, selectedPath, onSelect, onOpen, onClose, now, preview, renderThumbnail } = props;
|
|
537
|
+
const filtered = sortArtifacts(filterArtifacts(items, {
|
|
538
|
+
query,
|
|
539
|
+
type,
|
|
540
|
+
modified
|
|
541
|
+
}, now), sort, direction);
|
|
542
|
+
const hasFilters = query !== "" || type !== "any" || modified !== "any";
|
|
543
|
+
const selected = items.find((item) => item.path === selectedPath);
|
|
544
|
+
const rows = layout === "tree" ? artifactTree(filtered, (path) => hasFilters || expanded.has(path)) : filtered.map((item) => ({
|
|
545
|
+
kind: "file",
|
|
546
|
+
item,
|
|
547
|
+
depth: 0
|
|
548
|
+
}));
|
|
549
|
+
const clear = () => {
|
|
550
|
+
onQueryChange("");
|
|
551
|
+
onTypeChange("any");
|
|
552
|
+
onModifiedChange("any");
|
|
553
|
+
};
|
|
554
|
+
const moveFocus = (event) => {
|
|
555
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
556
|
+
const buttons = [...event.currentTarget.closest("[data-testid=\"artifacts-grid\"]")?.querySelectorAll("[data-artifact-row]") ?? []];
|
|
557
|
+
const index = buttons.indexOf(event.currentTarget);
|
|
558
|
+
if (index < 0) return;
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
buttons[Math.max(0, Math.min(buttons.length - 1, index + (event.key === "ArrowDown" ? 1 : -1)))]?.focus();
|
|
561
|
+
};
|
|
562
|
+
const modifiedLabels = {
|
|
563
|
+
any: "Any time",
|
|
564
|
+
today: "Today",
|
|
565
|
+
"7days": "Past 7 days",
|
|
566
|
+
"30days": "Past 30 days"
|
|
567
|
+
};
|
|
568
|
+
const sortLabels = {
|
|
569
|
+
"name:asc": "Name A to Z",
|
|
570
|
+
"name:desc": "Name Z to A",
|
|
571
|
+
"modified:desc": "Newest first",
|
|
572
|
+
"modified:asc": "Oldest first",
|
|
573
|
+
"size:desc": "Largest first",
|
|
574
|
+
"size:asc": "Smallest first"
|
|
575
|
+
};
|
|
576
|
+
const sortValue = `${sort}:${direction}`;
|
|
577
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
578
|
+
"data-testid": "artifacts-grid",
|
|
579
|
+
"aria-label": "Artifacts",
|
|
580
|
+
className: "@container flex min-h-0 flex-1 flex-col bg-po-bg text-po-text",
|
|
356
581
|
children: [
|
|
357
582
|
/* @__PURE__ */ jsxs("header", {
|
|
358
|
-
className: "flex shrink-0 items-center gap-3 border-b border-
|
|
359
|
-
children: [
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
583
|
+
className: "flex shrink-0 flex-wrap items-center gap-3 border-b border-po-border px-4 py-3",
|
|
584
|
+
children: [
|
|
585
|
+
/* @__PURE__ */ jsx("h1", {
|
|
586
|
+
className: "mr-auto text-lg font-semibold text-po-hi",
|
|
587
|
+
children: "Artifacts"
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ jsx("fieldset", {
|
|
590
|
+
"aria-label": "Artifact layout",
|
|
591
|
+
className: "flex shrink-0 gap-1 rounded-md border border-po-border p-0.5",
|
|
592
|
+
children: [
|
|
593
|
+
["tree", FolderIcon],
|
|
594
|
+
["list", ListIcon],
|
|
595
|
+
["grid", GridIcon]
|
|
596
|
+
].map(([value, Icon]) => /* @__PURE__ */ jsx("button", {
|
|
597
|
+
type: "button",
|
|
598
|
+
"aria-label": `${value[0].toUpperCase()}${value.slice(1)} layout`,
|
|
599
|
+
"aria-pressed": layout === value,
|
|
600
|
+
onClick: () => onLayoutChange(value),
|
|
601
|
+
className: `${tabVariants({ active: layout === value })} focus-visible:ring-2 focus-visible:ring-po-green`,
|
|
602
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
603
|
+
"aria-hidden": true,
|
|
604
|
+
className: "size-4"
|
|
605
|
+
})
|
|
606
|
+
}, value))
|
|
607
|
+
}),
|
|
608
|
+
/* @__PURE__ */ jsxs("div", {
|
|
609
|
+
className: "relative w-full @lg:w-56",
|
|
610
|
+
children: [/* @__PURE__ */ jsx(SearchIcon, {
|
|
611
|
+
"aria-hidden": true,
|
|
612
|
+
className: "absolute top-2 left-2 size-4 text-po-dim"
|
|
613
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
614
|
+
"aria-label": "Search artifacts",
|
|
615
|
+
placeholder: "Search artifacts",
|
|
616
|
+
value: query,
|
|
617
|
+
onChange: (event) => onQueryChange(event.target.value),
|
|
618
|
+
className: "w-full pl-8"
|
|
619
|
+
})]
|
|
620
|
+
})
|
|
621
|
+
]
|
|
371
622
|
}),
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
623
|
+
/* @__PURE__ */ jsxs("div", {
|
|
624
|
+
className: "flex shrink-0 flex-wrap items-center gap-1 border-b border-po-border px-3 py-1.5",
|
|
625
|
+
children: [
|
|
626
|
+
/* @__PURE__ */ jsx(SlidersIcon, {
|
|
627
|
+
"aria-hidden": true,
|
|
628
|
+
className: "mr-1 size-3.5 text-po-dim"
|
|
629
|
+
}),
|
|
630
|
+
/* @__PURE__ */ jsx(ArtifactFilter, {
|
|
631
|
+
label: type === "any" ? "Type" : type,
|
|
632
|
+
value: type === "any" ? "All types" : type,
|
|
633
|
+
options: [
|
|
634
|
+
"All types",
|
|
635
|
+
"Markdown",
|
|
636
|
+
"Image",
|
|
637
|
+
"Code",
|
|
638
|
+
"Data",
|
|
639
|
+
"Document",
|
|
640
|
+
"Other"
|
|
641
|
+
],
|
|
642
|
+
active: type !== "any",
|
|
643
|
+
onChange: (value) => onTypeChange(value === "All types" ? "any" : value)
|
|
644
|
+
}),
|
|
645
|
+
/* @__PURE__ */ jsx(ArtifactFilter, {
|
|
646
|
+
label: modified === "any" ? "Modified" : modifiedLabels[modified],
|
|
647
|
+
value: modifiedLabels[modified],
|
|
648
|
+
options: Object.values(modifiedLabels),
|
|
649
|
+
active: modified !== "any",
|
|
650
|
+
onChange: (value) => onModifiedChange(Object.keys(modifiedLabels).find((key) => modifiedLabels[key] === value) ?? "any")
|
|
651
|
+
}),
|
|
652
|
+
/* @__PURE__ */ jsx(ArtifactFilter, {
|
|
653
|
+
label: sortLabels[sortValue],
|
|
654
|
+
value: sortLabels[sortValue],
|
|
655
|
+
options: Object.values(sortLabels),
|
|
656
|
+
onChange: (value) => {
|
|
657
|
+
const [nextSort, nextDirection] = Object.keys(sortLabels).find((key) => sortLabels[key] === value).split(":");
|
|
658
|
+
onSortChange(nextSort, nextDirection);
|
|
659
|
+
}
|
|
660
|
+
}),
|
|
661
|
+
hasFilters ? /* @__PURE__ */ jsx(Button, {
|
|
662
|
+
variant: "ghost",
|
|
663
|
+
size: "sm",
|
|
664
|
+
onClick: clear,
|
|
665
|
+
className: "ml-auto text-po-magenta",
|
|
666
|
+
children: "Clear filters"
|
|
667
|
+
}) : null
|
|
668
|
+
]
|
|
669
|
+
}),
|
|
670
|
+
/* @__PURE__ */ jsxs("div", {
|
|
671
|
+
className: "flex min-h-0 flex-1 flex-col @3xl:flex-row",
|
|
672
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
673
|
+
className: "min-h-0 min-w-0 flex-1 overflow-auto",
|
|
396
674
|
children: [
|
|
397
|
-
/* @__PURE__ */ jsx(
|
|
675
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
676
|
+
role: "alert",
|
|
677
|
+
className: "px-4 py-3 text-sm text-po-red",
|
|
678
|
+
children: error
|
|
679
|
+
}) : null,
|
|
680
|
+
loading ? /* @__PURE__ */ jsx("output", {
|
|
681
|
+
className: "px-4 py-3 text-sm text-po-dim",
|
|
682
|
+
children: "Loading artifacts..."
|
|
683
|
+
}) : null,
|
|
684
|
+
!loading && !error && items.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
685
|
+
title: "No artifacts yet",
|
|
686
|
+
description: "Documents Po prepares for this session will appear here.",
|
|
687
|
+
className: "px-4 py-8"
|
|
688
|
+
}) : null,
|
|
689
|
+
!loading && !error && items.length > 0 && filtered.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
690
|
+
title: "No artifacts match these filters",
|
|
691
|
+
className: "px-4 py-8",
|
|
692
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
693
|
+
variant: "ghost",
|
|
694
|
+
onClick: clear,
|
|
695
|
+
children: "Clear filters"
|
|
696
|
+
})
|
|
697
|
+
}) : null,
|
|
698
|
+
layout !== "grid" && filtered.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
398
699
|
"aria-hidden": true,
|
|
399
|
-
className: "
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
700
|
+
className: "flex items-center gap-3 border-b border-po-border px-4 py-2 text-sm text-po-dim",
|
|
701
|
+
children: [
|
|
702
|
+
/* @__PURE__ */ jsx("span", {
|
|
703
|
+
className: "min-w-0 flex-1",
|
|
704
|
+
children: "Name"
|
|
705
|
+
}),
|
|
706
|
+
/* @__PURE__ */ jsx("span", {
|
|
707
|
+
className: "hidden w-20 @2xl:block",
|
|
708
|
+
children: "Kind"
|
|
709
|
+
}),
|
|
710
|
+
/* @__PURE__ */ jsx("span", {
|
|
711
|
+
className: "hidden w-16 text-right @2xl:block",
|
|
712
|
+
children: "Size"
|
|
713
|
+
}),
|
|
714
|
+
/* @__PURE__ */ jsx("span", {
|
|
715
|
+
className: "w-24 text-right",
|
|
716
|
+
children: "Modified"
|
|
717
|
+
})
|
|
718
|
+
]
|
|
719
|
+
}) : null,
|
|
720
|
+
/* @__PURE__ */ jsx("div", {
|
|
721
|
+
className: layout === "grid" ? "grid grid-cols-2 gap-3 p-4 @xl:grid-cols-3 @3xl:grid-cols-4" : "flex flex-col py-1",
|
|
722
|
+
children: rows.map((row) => row.kind === "dir" ? /* @__PURE__ */ jsxs("button", {
|
|
723
|
+
type: "button",
|
|
724
|
+
"data-artifact-row": true,
|
|
725
|
+
"aria-expanded": row.open,
|
|
726
|
+
onClick: () => onToggleFolder(row.path),
|
|
727
|
+
onKeyDown: moveFocus,
|
|
728
|
+
className: "flex min-h-10 items-center gap-2 border-l-2 border-transparent px-4 py-2 text-left hover:bg-po-panel focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-po-green",
|
|
729
|
+
children: [
|
|
730
|
+
Array.from({ length: row.depth }, (_, index) => /* @__PURE__ */ jsx("span", { className: "w-3 shrink-0" }, index)),
|
|
731
|
+
row.open ? /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
732
|
+
"aria-hidden": true,
|
|
733
|
+
className: "size-3.5 shrink-0 text-po-dim"
|
|
734
|
+
}) : /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
735
|
+
"aria-hidden": true,
|
|
736
|
+
className: "size-3.5 shrink-0 text-po-dim"
|
|
737
|
+
}),
|
|
738
|
+
/* @__PURE__ */ jsx(FolderIcon, {
|
|
739
|
+
"aria-hidden": true,
|
|
740
|
+
className: "size-4 shrink-0 text-po-dim"
|
|
741
|
+
}),
|
|
742
|
+
/* @__PURE__ */ jsx("span", {
|
|
743
|
+
className: "truncate text-base font-medium",
|
|
744
|
+
children: row.name
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ jsxs("span", {
|
|
747
|
+
className: "ml-auto text-sm text-po-dim",
|
|
748
|
+
children: [
|
|
749
|
+
row.count,
|
|
750
|
+
" ",
|
|
751
|
+
row.count === 1 ? "file" : "files"
|
|
752
|
+
]
|
|
753
|
+
})
|
|
754
|
+
]
|
|
755
|
+
}, row.path) : /* @__PURE__ */ jsxs("button", {
|
|
756
|
+
type: "button",
|
|
757
|
+
"data-artifact-row": true,
|
|
758
|
+
"data-artifact-path": row.item.path,
|
|
759
|
+
"aria-current": selectedPath === row.item.path ? "true" : void 0,
|
|
760
|
+
title: row.item.path,
|
|
761
|
+
onClick: () => onSelect(row.item),
|
|
762
|
+
onDoubleClick: () => onOpen(row.item),
|
|
763
|
+
onKeyDown: (event) => {
|
|
764
|
+
moveFocus(event);
|
|
765
|
+
if (event.key === "Enter") {
|
|
766
|
+
event.preventDefault();
|
|
767
|
+
onOpen(row.item);
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
className: `${layout === "grid" ? "flex min-w-0 flex-col gap-2 rounded-md border p-3 text-left" : "flex min-h-12 items-center gap-3 border-l-2 px-4 py-2 text-left"} ${selectedPath === row.item.path ? "border-po-blue bg-po-panel" : layout === "grid" ? "border-po-border hover:bg-po-panel/60" : "border-transparent hover:bg-po-panel/60"} focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-po-green`,
|
|
771
|
+
children: [
|
|
772
|
+
layout !== "grid" ? Array.from({ length: row.depth }, (_, index) => /* @__PURE__ */ jsx("span", { className: "w-3 shrink-0" }, index)) : null,
|
|
773
|
+
layout === "tree" ? /* @__PURE__ */ jsx("span", { className: "w-3.5 shrink-0" }) : null,
|
|
774
|
+
layout === "grid" ? /* @__PURE__ */ jsx("div", {
|
|
775
|
+
className: "flex h-24 w-full items-center justify-center overflow-hidden rounded-sm bg-po-deep text-po-dim",
|
|
776
|
+
children: renderThumbnail?.(row.item) ?? (artifactKind(row.item.path) === "Image" ? /* @__PURE__ */ jsx(ImageIcon, {
|
|
777
|
+
"aria-hidden": true,
|
|
778
|
+
className: "size-8"
|
|
779
|
+
}) : /* @__PURE__ */ jsx(FileIcon, {
|
|
780
|
+
"aria-hidden": true,
|
|
781
|
+
className: "size-8"
|
|
782
|
+
}))
|
|
783
|
+
}) : /* @__PURE__ */ jsx(FileIcon, {
|
|
784
|
+
"aria-hidden": true,
|
|
785
|
+
className: "size-4 shrink-0 text-po-dim"
|
|
786
|
+
}),
|
|
787
|
+
/* @__PURE__ */ jsxs("span", {
|
|
788
|
+
className: "min-w-0 flex-1",
|
|
789
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
790
|
+
className: "block truncate text-base font-medium text-po-hi",
|
|
791
|
+
children: row.item.name
|
|
792
|
+
}), layout !== "tree" ? /* @__PURE__ */ jsx("span", {
|
|
793
|
+
className: "block truncate font-mono text-sm text-po-dim",
|
|
794
|
+
children: row.item.path.includes("/") ? row.item.path.slice(0, row.item.path.lastIndexOf("/")) : "All files"
|
|
795
|
+
}) : null]
|
|
796
|
+
}),
|
|
797
|
+
layout === "grid" ? /* @__PURE__ */ jsx("span", {
|
|
798
|
+
className: "text-sm text-po-dim",
|
|
799
|
+
children: sizeLabel(row.item.size)
|
|
800
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
801
|
+
/* @__PURE__ */ jsx("span", {
|
|
802
|
+
className: "hidden w-20 shrink-0 text-sm text-po-dim @2xl:block",
|
|
803
|
+
children: artifactKind(row.item.path)
|
|
804
|
+
}),
|
|
805
|
+
/* @__PURE__ */ jsx("span", {
|
|
806
|
+
className: "hidden w-16 shrink-0 text-right text-sm text-po-dim @2xl:block",
|
|
807
|
+
children: sizeLabel(row.item.size)
|
|
808
|
+
}),
|
|
809
|
+
/* @__PURE__ */ jsx("time", {
|
|
810
|
+
dateTime: new Date(row.item.modifiedAt).toISOString(),
|
|
811
|
+
className: "w-24 shrink-0 text-right text-sm text-po-dim",
|
|
812
|
+
children: new Date(row.item.modifiedAt).toLocaleDateString("en-US", {
|
|
813
|
+
month: "short",
|
|
814
|
+
day: "numeric"
|
|
815
|
+
})
|
|
816
|
+
})
|
|
817
|
+
] })
|
|
818
|
+
]
|
|
819
|
+
}, row.item.path))
|
|
414
820
|
})
|
|
415
821
|
]
|
|
416
|
-
},
|
|
822
|
+
}), /* @__PURE__ */ jsx("aside", {
|
|
823
|
+
"aria-label": "Selected artifact",
|
|
824
|
+
className: `flex min-h-0 shrink-0 flex-col border-t border-po-border @3xl:w-72 @3xl:border-t-0 @3xl:border-l ${selected ? "h-56 @3xl:h-auto" : "hidden @3xl:flex"}`,
|
|
825
|
+
children: selected ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
826
|
+
className: "flex shrink-0 items-center gap-2 border-b border-po-border px-4 py-2",
|
|
827
|
+
children: [
|
|
828
|
+
/* @__PURE__ */ jsxs("div", {
|
|
829
|
+
className: "min-w-0 flex-1",
|
|
830
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
831
|
+
className: "truncate text-base font-semibold text-po-hi",
|
|
832
|
+
children: selected.name
|
|
833
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
834
|
+
className: "text-sm text-po-dim",
|
|
835
|
+
children: [
|
|
836
|
+
artifactKind(selected.path),
|
|
837
|
+
" · ",
|
|
838
|
+
sizeLabel(selected.size)
|
|
839
|
+
]
|
|
840
|
+
})]
|
|
841
|
+
}),
|
|
842
|
+
/* @__PURE__ */ jsx(Button, {
|
|
843
|
+
variant: "ghost",
|
|
844
|
+
size: "icon",
|
|
845
|
+
"aria-label": "Close preview",
|
|
846
|
+
onClick: onClose,
|
|
847
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {
|
|
848
|
+
"aria-hidden": true,
|
|
849
|
+
className: "size-4"
|
|
850
|
+
})
|
|
851
|
+
}),
|
|
852
|
+
/* @__PURE__ */ jsx(Button, {
|
|
853
|
+
variant: "primary",
|
|
854
|
+
size: "sm",
|
|
855
|
+
onClick: () => onOpen(selected),
|
|
856
|
+
children: "Open"
|
|
857
|
+
})
|
|
858
|
+
]
|
|
859
|
+
}), preview] }) : /* @__PURE__ */ jsx("div", {
|
|
860
|
+
className: "flex flex-1 items-center justify-center p-6 text-center text-sm text-po-dim",
|
|
861
|
+
children: "Select a file to preview it"
|
|
862
|
+
})
|
|
863
|
+
})]
|
|
864
|
+
}),
|
|
865
|
+
/* @__PURE__ */ jsxs("footer", {
|
|
866
|
+
"data-testid": "artifacts-count",
|
|
867
|
+
className: "shrink-0 border-t border-po-border px-4 py-2 text-sm text-po-dim",
|
|
868
|
+
"aria-live": "polite",
|
|
869
|
+
children: [
|
|
870
|
+
hasFilters ? `${filtered.length} of ${items.length}` : items.length,
|
|
871
|
+
" ",
|
|
872
|
+
items.length === 1 ? "file" : "files",
|
|
873
|
+
selected ? " · 1 selected" : ""
|
|
874
|
+
]
|
|
417
875
|
})
|
|
418
876
|
]
|
|
419
877
|
});
|
|
420
878
|
}
|
|
421
879
|
//#endregion
|
|
880
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_components/SessionFilesView.tsx
|
|
881
|
+
/** The approved file-scope selector and temporary-file list, independent of transport. */
|
|
882
|
+
function SessionFilesView({ scope, onScopeChange, items, loading, error, onOpen, artifacts }) {
|
|
883
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
884
|
+
className: scope === "artifacts" ? "flex min-h-0 flex-1 flex-col overflow-hidden bg-po-bg text-po-text" : "flex min-h-screen flex-col gap-4 bg-po-bg p-6 text-po-text",
|
|
885
|
+
children: [/* @__PURE__ */ jsxs("nav", {
|
|
886
|
+
"aria-label": "Session files",
|
|
887
|
+
className: scope === "artifacts" ? "flex shrink-0 gap-2 border-b border-po-border px-4 py-3" : "flex gap-2",
|
|
888
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
889
|
+
variant: scope === "artifacts" ? "outline" : "ghost",
|
|
890
|
+
"aria-pressed": scope === "artifacts",
|
|
891
|
+
onClick: () => onScopeChange("artifacts"),
|
|
892
|
+
children: "Artifacts"
|
|
893
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
894
|
+
variant: scope === "temporary" ? "outline" : "ghost",
|
|
895
|
+
"aria-pressed": scope === "temporary",
|
|
896
|
+
onClick: () => onScopeChange("temporary"),
|
|
897
|
+
children: "Temporary files"
|
|
898
|
+
})]
|
|
899
|
+
}), scope === "artifacts" ? artifacts : /* @__PURE__ */ jsxs("section", {
|
|
900
|
+
className: "flex flex-col gap-3 rounded-md border border-po-border bg-po-panel p-4",
|
|
901
|
+
children: [
|
|
902
|
+
/* @__PURE__ */ jsx("h1", {
|
|
903
|
+
className: "text-lg font-semibold text-po-hi",
|
|
904
|
+
children: "Temporary files"
|
|
905
|
+
}),
|
|
906
|
+
/* @__PURE__ */ jsx("p", {
|
|
907
|
+
className: "text-sm text-po-dim",
|
|
908
|
+
children: "Working files for this session. Save anything you want to keep in artifacts."
|
|
909
|
+
}),
|
|
910
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
911
|
+
role: "alert",
|
|
912
|
+
className: "text-sm text-po-red",
|
|
913
|
+
children: error
|
|
914
|
+
}) : null,
|
|
915
|
+
loading ? /* @__PURE__ */ jsx("output", {
|
|
916
|
+
className: "text-sm text-po-dim",
|
|
917
|
+
children: "Loading temporary files..."
|
|
918
|
+
}) : null,
|
|
919
|
+
!loading && !error && items.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
|
|
920
|
+
title: "No temporary files",
|
|
921
|
+
description: "Po has not created working files here, or the system has cleared them."
|
|
922
|
+
}) : null,
|
|
923
|
+
items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
924
|
+
"data-testid": "temporary-files-items",
|
|
925
|
+
className: "flex flex-col gap-1",
|
|
926
|
+
children: items.map((item) => /* @__PURE__ */ jsx(ArtifactFileButton, {
|
|
927
|
+
item,
|
|
928
|
+
onOpen
|
|
929
|
+
}, item.path))
|
|
930
|
+
}) : null
|
|
931
|
+
]
|
|
932
|
+
})]
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
//#endregion
|
|
422
936
|
//#region src/extensions/workspaces/sessions/(frontend)/_components/ArtifactsPanel.tsx
|
|
423
937
|
function artifactsTab() {
|
|
424
938
|
return {
|
|
@@ -427,7 +941,21 @@ function artifactsTab() {
|
|
|
427
941
|
panel: ArtifactsPanel
|
|
428
942
|
};
|
|
429
943
|
}
|
|
430
|
-
|
|
944
|
+
/** With Author installed, an artifact opens straight in Author's own (read-only) canvas tab. */
|
|
945
|
+
function openArtifact(props, path, scope = "artifacts") {
|
|
946
|
+
if (props.sessionId === null) return;
|
|
947
|
+
if (scope === "temporary") {
|
|
948
|
+
props.openTransientTab(artifactTab(props.sessionId, path, scope));
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const author = authorSourceAction(props);
|
|
952
|
+
props.openTransientTab(author?.createTab({
|
|
953
|
+
sessionId: props.sessionId,
|
|
954
|
+
path: `artifact:${path}`
|
|
955
|
+
}) ?? artifactTab(props.sessionId, path));
|
|
956
|
+
}
|
|
957
|
+
function ArtifactsActivitySection(props) {
|
|
958
|
+
const { sessionId } = props;
|
|
431
959
|
const snapshot = useStore(artifacts.store, (state) => artifacts.select(state, sessionId));
|
|
432
960
|
useEffect(() => {
|
|
433
961
|
if (sessionId === null || snapshot.loaded) return;
|
|
@@ -439,34 +967,179 @@ function ArtifactsActivitySection({ sessionId, openTransientTab }) {
|
|
|
439
967
|
items: snapshot.items,
|
|
440
968
|
loading: !snapshot.loaded,
|
|
441
969
|
error: snapshot.error,
|
|
442
|
-
onOpen: (item) =>
|
|
443
|
-
if (sessionId !== null) openTransientTab(artifactTab(sessionId, item.path));
|
|
444
|
-
}
|
|
970
|
+
onOpen: (item) => openArtifact(props, item.path)
|
|
445
971
|
});
|
|
446
972
|
}
|
|
447
|
-
function ArtifactsPanel(
|
|
448
|
-
const
|
|
973
|
+
function ArtifactsPanel(props) {
|
|
974
|
+
const { sessionId } = props;
|
|
975
|
+
const [scope, setScope] = useState("artifacts");
|
|
976
|
+
const [temporary, setTemporary] = useState();
|
|
449
977
|
useEffect(() => {
|
|
450
978
|
if (sessionId === null) return;
|
|
451
979
|
const controller = new AbortController();
|
|
452
980
|
refreshArtifacts(sessionId, controller.signal);
|
|
453
981
|
return () => controller.abort();
|
|
454
982
|
}, [sessionId]);
|
|
455
|
-
|
|
983
|
+
useEffect(() => {
|
|
984
|
+
if (sessionId === null || scope !== "temporary") return;
|
|
985
|
+
const controller = new AbortController();
|
|
986
|
+
let timer;
|
|
987
|
+
const load = async () => {
|
|
988
|
+
try {
|
|
989
|
+
const result = await fetchArtifacts(sessionId, controller.signal, "temporary");
|
|
990
|
+
if (!controller.signal.aborted) setTemporary({
|
|
991
|
+
...result,
|
|
992
|
+
sessionId
|
|
993
|
+
});
|
|
994
|
+
} catch (error) {
|
|
995
|
+
if (!controller.signal.aborted) setTemporary((before) => ({
|
|
996
|
+
sessionId,
|
|
997
|
+
items: before?.sessionId === sessionId ? before.items : [],
|
|
998
|
+
error: error instanceof Error ? error.message : String(error)
|
|
999
|
+
}));
|
|
1000
|
+
} finally {
|
|
1001
|
+
if (!controller.signal.aborted) timer = setTimeout(() => void load(), ARTIFACT_REFRESH_MS);
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
load();
|
|
1005
|
+
return () => {
|
|
1006
|
+
controller.abort();
|
|
1007
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1008
|
+
};
|
|
1009
|
+
}, [sessionId, scope]);
|
|
1010
|
+
const current = temporary?.sessionId === sessionId ? temporary : void 0;
|
|
1011
|
+
return /* @__PURE__ */ jsx(SessionFilesView, {
|
|
1012
|
+
scope,
|
|
1013
|
+
onScopeChange: setScope,
|
|
1014
|
+
items: current?.items ?? [],
|
|
1015
|
+
loading: sessionId !== null && current === void 0,
|
|
1016
|
+
error: sessionId === null ? "The session is unavailable." : current?.error,
|
|
1017
|
+
onOpen: (item) => openArtifact(props, item.path, "temporary"),
|
|
1018
|
+
artifacts: /* @__PURE__ */ jsx(ArtifactBrowserPanel, { ...props }, sessionId)
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
function ArtifactBrowserPanel(props) {
|
|
1022
|
+
const { sessionId } = props;
|
|
1023
|
+
const snapshot = useStore(artifacts.store, (state) => artifacts.select(state, sessionId));
|
|
1024
|
+
const layout = useStore(artifactLayout.store);
|
|
1025
|
+
const [query, setQuery] = useState("");
|
|
1026
|
+
const [type, setType] = useState("any");
|
|
1027
|
+
const [modified, setModified] = useState("any");
|
|
1028
|
+
const [sort, setSort] = useState("name");
|
|
1029
|
+
const [direction, setDirection] = useState("asc");
|
|
1030
|
+
const [expanded, setExpanded] = useState(/* @__PURE__ */ new Set());
|
|
1031
|
+
const [selectedPath, setSelectedPath] = useState();
|
|
1032
|
+
const [now, setNow] = useState(Date.now);
|
|
1033
|
+
useEffect(() => {
|
|
1034
|
+
const refreshClock = () => setNow(Date.now());
|
|
1035
|
+
const subscription = artifacts.store.subscribe(refreshClock);
|
|
1036
|
+
const timer = setInterval(refreshClock, 6e4);
|
|
1037
|
+
return () => {
|
|
1038
|
+
subscription.unsubscribe();
|
|
1039
|
+
clearInterval(timer);
|
|
1040
|
+
};
|
|
1041
|
+
}, []);
|
|
1042
|
+
if (snapshot.loaded && selectedPath && !snapshot.items.some((item) => item.path === selectedPath)) setSelectedPath(void 0);
|
|
1043
|
+
return /* @__PURE__ */ jsx(ArtifactLibraryView, {
|
|
456
1044
|
items: snapshot.items,
|
|
457
1045
|
loading: !snapshot.loaded && sessionId !== null,
|
|
458
1046
|
error: sessionId === null ? "The session is unavailable." : snapshot.error,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
1047
|
+
layout,
|
|
1048
|
+
onLayoutChange: setArtifactLayout,
|
|
1049
|
+
query,
|
|
1050
|
+
onQueryChange: setQuery,
|
|
1051
|
+
type,
|
|
1052
|
+
onTypeChange: setType,
|
|
1053
|
+
modified,
|
|
1054
|
+
onModifiedChange: (value) => {
|
|
1055
|
+
setModified(value);
|
|
1056
|
+
setNow(Date.now());
|
|
1057
|
+
},
|
|
1058
|
+
sort,
|
|
1059
|
+
direction,
|
|
1060
|
+
onSortChange: (sort, direction) => {
|
|
1061
|
+
setSort(sort);
|
|
1062
|
+
setDirection(direction);
|
|
1063
|
+
},
|
|
1064
|
+
expanded,
|
|
1065
|
+
onToggleFolder: (path) => setExpanded((current) => {
|
|
1066
|
+
const next = new Set(current);
|
|
1067
|
+
if (next.has(path)) next.delete(path);
|
|
1068
|
+
else next.add(path);
|
|
1069
|
+
return next;
|
|
1070
|
+
}),
|
|
1071
|
+
selectedPath,
|
|
1072
|
+
onSelect: (item) => setSelectedPath(item.path),
|
|
1073
|
+
onClose: () => setSelectedPath(void 0),
|
|
1074
|
+
onOpen: (item) => openArtifact(props, item.path),
|
|
1075
|
+
now,
|
|
1076
|
+
preview: selectedPath ? /* @__PURE__ */ jsx(ArtifactPreviewPanel, {
|
|
1077
|
+
...props,
|
|
1078
|
+
path: selectedPath
|
|
1079
|
+
}) : void 0,
|
|
1080
|
+
renderThumbnail: (item) => sessionId !== null && artifactKind(item.path) === "Image" && item.size <= 5242880 ? /* @__PURE__ */ jsx(ArtifactThumbnail, {
|
|
1081
|
+
sessionId,
|
|
1082
|
+
item
|
|
1083
|
+
}, item.path) : void 0
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
/** No thumbnail request until its image cell intersects the scrolling inventory. */
|
|
1087
|
+
function ArtifactThumbnail({ sessionId, item }) {
|
|
1088
|
+
const cell = useRef(null);
|
|
1089
|
+
const [loaded, setLoaded] = useState();
|
|
1090
|
+
const revision = `${sessionId}:${item.path}:${item.modifiedAt}:${item.size}`;
|
|
1091
|
+
useEffect(() => {
|
|
1092
|
+
const element = cell.current;
|
|
1093
|
+
if (!element) return;
|
|
1094
|
+
const controller = new AbortController();
|
|
1095
|
+
let url;
|
|
1096
|
+
const load = () => {
|
|
1097
|
+
artifactBlob(sessionId, item.path, controller.signal).then((blob) => {
|
|
1098
|
+
if (controller.signal.aborted || blob.size > 5242880 || !blob.type.startsWith("image/")) return;
|
|
1099
|
+
url = URL.createObjectURL(blob);
|
|
1100
|
+
setLoaded({
|
|
1101
|
+
revision,
|
|
1102
|
+
url
|
|
1103
|
+
});
|
|
1104
|
+
}).catch(() => {});
|
|
1105
|
+
};
|
|
1106
|
+
const observer = typeof IntersectionObserver === "undefined" ? void 0 : new IntersectionObserver((entries) => {
|
|
1107
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
1108
|
+
observer?.disconnect();
|
|
1109
|
+
load();
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
if (observer) observer.observe(element);
|
|
1113
|
+
else load();
|
|
1114
|
+
return () => {
|
|
1115
|
+
observer?.disconnect();
|
|
1116
|
+
controller.abort();
|
|
1117
|
+
if (url) URL.revokeObjectURL(url);
|
|
1118
|
+
};
|
|
1119
|
+
}, [
|
|
1120
|
+
sessionId,
|
|
1121
|
+
item.path,
|
|
1122
|
+
revision
|
|
1123
|
+
]);
|
|
1124
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1125
|
+
ref: cell,
|
|
1126
|
+
className: "flex h-full w-full items-center justify-center",
|
|
1127
|
+
children: loaded?.revision === revision ? /* @__PURE__ */ jsx("img", {
|
|
1128
|
+
src: loaded.url,
|
|
1129
|
+
alt: "",
|
|
1130
|
+
className: "h-full w-full object-cover"
|
|
1131
|
+
}) : /* @__PURE__ */ jsx(ImageIcon, {
|
|
1132
|
+
"aria-hidden": true,
|
|
1133
|
+
className: "size-8"
|
|
1134
|
+
})
|
|
462
1135
|
});
|
|
463
1136
|
}
|
|
464
1137
|
//#endregion
|
|
465
1138
|
//#region src/extensions/workspaces/sessions/(frontend)/activity-group/artifacts.web.ts
|
|
466
|
-
var artifacts_web_default$
|
|
1139
|
+
var artifacts_web_default$2 = defineActivityGroup({
|
|
467
1140
|
icon: FileIcon,
|
|
468
1141
|
keys: "",
|
|
469
|
-
statusKey: "
|
|
1142
|
+
statusKey: "po-artifacts",
|
|
470
1143
|
activeSource: artifactActivitySource,
|
|
471
1144
|
transientTab: artifactsTab,
|
|
472
1145
|
marksBackgroundWork: false,
|
|
@@ -474,7 +1147,43 @@ var artifacts_web_default$1 = defineActivityGroup({
|
|
|
474
1147
|
});
|
|
475
1148
|
//#endregion
|
|
476
1149
|
//#region src/extensions/workspaces/sessions/(frontend)/channel/artifacts.web.ts
|
|
477
|
-
var artifacts_web_default = defineChannelFile(artifactsChannel);
|
|
1150
|
+
var artifacts_web_default$1 = defineChannelFile(artifactsChannel);
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/temporaryFiles.ts
|
|
1153
|
+
/** Matching links is presentation only. The server independently selects and guards the root. */
|
|
1154
|
+
function temporaryFileReference(reference, root) {
|
|
1155
|
+
const value = reference.trim();
|
|
1156
|
+
const prefix = "temporary:";
|
|
1157
|
+
let relative;
|
|
1158
|
+
if (value.startsWith(prefix)) relative = value.slice(10);
|
|
1159
|
+
else {
|
|
1160
|
+
if (!root || !root.startsWith("/")) return void 0;
|
|
1161
|
+
const base = root.replace(/\/+$/u, "");
|
|
1162
|
+
if (!value.startsWith(`${base}/`)) return void 0;
|
|
1163
|
+
relative = value.slice(base.length + 1);
|
|
1164
|
+
}
|
|
1165
|
+
if (!relative || relative.includes("\\") || relative.includes("\0") || relative.split("/").some((part) => !part || part === "." || part === "..")) return void 0;
|
|
1166
|
+
return relative;
|
|
1167
|
+
}
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region src/extensions/workspaces/sessions/(frontend)/file-links/artifacts.web.ts
|
|
1170
|
+
/** Artifact references belong to the session store, never the repository file API. */
|
|
1171
|
+
var artifacts_web_default = defineFileLinks({
|
|
1172
|
+
subscribe(listener) {
|
|
1173
|
+
const subscription = artifacts.store.subscribe(listener);
|
|
1174
|
+
return () => subscription.unsubscribe();
|
|
1175
|
+
},
|
|
1176
|
+
fingerprint: (sessionId) => artifacts.select(artifacts.store.state, sessionId).temporaryRoot ?? "",
|
|
1177
|
+
resolve(sessionId, path) {
|
|
1178
|
+
const reference = path.trim();
|
|
1179
|
+
if (sessionId === null) return void 0;
|
|
1180
|
+
const temporary = temporaryFileReference(reference, artifacts.select(artifacts.store.state, sessionId).temporaryRoot);
|
|
1181
|
+
if (temporary) return artifactTab(sessionId, temporary, "temporary");
|
|
1182
|
+
if (!reference.startsWith("artifact:")) return void 0;
|
|
1183
|
+
const relative = reference.slice(9);
|
|
1184
|
+
return relative === "" ? void 0 : artifactTab(sessionId, relative);
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
478
1187
|
//#endregion
|
|
479
1188
|
//#region src/extensions/workspaces/sessions/(frontend)/fill/Artifacts.activity.artifacts.web.tsx
|
|
480
1189
|
var Artifacts_activity_artifacts_web_default = defineFill({ component: ArtifactsActivitySection });
|
|
@@ -488,10 +1197,13 @@ const webPlugin = defineWebPlugin({
|
|
|
488
1197
|
id: "artifacts",
|
|
489
1198
|
session: {
|
|
490
1199
|
get activityGroups() {
|
|
491
|
-
return [via({ name: "artifacts" }, artifacts_web_default$
|
|
1200
|
+
return [via({ name: "artifacts" }, artifacts_web_default$2)];
|
|
492
1201
|
},
|
|
493
1202
|
get channels() {
|
|
494
|
-
return [via({ channel: "artifacts" }, artifacts_web_default)];
|
|
1203
|
+
return [via({ channel: "artifacts" }, artifacts_web_default$1)];
|
|
1204
|
+
},
|
|
1205
|
+
get fileLinks() {
|
|
1206
|
+
return artifacts_web_default;
|
|
495
1207
|
},
|
|
496
1208
|
get fills() {
|
|
497
1209
|
return [via({
|