@useavalon/caelence-agent 0.2.2-canary.3 → 0.2.2-canary.5
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/desktop/src/App.tsx +160 -45
- package/desktop/src/ComposerAttach.tsx +2 -26
- package/desktop/src/FilesPanel.tsx +68 -0
- package/desktop/src/McpPanel.tsx +268 -0
- package/desktop/src/api.ts +48 -1
- package/desktop/src/app.css +69 -0
- package/desktop/src/composer-files.test.ts +2 -0
- package/desktop/src/composer-files.ts +10 -0
- package/desktop/src/user-display.test.ts +42 -0
- package/desktop/src/user-display.ts +20 -0
- package/package.json +1 -1
- package/src/cli/slash-dispatch.test.ts +1 -0
- package/src/cli/tui.tsx +40 -5
- package/src/core/approval.test.ts +22 -0
- package/src/core/approval.ts +20 -0
- package/src/desktop/bridge.ts +60 -6
- package/src/desktop/upload-message.test.ts +53 -0
- package/src/desktop/upload-message.ts +74 -0
- package/src/desktop/uploads.test.ts +34 -0
- package/src/desktop/uploads.ts +178 -13
- package/src/index.ts +1 -0
- package/src/init.test.ts +21 -0
- package/src/mcp/user-servers.test.ts +138 -0
- package/src/mcp/user-servers.ts +427 -0
- package/src/runtime.ts +61 -12
package/desktop/src/App.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArrowUpRightIcon } from "@phosphor-icons/react/dist/csr/ArrowUpRight";
|
|
2
2
|
import { CaretDownIcon } from "@phosphor-icons/react/dist/csr/CaretDown";
|
|
3
3
|
import { CheckIcon } from "@phosphor-icons/react/dist/csr/Check";
|
|
4
|
+
import { FileIcon } from "@phosphor-icons/react/dist/csr/File";
|
|
4
5
|
import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple";
|
|
5
6
|
import { GearIcon } from "@phosphor-icons/react/dist/csr/Gear";
|
|
6
7
|
import { MicrophoneIcon } from "@phosphor-icons/react/dist/csr/Microphone";
|
|
@@ -85,9 +86,11 @@ import {
|
|
|
85
86
|
isMicPermissionDenied,
|
|
86
87
|
pickRecorderMime,
|
|
87
88
|
} from "./dictation";
|
|
89
|
+
import { FilesPanel, homePath } from "./FilesPanel";
|
|
88
90
|
import { FloatNotice } from "./FloatNotice";
|
|
89
91
|
import { integrationMatches } from "./integration-search";
|
|
90
92
|
import { LogoMark } from "./LogoMark";
|
|
93
|
+
import { McpPanel } from "./McpPanel";
|
|
91
94
|
import { pickerKeyAction, pickerStartIndex, stepIndex } from "./picker-nav";
|
|
92
95
|
import {
|
|
93
96
|
enqueueMessage,
|
|
@@ -115,10 +118,11 @@ import {
|
|
|
115
118
|
thoughtTools,
|
|
116
119
|
} from "./thought";
|
|
117
120
|
import { eventCountSuffix } from "./tool-label";
|
|
121
|
+
import { joinUploadDisplay, userBubbleContent } from "./user-display";
|
|
118
122
|
|
|
119
123
|
type ThemeChoice = "system" | "light" | "dark";
|
|
120
124
|
type UiStatus = "boot" | "idle" | "running" | "approval" | "picker";
|
|
121
|
-
type MainView = "chat" | "settings" | "integrations" | "skills";
|
|
125
|
+
type MainView = "chat" | "settings" | "integrations" | "skills" | "files";
|
|
122
126
|
|
|
123
127
|
interface PickerState {
|
|
124
128
|
title: string;
|
|
@@ -140,6 +144,14 @@ interface PendingApproval {
|
|
|
140
144
|
input: Record<string, unknown>;
|
|
141
145
|
}
|
|
142
146
|
|
|
147
|
+
function isUploadEditPending(pending: PendingApproval): boolean {
|
|
148
|
+
return (
|
|
149
|
+
(pending.toolName === "edit_file" || pending.toolName === "write_file") &&
|
|
150
|
+
typeof pending.input.originalPath === "string" &&
|
|
151
|
+
pending.input.originalPath.trim().length > 0
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
143
155
|
function pickerSelectedId(kind: SlashPickerKind, current: DesktopState): string | undefined {
|
|
144
156
|
if (kind === "model") return current.modelId;
|
|
145
157
|
if (kind === "mode") return current.mode;
|
|
@@ -153,6 +165,7 @@ function mainViewTitle(view: MainView): string {
|
|
|
153
165
|
if (view === "settings") return "Settings";
|
|
154
166
|
if (view === "integrations") return "Integrations";
|
|
155
167
|
if (view === "skills") return "Skills";
|
|
168
|
+
if (view === "files") return "Files";
|
|
156
169
|
return "Chat";
|
|
157
170
|
}
|
|
158
171
|
|
|
@@ -276,10 +289,12 @@ function DeskSidePanel(
|
|
|
276
289
|
bridge: BridgeClient | null;
|
|
277
290
|
theme: ThemeChoice;
|
|
278
291
|
skillQuery: string;
|
|
292
|
+
uploads: Array<{ name: string; rel: string; sourcePath?: string }>;
|
|
279
293
|
onTheme: (theme: ThemeChoice) => void;
|
|
280
294
|
onSaved: (state: DesktopState) => void;
|
|
281
295
|
onNotice: (text: string) => void;
|
|
282
296
|
onSkillQuery: (value: string) => void;
|
|
297
|
+
onOpenFile: (path: string, reveal: boolean) => void;
|
|
283
298
|
}>,
|
|
284
299
|
): React.ReactElement | null {
|
|
285
300
|
if (!props.bridge) return null;
|
|
@@ -307,6 +322,9 @@ function DeskSidePanel(
|
|
|
307
322
|
/>
|
|
308
323
|
);
|
|
309
324
|
}
|
|
325
|
+
if (props.view === "files") {
|
|
326
|
+
return <FilesPanel items={props.uploads} onOpen={props.onOpenFile} />;
|
|
327
|
+
}
|
|
310
328
|
return null;
|
|
311
329
|
}
|
|
312
330
|
|
|
@@ -436,7 +454,11 @@ export function App(): React.ReactElement {
|
|
|
436
454
|
const [pending, setPending] = useState<PendingApproval | null>(null);
|
|
437
455
|
const [listening, setListening] = useState(false);
|
|
438
456
|
const [queue, setQueue] = useState<QueuedMessage[]>([]);
|
|
439
|
-
const [editingUser, setEditingUser] = useState<{
|
|
457
|
+
const [editingUser, setEditingUser] = useState<{
|
|
458
|
+
index: number;
|
|
459
|
+
text: string;
|
|
460
|
+
suffix?: string;
|
|
461
|
+
} | null>(null);
|
|
440
462
|
const [editingQueuedId, setEditingQueuedId] = useState<string | null>(null);
|
|
441
463
|
const [notice, setNotice] = useState<{ text: string; id: number } | null>(null);
|
|
442
464
|
const [attachments, setAttachments] = useState<ComposerAttachment[]>([]);
|
|
@@ -918,8 +940,8 @@ export function App(): React.ReactElement {
|
|
|
918
940
|
|
|
919
941
|
const commitEdit = useCallback(async () => {
|
|
920
942
|
if (!bridge || !editingUser) return;
|
|
921
|
-
const text = editingUser.text.
|
|
922
|
-
if (!text) return;
|
|
943
|
+
const text = joinUploadDisplay(editingUser.text, editingUser.suffix);
|
|
944
|
+
if (!text.trim()) return;
|
|
923
945
|
const index = editingUser.index;
|
|
924
946
|
setEditingUser(null);
|
|
925
947
|
skipDrainRef.current = true;
|
|
@@ -1117,7 +1139,7 @@ export function App(): React.ReactElement {
|
|
|
1117
1139
|
}, [renamingId, sessionMenu]);
|
|
1118
1140
|
|
|
1119
1141
|
const decide = useCallback(
|
|
1120
|
-
async (decision: "yes" | "no" | "always") => {
|
|
1142
|
+
async (decision: "yes" | "no" | "always" | "copy" | "original") => {
|
|
1121
1143
|
if (!bridge || !pending) return;
|
|
1122
1144
|
await approve(bridge, {
|
|
1123
1145
|
callId: pending.callId,
|
|
@@ -1418,6 +1440,15 @@ export function App(): React.ReactElement {
|
|
|
1418
1440
|
</ul>
|
|
1419
1441
|
)}
|
|
1420
1442
|
</section>
|
|
1443
|
+
<button
|
|
1444
|
+
type="button"
|
|
1445
|
+
className={`desk-settings-btn ${view === "files" ? "is-on" : ""}`}
|
|
1446
|
+
aria-label="Files"
|
|
1447
|
+
onClick={() => setView((current) => (current === "files" ? "chat" : "files"))}
|
|
1448
|
+
>
|
|
1449
|
+
<FileIcon size={16} weight="regular" />
|
|
1450
|
+
<span>Files</span>
|
|
1451
|
+
</button>
|
|
1421
1452
|
<button
|
|
1422
1453
|
type="button"
|
|
1423
1454
|
className={`desk-settings-btn ${view === "skills" ? "is-on" : ""}`}
|
|
@@ -1474,10 +1505,16 @@ export function App(): React.ReactElement {
|
|
|
1474
1505
|
bridge={bridge}
|
|
1475
1506
|
theme={theme}
|
|
1476
1507
|
skillQuery={skillQuery}
|
|
1508
|
+
uploads={state.uploads ?? []}
|
|
1477
1509
|
onTheme={setTheme}
|
|
1478
1510
|
onSaved={(next) => setState(next)}
|
|
1479
1511
|
onNotice={showNotice}
|
|
1480
1512
|
onSkillQuery={setSkillQuery}
|
|
1513
|
+
onOpenFile={(path, reveal) => {
|
|
1514
|
+
void openLocalFile(path, reveal, bridge).catch((err: unknown) => {
|
|
1515
|
+
noticeError(err);
|
|
1516
|
+
});
|
|
1517
|
+
}}
|
|
1481
1518
|
/>
|
|
1482
1519
|
) : (
|
|
1483
1520
|
<div className="desk-transcript" ref={transcriptRef}>
|
|
@@ -1509,7 +1546,14 @@ export function App(): React.ReactElement {
|
|
|
1509
1546
|
}
|
|
1510
1547
|
onStartEdit={
|
|
1511
1548
|
line.type === "user"
|
|
1512
|
-
? () =>
|
|
1549
|
+
? () => {
|
|
1550
|
+
const shown = userBubbleContent(line.text, line.attachments);
|
|
1551
|
+
setEditingUser({
|
|
1552
|
+
index: line.userTurnIndex,
|
|
1553
|
+
text: shown.text,
|
|
1554
|
+
suffix: shown.suffix,
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1513
1557
|
: undefined
|
|
1514
1558
|
}
|
|
1515
1559
|
onEditChange={(text) =>
|
|
@@ -1540,31 +1584,70 @@ export function App(): React.ReactElement {
|
|
|
1540
1584
|
|
|
1541
1585
|
{view === "chat" && pending ? (
|
|
1542
1586
|
<section className="desk-approve" aria-label="Approval needed">
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1587
|
+
{isUploadEditPending(pending) ? (
|
|
1588
|
+
<>
|
|
1589
|
+
<p>Edit this file where?</p>
|
|
1590
|
+
<pre className="cel-code">
|
|
1591
|
+
{typeof pending.input.fileName === "string" ? pending.input.fileName : "File"}
|
|
1592
|
+
{"\n"}Copy:{" "}
|
|
1593
|
+
{typeof pending.input.copyPath === "string"
|
|
1594
|
+
? pending.input.copyPath
|
|
1595
|
+
: approvalPreview}
|
|
1596
|
+
{"\n"}Original: {homePath(String(pending.input.originalPath))}
|
|
1597
|
+
</pre>
|
|
1598
|
+
<div className="desk-approve-actions">
|
|
1599
|
+
<button
|
|
1600
|
+
type="button"
|
|
1601
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1602
|
+
onClick={() => void decide("copy")}
|
|
1603
|
+
>
|
|
1604
|
+
Copy
|
|
1605
|
+
</button>
|
|
1606
|
+
<button
|
|
1607
|
+
type="button"
|
|
1608
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1609
|
+
onClick={() => void decide("original")}
|
|
1610
|
+
>
|
|
1611
|
+
Original
|
|
1612
|
+
</button>
|
|
1613
|
+
<button
|
|
1614
|
+
type="button"
|
|
1615
|
+
className="cel-btn cel-btn--tertiary cel-btn--compact"
|
|
1616
|
+
onClick={() => void decide("no")}
|
|
1617
|
+
>
|
|
1618
|
+
Cancel
|
|
1619
|
+
</button>
|
|
1620
|
+
</div>
|
|
1621
|
+
</>
|
|
1622
|
+
) : (
|
|
1623
|
+
<>
|
|
1624
|
+
<p>Approval needed · {pending.toolName}</p>
|
|
1625
|
+
<pre className="cel-code">{approvalPreview}</pre>
|
|
1626
|
+
<div className="desk-approve-actions">
|
|
1627
|
+
<button
|
|
1628
|
+
type="button"
|
|
1629
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1630
|
+
onClick={() => void decide("yes")}
|
|
1631
|
+
>
|
|
1632
|
+
Approve
|
|
1633
|
+
</button>
|
|
1634
|
+
<button
|
|
1635
|
+
type="button"
|
|
1636
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1637
|
+
onClick={() => void decide("no")}
|
|
1638
|
+
>
|
|
1639
|
+
Deny
|
|
1640
|
+
</button>
|
|
1641
|
+
<button
|
|
1642
|
+
type="button"
|
|
1643
|
+
className="cel-btn cel-btn--tertiary cel-btn--compact"
|
|
1644
|
+
onClick={() => void decide("always")}
|
|
1645
|
+
>
|
|
1646
|
+
Always this session
|
|
1647
|
+
</button>
|
|
1648
|
+
</div>
|
|
1649
|
+
</>
|
|
1650
|
+
)}
|
|
1568
1651
|
</section>
|
|
1569
1652
|
) : null}
|
|
1570
1653
|
|
|
@@ -1935,6 +2018,45 @@ function IntegrationsPanel(
|
|
|
1935
2018
|
bridge: BridgeClient;
|
|
1936
2019
|
onNotice: (text: string) => void;
|
|
1937
2020
|
}>,
|
|
2021
|
+
): React.ReactElement {
|
|
2022
|
+
const [tab, setTab] = useState<"integrations" | "mcp">("integrations");
|
|
2023
|
+
|
|
2024
|
+
return (
|
|
2025
|
+
<div className="desk-integrations">
|
|
2026
|
+
<div className="desk-pane-tabs" role="tablist" aria-label="Integrations and MCP">
|
|
2027
|
+
<button
|
|
2028
|
+
type="button"
|
|
2029
|
+
role="tab"
|
|
2030
|
+
aria-selected={tab === "integrations"}
|
|
2031
|
+
className={tab === "integrations" ? "is-on" : undefined}
|
|
2032
|
+
onClick={() => setTab("integrations")}
|
|
2033
|
+
>
|
|
2034
|
+
Integrations
|
|
2035
|
+
</button>
|
|
2036
|
+
<button
|
|
2037
|
+
type="button"
|
|
2038
|
+
role="tab"
|
|
2039
|
+
aria-selected={tab === "mcp"}
|
|
2040
|
+
className={tab === "mcp" ? "is-on" : undefined}
|
|
2041
|
+
onClick={() => setTab("mcp")}
|
|
2042
|
+
>
|
|
2043
|
+
MCP
|
|
2044
|
+
</button>
|
|
2045
|
+
</div>
|
|
2046
|
+
{tab === "mcp" ? (
|
|
2047
|
+
<McpPanel bridge={props.bridge} onNotice={props.onNotice} />
|
|
2048
|
+
) : (
|
|
2049
|
+
<HostedIntegrationsList bridge={props.bridge} onNotice={props.onNotice} />
|
|
2050
|
+
)}
|
|
2051
|
+
</div>
|
|
2052
|
+
);
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
function HostedIntegrationsList(
|
|
2056
|
+
props: Readonly<{
|
|
2057
|
+
bridge: BridgeClient;
|
|
2058
|
+
onNotice: (text: string) => void;
|
|
2059
|
+
}>,
|
|
1938
2060
|
): React.ReactElement {
|
|
1939
2061
|
const [items, setItems] = useState<PublicIntegration[] | null>(null);
|
|
1940
2062
|
const [query, setQuery] = useState("");
|
|
@@ -1980,23 +2102,15 @@ function IntegrationsPanel(
|
|
|
1980
2102
|
};
|
|
1981
2103
|
|
|
1982
2104
|
if (!items && !loadFailed) {
|
|
1983
|
-
return
|
|
1984
|
-
<div className="desk-integrations">
|
|
1985
|
-
<p>Loading integrations</p>
|
|
1986
|
-
</div>
|
|
1987
|
-
);
|
|
2105
|
+
return <p>Loading integrations</p>;
|
|
1988
2106
|
}
|
|
1989
2107
|
|
|
1990
2108
|
if (!items && loadFailed) {
|
|
1991
|
-
return
|
|
1992
|
-
<div className="desk-integrations">
|
|
1993
|
-
<p className="desk-side-empty">Integrations could not be loaded</p>
|
|
1994
|
-
</div>
|
|
1995
|
-
);
|
|
2109
|
+
return <p className="desk-side-empty">Integrations could not be loaded</p>;
|
|
1996
2110
|
}
|
|
1997
2111
|
|
|
1998
2112
|
return (
|
|
1999
|
-
|
|
2113
|
+
<>
|
|
2000
2114
|
<p className="desk-integrations-lead">
|
|
2001
2115
|
Hosted MCP servers the agent can call. App connectors for published sites stay in the
|
|
2002
2116
|
builder.
|
|
@@ -2073,7 +2187,7 @@ function IntegrationsPanel(
|
|
|
2073
2187
|
) : null}
|
|
2074
2188
|
</>
|
|
2075
2189
|
)}
|
|
2076
|
-
|
|
2190
|
+
</>
|
|
2077
2191
|
);
|
|
2078
2192
|
}
|
|
2079
2193
|
|
|
@@ -2328,6 +2442,7 @@ function UserTranscriptLine(
|
|
|
2328
2442
|
}>,
|
|
2329
2443
|
): React.ReactElement {
|
|
2330
2444
|
const editing = props.editing != null;
|
|
2445
|
+
const shown = userBubbleContent(props.line.text, props.line.attachments);
|
|
2331
2446
|
return (
|
|
2332
2447
|
<article className={`desk-line desk-line--user${editing ? " is-editing" : ""}`}>
|
|
2333
2448
|
<p className="desk-line__who">
|
|
@@ -2382,8 +2497,8 @@ function UserTranscriptLine(
|
|
|
2382
2497
|
</>
|
|
2383
2498
|
) : (
|
|
2384
2499
|
<>
|
|
2385
|
-
<AttachmentThumbs items={
|
|
2386
|
-
{
|
|
2500
|
+
<AttachmentThumbs items={shown.attachments} variant="chat" />
|
|
2501
|
+
{shown.text ? <p>{shown.text}</p> : null}
|
|
2387
2502
|
</>
|
|
2388
2503
|
)}
|
|
2389
2504
|
</div>
|
|
@@ -16,7 +16,7 @@ export function AttachmentThumbs(
|
|
|
16
16
|
<ul className="desk-attach-previews" aria-label="Attached files">
|
|
17
17
|
{props.items.map((item, index) => (
|
|
18
18
|
<li key={item.id ?? `${item.name}-${index}`} className="desk-attach-preview">
|
|
19
|
-
<ChatPreview name={item.name}
|
|
19
|
+
<ChatPreview name={item.name} />
|
|
20
20
|
</li>
|
|
21
21
|
))}
|
|
22
22
|
</ul>
|
|
@@ -43,31 +43,7 @@ export function AttachmentThumbs(
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function ChatPreview(
|
|
47
|
-
props: Readonly<{
|
|
48
|
-
name: string;
|
|
49
|
-
kind: ComposerFileKind;
|
|
50
|
-
previewUrl?: string;
|
|
51
|
-
}>,
|
|
52
|
-
): React.ReactElement {
|
|
53
|
-
if (props.kind === "image" && props.previewUrl) {
|
|
54
|
-
return (
|
|
55
|
-
<>
|
|
56
|
-
<img className="desk-preview desk-preview--img" src={props.previewUrl} alt={props.name} />
|
|
57
|
-
<p className="desk-line__caption">{props.name}</p>
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
if (props.kind === "video" && props.previewUrl) {
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
<video className="desk-preview desk-preview--img" controls src={props.previewUrl}>
|
|
65
|
-
<track kind="captions" srcLang="en" label="Captions" src="data:text/vtt,WEBVTT" />
|
|
66
|
-
</video>
|
|
67
|
-
<p className="desk-line__caption">{props.name}</p>
|
|
68
|
-
</>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
46
|
+
function ChatPreview(props: Readonly<{ name: string }>): React.ReactElement {
|
|
71
47
|
return (
|
|
72
48
|
<span className="desk-attach-file">
|
|
73
49
|
<FileGlyph size={16} weight="regular" aria-hidden="true" />
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
|
|
4
|
+
export interface UploadItem {
|
|
5
|
+
name: string;
|
|
6
|
+
rel: string;
|
|
7
|
+
sourcePath?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function homePath(path: string): string {
|
|
11
|
+
if (path.startsWith("/Users/")) {
|
|
12
|
+
const cut = path.indexOf("/", 7);
|
|
13
|
+
if (cut > 0) return `~${path.slice(cut)}`;
|
|
14
|
+
}
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function FilesPanel(
|
|
19
|
+
props: Readonly<{
|
|
20
|
+
items: UploadItem[];
|
|
21
|
+
onOpen: (path: string, reveal: boolean) => void;
|
|
22
|
+
}>,
|
|
23
|
+
): ReactElement {
|
|
24
|
+
return (
|
|
25
|
+
<div className="desk-integrations">
|
|
26
|
+
<p className="desk-integrations-lead">Files you attached. Copies stay in this project.</p>
|
|
27
|
+
{props.items.length === 0 ? (
|
|
28
|
+
<p className="desk-side-empty">No uploaded files</p>
|
|
29
|
+
) : (
|
|
30
|
+
<ul className="desk-integration-list">
|
|
31
|
+
{props.items.map((item) => (
|
|
32
|
+
<li key={item.rel}>
|
|
33
|
+
<span className="desk-integration-glyph desk-integration-mark" aria-hidden="true">
|
|
34
|
+
{fileGlyph(item.name)}
|
|
35
|
+
</span>
|
|
36
|
+
<div>
|
|
37
|
+
<p>{item.name}</p>
|
|
38
|
+
<em>{item.sourcePath ? homePath(item.sourcePath) : "Copy in this project"}</em>
|
|
39
|
+
</div>
|
|
40
|
+
<div className="desk-integration-actions">
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
44
|
+
onClick={() => props.onOpen(item.rel, false)}
|
|
45
|
+
>
|
|
46
|
+
Open
|
|
47
|
+
</button>
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
className="cel-btn cel-btn--quiet cel-btn--compact"
|
|
51
|
+
aria-label={`Show ${item.name} in folder`}
|
|
52
|
+
onClick={() => props.onOpen(item.rel, true)}
|
|
53
|
+
>
|
|
54
|
+
<FolderSimpleIcon size={16} weight="regular" />
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
</li>
|
|
58
|
+
))}
|
|
59
|
+
</ul>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function fileGlyph(name: string): string {
|
|
66
|
+
const match = /\.([a-z0-9]{1,4})$/i.exec(name.trim());
|
|
67
|
+
return (match?.[1] ?? "file").slice(0, 4).toUpperCase();
|
|
68
|
+
}
|