@useavalon/caelence-agent 0.2.3-canary.1 → 0.2.3-canary.2
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 +9 -2919
- package/desktop/src/BubbleClip.tsx +1 -1
- package/desktop/src/ComposerAttach.tsx +2 -2
- package/desktop/src/DeskBoot.tsx +28 -0
- package/desktop/src/DeskChrome.tsx +360 -0
- package/desktop/src/DeskComposer.tsx +311 -0
- package/desktop/src/DeskSidebar.tsx +191 -0
- package/desktop/src/FilesPanel.tsx +104 -36
- package/desktop/src/FloatNotice.test.ts +12 -0
- package/desktop/src/FloatNotice.tsx +5 -2
- package/desktop/src/IntegrationsPanel.tsx +273 -0
- package/desktop/src/McpPanel.tsx +8 -8
- package/desktop/src/MemoryPanel.tsx +138 -0
- package/desktop/src/QueuePanel.tsx +123 -0
- package/desktop/src/SessionsPanel.tsx +174 -0
- package/desktop/src/SettingsPanel.tsx +181 -0
- package/desktop/src/SkillsPanel.tsx +28 -12
- package/desktop/src/TranscriptViews.tsx +637 -0
- package/desktop/src/api.ts +36 -0
- package/desktop/src/app.css +159 -11
- package/desktop/src/composer-files.ts +2 -2
- package/desktop/src/desk-keys.ts +45 -0
- package/desktop/src/desk-prefs.ts +29 -0
- package/desktop/src/desk-types.ts +92 -0
- package/desktop/src/desktop-turn.ts +271 -0
- package/desktop/src/queue.ts +1 -1
- package/desktop/src/session-search.test.ts +20 -0
- package/desktop/src/session-search.ts +13 -0
- package/desktop/src/session-select.test.ts +23 -0
- package/desktop/src/session-select.ts +32 -0
- package/desktop/src/useDeskDictation.ts +123 -0
- package/desktop/src/useDeskFiles.ts +180 -0
- package/desktop/src/useDeskNotice.ts +20 -0
- package/desktop/src/useDeskPicker.ts +189 -0
- package/desktop/src/useDeskPrefs.ts +30 -0
- package/desktop/src/useDeskRuntime.ts +109 -0
- package/desktop/src/useDeskSessions.ts +195 -0
- package/desktop/src/useDeskSlash.ts +31 -0
- package/desktop/src/useDeskTurns.ts +264 -0
- package/desktop/src/useDesktopApp.ts +286 -0
- package/desktop/src/user-display.ts +2 -2
- package/package.json +2 -2
- package/src/desktop/bridge.test.ts +13 -0
- package/src/desktop/bridge.ts +45 -19
- package/src/desktop/uploads.test.ts +6 -0
- package/src/desktop/uploads.ts +178 -66
|
@@ -8,16 +8,19 @@ import { useEffect } from "react";
|
|
|
8
8
|
|
|
9
9
|
export const NOTICE_MS = 4000;
|
|
10
10
|
|
|
11
|
+
export type NoticeKind = "ok" | "error";
|
|
12
|
+
|
|
11
13
|
export function FloatNotice(
|
|
12
|
-
props: Readonly<{ text: string; onDismiss: () => void }>,
|
|
14
|
+
props: Readonly<{ text: string; kind?: NoticeKind; onDismiss: () => void }>,
|
|
13
15
|
): React.ReactElement {
|
|
14
16
|
const { text, onDismiss } = props;
|
|
17
|
+
const kind = props.kind ?? "ok";
|
|
15
18
|
useEffect(() => {
|
|
16
19
|
const id = window.setTimeout(onDismiss, NOTICE_MS);
|
|
17
20
|
return () => window.clearTimeout(id);
|
|
18
21
|
}, [onDismiss]);
|
|
19
22
|
return (
|
|
20
|
-
<output className=
|
|
23
|
+
<output className={`desk-notice cel-float${kind === "error" ? " desk-notice--error" : ""}`}>
|
|
21
24
|
<span className="desk-notice__label">{text}</span>
|
|
22
25
|
<button type="button" className="desk-notice__close" aria-label="Dismiss" onClick={onDismiss}>
|
|
23
26
|
<XIcon size={16} weight="regular" />
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { CheckIcon } from "@phosphor-icons/react/dist/csr/Check";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { errorMessage } from "../../src/core/errors";
|
|
4
|
+
import {
|
|
5
|
+
type BridgeClient,
|
|
6
|
+
connectIntegration,
|
|
7
|
+
disconnectIntegration,
|
|
8
|
+
getIntegrations,
|
|
9
|
+
type PublicIntegration,
|
|
10
|
+
} from "./api";
|
|
11
|
+
import type { ShowNotice } from "./desk-types";
|
|
12
|
+
import { integrationMatches } from "./integration-search";
|
|
13
|
+
import { McpPanel } from "./McpPanel";
|
|
14
|
+
|
|
15
|
+
export function IntegrationActions(
|
|
16
|
+
props: Readonly<{
|
|
17
|
+
pending: boolean;
|
|
18
|
+
connected: boolean;
|
|
19
|
+
onConnect: () => void;
|
|
20
|
+
onDisconnect: () => void;
|
|
21
|
+
}>,
|
|
22
|
+
): React.ReactElement {
|
|
23
|
+
if (props.pending) {
|
|
24
|
+
return (
|
|
25
|
+
<span className="desk-integration-ok">
|
|
26
|
+
<span className="cel-chip__spin" aria-hidden="true" />
|
|
27
|
+
{props.connected ? "Disconnecting" : "Connecting"}
|
|
28
|
+
</span>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (props.connected) {
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<span className="desk-integration-ok">
|
|
35
|
+
<CheckIcon size={16} weight="regular" aria-hidden="true" />
|
|
36
|
+
Connected
|
|
37
|
+
</span>
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
className="cel-btn cel-btn--quiet cel-btn--compact"
|
|
41
|
+
onClick={props.onDisconnect}
|
|
42
|
+
>
|
|
43
|
+
Disconnect
|
|
44
|
+
</button>
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return (
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
52
|
+
onClick={props.onConnect}
|
|
53
|
+
>
|
|
54
|
+
Connect
|
|
55
|
+
</button>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function IntegrationMark(props: Readonly<{ item: PublicIntegration }>): React.ReactElement {
|
|
60
|
+
const [failed, setFailed] = useState(false);
|
|
61
|
+
if (failed) {
|
|
62
|
+
return <span className="desk-integration-glyph desk-integration-mark">{props.item.glyph}</span>;
|
|
63
|
+
}
|
|
64
|
+
return (
|
|
65
|
+
<span className="desk-integration-mark">
|
|
66
|
+
<img src={props.item.logoUrl} alt="" width={20} height={20} onError={() => setFailed(true)} />
|
|
67
|
+
</span>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function IntegrationRow(
|
|
72
|
+
props: Readonly<{
|
|
73
|
+
item: PublicIntegration;
|
|
74
|
+
pending: boolean;
|
|
75
|
+
onConnect: () => void;
|
|
76
|
+
onDisconnect: () => void;
|
|
77
|
+
}>,
|
|
78
|
+
): React.ReactElement {
|
|
79
|
+
const { item } = props;
|
|
80
|
+
return (
|
|
81
|
+
<li>
|
|
82
|
+
<IntegrationMark item={item} />
|
|
83
|
+
<div>
|
|
84
|
+
<p>{item.label}</p>
|
|
85
|
+
<em>{item.description}</em>
|
|
86
|
+
</div>
|
|
87
|
+
<div className="desk-integration-actions">
|
|
88
|
+
<IntegrationActions
|
|
89
|
+
pending={props.pending}
|
|
90
|
+
connected={item.connected}
|
|
91
|
+
onConnect={props.onConnect}
|
|
92
|
+
onDisconnect={props.onDisconnect}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
</li>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function IntegrationsPanel(
|
|
100
|
+
props: Readonly<{
|
|
101
|
+
bridge: BridgeClient;
|
|
102
|
+
onNotice: ShowNotice;
|
|
103
|
+
}>,
|
|
104
|
+
): React.ReactElement {
|
|
105
|
+
const [tab, setTab] = useState<"integrations" | "mcp">("integrations");
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div className="desk-integrations">
|
|
109
|
+
<div className="desk-pane-tabs" role="tablist" aria-label="Integrations and MCP">
|
|
110
|
+
<button
|
|
111
|
+
type="button"
|
|
112
|
+
role="tab"
|
|
113
|
+
aria-selected={tab === "integrations"}
|
|
114
|
+
className={tab === "integrations" ? "is-on" : undefined}
|
|
115
|
+
onClick={() => setTab("integrations")}
|
|
116
|
+
>
|
|
117
|
+
Integrations
|
|
118
|
+
</button>
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
role="tab"
|
|
122
|
+
aria-selected={tab === "mcp"}
|
|
123
|
+
className={tab === "mcp" ? "is-on" : undefined}
|
|
124
|
+
onClick={() => setTab("mcp")}
|
|
125
|
+
>
|
|
126
|
+
MCP
|
|
127
|
+
</button>
|
|
128
|
+
</div>
|
|
129
|
+
{tab === "mcp" ? (
|
|
130
|
+
<McpPanel bridge={props.bridge} onNotice={props.onNotice} />
|
|
131
|
+
) : (
|
|
132
|
+
<HostedIntegrationsList bridge={props.bridge} onNotice={props.onNotice} />
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function HostedIntegrationsList(
|
|
139
|
+
props: Readonly<{
|
|
140
|
+
bridge: BridgeClient;
|
|
141
|
+
onNotice: ShowNotice;
|
|
142
|
+
}>,
|
|
143
|
+
): React.ReactElement {
|
|
144
|
+
const [items, setItems] = useState<PublicIntegration[] | null>(null);
|
|
145
|
+
const [query, setQuery] = useState("");
|
|
146
|
+
const [loadFailed, setLoadFailed] = useState(false);
|
|
147
|
+
const [pendingId, setPendingId] = useState<string | null>(null);
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
let alive = true;
|
|
151
|
+
void getIntegrations(props.bridge)
|
|
152
|
+
.then((result) => {
|
|
153
|
+
if (alive) setItems(result.items);
|
|
154
|
+
})
|
|
155
|
+
.catch((err: unknown) => {
|
|
156
|
+
if (!alive) return;
|
|
157
|
+
setLoadFailed(true);
|
|
158
|
+
props.onNotice(errorMessage(err), "error");
|
|
159
|
+
});
|
|
160
|
+
return () => {
|
|
161
|
+
alive = false;
|
|
162
|
+
};
|
|
163
|
+
}, [props.bridge, props.onNotice]);
|
|
164
|
+
|
|
165
|
+
const visible = (items ?? []).filter((item) => integrationMatches(item.label, query));
|
|
166
|
+
const ready = visible.filter(
|
|
167
|
+
(item) => item.auth !== "google" && item.auth !== "microsoft" && item.auth !== "desktop",
|
|
168
|
+
);
|
|
169
|
+
const desktop = visible.filter((item) => item.auth === "desktop");
|
|
170
|
+
const setup = visible.filter((item) => item.auth === "google" || item.auth === "microsoft");
|
|
171
|
+
|
|
172
|
+
const run = async (id: string, action: "connect" | "disconnect"): Promise<void> => {
|
|
173
|
+
setPendingId(id);
|
|
174
|
+
try {
|
|
175
|
+
const result =
|
|
176
|
+
action === "connect"
|
|
177
|
+
? await connectIntegration(props.bridge, id)
|
|
178
|
+
: await disconnectIntegration(props.bridge, id);
|
|
179
|
+
setItems(result.items);
|
|
180
|
+
props.onNotice(action === "connect" ? "Connected" : "Disconnected");
|
|
181
|
+
} catch (err) {
|
|
182
|
+
props.onNotice(errorMessage(err), "error");
|
|
183
|
+
} finally {
|
|
184
|
+
setPendingId(null);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if (!items && !loadFailed) {
|
|
189
|
+
return <p>Loading integrations</p>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!items && loadFailed) {
|
|
193
|
+
return <p className="desk-side-empty">Integrations could not be loaded</p>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<>
|
|
198
|
+
<p className="desk-integrations-lead">Connect a service the agent can call.</p>
|
|
199
|
+
<label className="desk-field">
|
|
200
|
+
<span className="visually-hidden">Search integrations</span>
|
|
201
|
+
<input
|
|
202
|
+
className="cel-input"
|
|
203
|
+
value={query}
|
|
204
|
+
placeholder="Search"
|
|
205
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
206
|
+
/>
|
|
207
|
+
</label>
|
|
208
|
+
{visible.length === 0 ? (
|
|
209
|
+
<p className="desk-side-empty">No integrations match</p>
|
|
210
|
+
) : (
|
|
211
|
+
<>
|
|
212
|
+
{ready.length > 0 ? (
|
|
213
|
+
<ul className="desk-integration-list">
|
|
214
|
+
{ready.map((item) => (
|
|
215
|
+
<IntegrationRow
|
|
216
|
+
key={item.id}
|
|
217
|
+
item={item}
|
|
218
|
+
pending={pendingId === item.id}
|
|
219
|
+
onConnect={() => void run(item.id, "connect")}
|
|
220
|
+
onDisconnect={() => void run(item.id, "disconnect")}
|
|
221
|
+
/>
|
|
222
|
+
))}
|
|
223
|
+
</ul>
|
|
224
|
+
) : null}
|
|
225
|
+
{desktop.length > 0 ? (
|
|
226
|
+
<>
|
|
227
|
+
<div className="desk-integration-split">
|
|
228
|
+
<p>Figma desktop required</p>
|
|
229
|
+
<em>
|
|
230
|
+
Remote Figma MCP only allows approved clients. Enable the Dev Mode MCP server in
|
|
231
|
+
Figma desktop, then Connect.
|
|
232
|
+
</em>
|
|
233
|
+
</div>
|
|
234
|
+
<ul className="desk-integration-list">
|
|
235
|
+
{desktop.map((item) => (
|
|
236
|
+
<IntegrationRow
|
|
237
|
+
key={item.id}
|
|
238
|
+
item={item}
|
|
239
|
+
pending={pendingId === item.id}
|
|
240
|
+
onConnect={() => void run(item.id, "connect")}
|
|
241
|
+
onDisconnect={() => void run(item.id, "disconnect")}
|
|
242
|
+
/>
|
|
243
|
+
))}
|
|
244
|
+
</ul>
|
|
245
|
+
</>
|
|
246
|
+
) : null}
|
|
247
|
+
{setup.length > 0 ? (
|
|
248
|
+
<>
|
|
249
|
+
<div className="desk-integration-split">
|
|
250
|
+
<p>OAuth client required</p>
|
|
251
|
+
<em>
|
|
252
|
+
Google Workspace and Microsoft 365 have no dynamic client registration. Add a
|
|
253
|
+
client id in Settings, then Connect.
|
|
254
|
+
</em>
|
|
255
|
+
</div>
|
|
256
|
+
<ul className="desk-integration-list">
|
|
257
|
+
{setup.map((item) => (
|
|
258
|
+
<IntegrationRow
|
|
259
|
+
key={item.id}
|
|
260
|
+
item={item}
|
|
261
|
+
pending={pendingId === item.id}
|
|
262
|
+
onConnect={() => void run(item.id, "connect")}
|
|
263
|
+
onDisconnect={() => void run(item.id, "disconnect")}
|
|
264
|
+
/>
|
|
265
|
+
))}
|
|
266
|
+
</ul>
|
|
267
|
+
</>
|
|
268
|
+
) : null}
|
|
269
|
+
</>
|
|
270
|
+
)}
|
|
271
|
+
</>
|
|
272
|
+
);
|
|
273
|
+
}
|
package/desktop/src/McpPanel.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { CheckIcon } from "@phosphor-icons/react/dist/csr/Check";
|
|
|
2
2
|
import { type ReactElement, useEffect, useState } from "react";
|
|
3
3
|
import { errorMessage } from "../../src/core/errors";
|
|
4
4
|
import { addMcp, type BridgeClient, getMcps, type PublicUserMcp, removeMcp } from "./api";
|
|
5
|
+
import type { ShowNotice } from "./desk-types";
|
|
5
6
|
|
|
6
7
|
const LOCAL_MCP_PLACEHOLDER = `uvx mcp-server-fetch
|
|
7
8
|
or ------------------------
|
|
@@ -86,7 +87,7 @@ function McpRow(
|
|
|
86
87
|
export function McpPanel(
|
|
87
88
|
props: Readonly<{
|
|
88
89
|
bridge: BridgeClient;
|
|
89
|
-
onNotice:
|
|
90
|
+
onNotice: ShowNotice;
|
|
90
91
|
}>,
|
|
91
92
|
): ReactElement {
|
|
92
93
|
const [items, setItems] = useState<PublicUserMcp[] | null>(null);
|
|
@@ -108,7 +109,7 @@ export function McpPanel(
|
|
|
108
109
|
.catch((err: unknown) => {
|
|
109
110
|
if (!alive) return;
|
|
110
111
|
setLoadFailed(true);
|
|
111
|
-
props.onNotice(errorMessage(err));
|
|
112
|
+
props.onNotice(errorMessage(err), "error");
|
|
112
113
|
});
|
|
113
114
|
return () => {
|
|
114
115
|
alive = false;
|
|
@@ -129,8 +130,9 @@ export function McpPanel(
|
|
|
129
130
|
setCommand("");
|
|
130
131
|
setUrl("");
|
|
131
132
|
setToken("");
|
|
133
|
+
props.onNotice("Added");
|
|
132
134
|
} catch (err) {
|
|
133
|
-
props.onNotice(errorMessage(err));
|
|
135
|
+
props.onNotice(errorMessage(err), "error");
|
|
134
136
|
} finally {
|
|
135
137
|
setBusy(false);
|
|
136
138
|
}
|
|
@@ -141,8 +143,9 @@ export function McpPanel(
|
|
|
141
143
|
try {
|
|
142
144
|
const result = await removeMcp(props.bridge, id);
|
|
143
145
|
setItems(result.items);
|
|
146
|
+
props.onNotice("Removed");
|
|
144
147
|
} catch (err) {
|
|
145
|
-
props.onNotice(errorMessage(err));
|
|
148
|
+
props.onNotice(errorMessage(err), "error");
|
|
146
149
|
} finally {
|
|
147
150
|
setPendingId(null);
|
|
148
151
|
}
|
|
@@ -161,10 +164,7 @@ export function McpPanel(
|
|
|
161
164
|
|
|
162
165
|
return (
|
|
163
166
|
<>
|
|
164
|
-
<p className="desk-integrations-lead">
|
|
165
|
-
Local command or URL MCP servers for this project. Paste a command, or an mcpServers JSON
|
|
166
|
-
block.
|
|
167
|
-
</p>
|
|
167
|
+
<p className="desk-integrations-lead">Add a server the agent can call.</p>
|
|
168
168
|
<div className="desk-pane-tabs desk-pane-tabs--compact" role="tablist" aria-label="MCP kind">
|
|
169
169
|
<button
|
|
170
170
|
type="button"
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { CheckIcon } from "@phosphor-icons/react/dist/csr/Check";
|
|
2
|
+
import { type ReactElement, useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { errorMessage } from "../../src/core/errors";
|
|
4
|
+
import { type BridgeClient, getMemory, type PublicMemoryFact, saveMemory } from "./api";
|
|
5
|
+
import type { ShowNotice } from "./desk-types";
|
|
6
|
+
|
|
7
|
+
export function MemoryPanel(
|
|
8
|
+
props: Readonly<{
|
|
9
|
+
bridge: BridgeClient;
|
|
10
|
+
onNotice: ShowNotice;
|
|
11
|
+
}>,
|
|
12
|
+
): ReactElement {
|
|
13
|
+
const [enabled, setEnabled] = useState(false);
|
|
14
|
+
const [facts, setFacts] = useState<PublicMemoryFact[]>([]);
|
|
15
|
+
const [loaded, setLoaded] = useState(false);
|
|
16
|
+
const [pendingId, setPendingId] = useState<string | null>(null);
|
|
17
|
+
|
|
18
|
+
const refresh = useCallback(async () => {
|
|
19
|
+
const next = await getMemory(props.bridge);
|
|
20
|
+
setEnabled(next.enabled);
|
|
21
|
+
setFacts(next.facts);
|
|
22
|
+
setLoaded(true);
|
|
23
|
+
}, [props.bridge]);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
void refresh().catch((err: unknown) => {
|
|
27
|
+
props.onNotice(errorMessage(err), "error");
|
|
28
|
+
});
|
|
29
|
+
}, [props.onNotice, refresh]);
|
|
30
|
+
|
|
31
|
+
const setOn = (next: boolean) => {
|
|
32
|
+
void (async () => {
|
|
33
|
+
try {
|
|
34
|
+
const result = await saveMemory(props.bridge, { enabled: next });
|
|
35
|
+
setEnabled(result.enabled);
|
|
36
|
+
setFacts(result.facts);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
props.onNotice(errorMessage(err), "error");
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className="desk-integrations">
|
|
45
|
+
<p className="desk-integrations-lead">Keeps prefs and decisions for later chats.</p>
|
|
46
|
+
<div className="desk-pane-tabs desk-pane-tabs--compact" role="tablist" aria-label="Memory">
|
|
47
|
+
<button type="button" className={!enabled ? "is-on" : ""} onClick={() => setOn(false)}>
|
|
48
|
+
Off
|
|
49
|
+
</button>
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
className={enabled ? "is-on is-live" : ""}
|
|
53
|
+
onClick={() => setOn(true)}
|
|
54
|
+
>
|
|
55
|
+
On
|
|
56
|
+
</button>
|
|
57
|
+
</div>
|
|
58
|
+
{!loaded ? (
|
|
59
|
+
<p className="desk-side-empty">Loading memory</p>
|
|
60
|
+
) : (
|
|
61
|
+
<ul className="desk-integration-list">
|
|
62
|
+
{facts.map((fact) => (
|
|
63
|
+
<li key={fact.id}>
|
|
64
|
+
<span className="desk-integration-glyph desk-integration-mark" aria-hidden="true">
|
|
65
|
+
{fact.scope === "user" ? "USR" : "PRJ"}
|
|
66
|
+
</span>
|
|
67
|
+
<div>
|
|
68
|
+
<p>{fact.text}</p>
|
|
69
|
+
<em>{fact.scope === "user" ? "Every project" : "This project"}</em>
|
|
70
|
+
</div>
|
|
71
|
+
<div className="desk-integration-actions">
|
|
72
|
+
{fact.pinned ? (
|
|
73
|
+
<span className="desk-integration-ok">
|
|
74
|
+
<CheckIcon size={16} weight="regular" aria-hidden="true" />
|
|
75
|
+
Pinned
|
|
76
|
+
</span>
|
|
77
|
+
) : (
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
81
|
+
disabled={pendingId === fact.id}
|
|
82
|
+
onClick={() => {
|
|
83
|
+
if (pendingId) return;
|
|
84
|
+
setPendingId(fact.id);
|
|
85
|
+
void (async () => {
|
|
86
|
+
try {
|
|
87
|
+
const result = await saveMemory(props.bridge, { pin: fact.id });
|
|
88
|
+
setFacts(
|
|
89
|
+
result.facts.map((item) =>
|
|
90
|
+
item.id === fact.id ? { ...item, pinned: true } : item,
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
props.onNotice(
|
|
94
|
+
fact.scope === "user"
|
|
95
|
+
? "Pinned to ~/.harness/AGENTS.md"
|
|
96
|
+
: "Pinned to AGENTS.md",
|
|
97
|
+
);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
props.onNotice(errorMessage(err), "error");
|
|
100
|
+
} finally {
|
|
101
|
+
setPendingId(null);
|
|
102
|
+
}
|
|
103
|
+
})();
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
Pin
|
|
107
|
+
</button>
|
|
108
|
+
)}
|
|
109
|
+
<button
|
|
110
|
+
type="button"
|
|
111
|
+
className="cel-btn cel-btn--danger cel-btn--compact"
|
|
112
|
+
disabled={pendingId === fact.id}
|
|
113
|
+
onClick={() => {
|
|
114
|
+
if (pendingId) return;
|
|
115
|
+
setPendingId(fact.id);
|
|
116
|
+
void (async () => {
|
|
117
|
+
try {
|
|
118
|
+
const result = await saveMemory(props.bridge, { delete: fact.id });
|
|
119
|
+
setFacts(result.facts);
|
|
120
|
+
props.onNotice("Deleted");
|
|
121
|
+
} catch (err) {
|
|
122
|
+
props.onNotice(errorMessage(err), "error");
|
|
123
|
+
} finally {
|
|
124
|
+
setPendingId(null);
|
|
125
|
+
}
|
|
126
|
+
})();
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
Delete
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
</li>
|
|
133
|
+
))}
|
|
134
|
+
</ul>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ArrowUDownLeftIcon } from "@phosphor-icons/react/dist/csr/ArrowUDownLeft";
|
|
2
|
+
import { CaretDownIcon } from "@phosphor-icons/react/dist/csr/CaretDown";
|
|
3
|
+
import { CircleIcon } from "@phosphor-icons/react/dist/csr/Circle";
|
|
4
|
+
import { PencilSimpleIcon } from "@phosphor-icons/react/dist/csr/PencilSimple";
|
|
5
|
+
import { TrashIcon } from "@phosphor-icons/react/dist/csr/Trash";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { AttachmentThumbs } from "./ComposerAttach";
|
|
8
|
+
import type { QueuedMessage } from "./queue";
|
|
9
|
+
|
|
10
|
+
export function QueuePanel(
|
|
11
|
+
props: Readonly<{
|
|
12
|
+
queue: QueuedMessage[];
|
|
13
|
+
open: boolean;
|
|
14
|
+
editingId: string | null;
|
|
15
|
+
onToggle: () => void;
|
|
16
|
+
onEdit: (id: string | null) => void;
|
|
17
|
+
onChangeText: (id: string, text: string) => void;
|
|
18
|
+
onCommitText: (id: string, text: string) => void;
|
|
19
|
+
onSendNow: (id: string) => void;
|
|
20
|
+
onRemove: (id: string) => void;
|
|
21
|
+
}>,
|
|
22
|
+
): React.ReactElement {
|
|
23
|
+
const editRef = useRef<HTMLTextAreaElement>(null);
|
|
24
|
+
const count = props.queue.length;
|
|
25
|
+
const title = count === 1 ? "1 queued message" : `${count} queued messages`;
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (props.editingId) editRef.current?.focus();
|
|
28
|
+
}, [props.editingId]);
|
|
29
|
+
return (
|
|
30
|
+
<section className="desk-queue">
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
className="desk-queue__head"
|
|
34
|
+
aria-expanded={props.open}
|
|
35
|
+
onClick={props.onToggle}
|
|
36
|
+
>
|
|
37
|
+
<CaretDownIcon className="desk-queue__caret" size={12} weight="bold" aria-hidden="true" />
|
|
38
|
+
{title}
|
|
39
|
+
</button>
|
|
40
|
+
{props.open ? (
|
|
41
|
+
<ul className="desk-queue__list">
|
|
42
|
+
{props.queue.map((item) => {
|
|
43
|
+
const editing = props.editingId === item.id;
|
|
44
|
+
return (
|
|
45
|
+
<li key={item.id} className={`desk-queue-item${editing ? " is-editing" : ""}`}>
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
className="desk-queue__pick"
|
|
49
|
+
aria-label="Send now"
|
|
50
|
+
onClick={() => props.onSendNow(item.id)}
|
|
51
|
+
>
|
|
52
|
+
<CircleIcon size={16} weight="regular" aria-hidden="true" />
|
|
53
|
+
</button>
|
|
54
|
+
{editing ? (
|
|
55
|
+
<textarea
|
|
56
|
+
ref={editRef}
|
|
57
|
+
className="cel-input desk-compose-input desk-queue__input"
|
|
58
|
+
rows={2}
|
|
59
|
+
value={item.text}
|
|
60
|
+
aria-label="Edit queued message"
|
|
61
|
+
onChange={(event) => props.onChangeText(item.id, event.target.value)}
|
|
62
|
+
onKeyDown={(event) => {
|
|
63
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
props.onCommitText(item.id, item.text);
|
|
66
|
+
}
|
|
67
|
+
if (event.key === "Escape") {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
props.onEdit(null);
|
|
70
|
+
}
|
|
71
|
+
}}
|
|
72
|
+
onBlur={() => props.onCommitText(item.id, item.text)}
|
|
73
|
+
/>
|
|
74
|
+
) : (
|
|
75
|
+
<div className="desk-queue-copy">
|
|
76
|
+
<AttachmentThumbs items={item.attachments ?? []} />
|
|
77
|
+
{item.text ? (
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
className="desk-queue-text"
|
|
81
|
+
onClick={() => props.onEdit(item.id)}
|
|
82
|
+
>
|
|
83
|
+
{item.text}
|
|
84
|
+
</button>
|
|
85
|
+
) : null}
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
{editing ? null : (
|
|
89
|
+
<div className="desk-queue__actions">
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
className="desk-queue__act"
|
|
93
|
+
onClick={() => props.onSendNow(item.id)}
|
|
94
|
+
>
|
|
95
|
+
Send now
|
|
96
|
+
<ArrowUDownLeftIcon size={12} weight="bold" aria-hidden="true" />
|
|
97
|
+
</button>
|
|
98
|
+
<button
|
|
99
|
+
type="button"
|
|
100
|
+
className="desk-queue__icon"
|
|
101
|
+
aria-label="Edit queued message"
|
|
102
|
+
onClick={() => props.onEdit(item.id)}
|
|
103
|
+
>
|
|
104
|
+
<PencilSimpleIcon size={14} weight="regular" />
|
|
105
|
+
</button>
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
className="desk-queue__icon"
|
|
109
|
+
aria-label="Remove from queue"
|
|
110
|
+
onClick={() => props.onRemove(item.id)}
|
|
111
|
+
>
|
|
112
|
+
<TrashIcon size={14} weight="regular" />
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
</li>
|
|
117
|
+
);
|
|
118
|
+
})}
|
|
119
|
+
</ul>
|
|
120
|
+
) : null}
|
|
121
|
+
</section>
|
|
122
|
+
);
|
|
123
|
+
}
|