@koinzhang/paseo-plugin-inbox 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/README.md +20 -7
- package/client/changes.ts +69 -0
- package/client/default-selection.ts +13 -0
- package/client/inbox-surface.tsx +870 -333
- package/client/item-subtitle.ts +21 -0
- package/client/kind-filter-menu.tsx +145 -0
- package/client/kind-filter.ts +9 -0
- package/client/note-actions.ts +12 -0
- package/client/note-detail-styles.ts +13 -0
- package/client/note-row-actions.ts +11 -0
- package/client/workspace-panel.tsx +23 -5
- package/index.client.tsx +11 -4
- package/index.server.ts +19 -4
- package/package.json +5 -4
- package/paseo-plugin.json +2 -2
- package/server/agents.ts +5 -3
- package/server/changes.ts +67 -0
- package/server/handlers.ts +16 -8
- package/server/store.ts +57 -33
- package/shared/changes.ts +11 -0
- package/shared/contracts.ts +6 -5
- package/shared/filter-settings.ts +31 -23
- package/shared/item-title.ts +1 -1
- package/shared/note.ts +10 -0
- package/shared/slash-command.ts +2 -2
package/server/store.ts
CHANGED
|
@@ -14,7 +14,7 @@ type Database = InstanceType<SqliteModule["DatabaseSync"]>;
|
|
|
14
14
|
const SCHEMA = `
|
|
15
15
|
CREATE TABLE IF NOT EXISTS items (
|
|
16
16
|
id TEXT PRIMARY KEY,
|
|
17
|
-
kind TEXT NOT NULL CHECK (kind IN ('agent', 'note'
|
|
17
|
+
kind TEXT NOT NULL CHECK (kind IN ('agent', 'note')),
|
|
18
18
|
title TEXT,
|
|
19
19
|
body TEXT NOT NULL DEFAULT '',
|
|
20
20
|
project_key TEXT,
|
|
@@ -57,18 +57,19 @@ export interface WorkspaceRef {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export interface ListFilter {
|
|
60
|
-
|
|
60
|
+
kinds?: ItemKind[];
|
|
61
61
|
projectKey?: string;
|
|
62
|
+
projectKeys?: string[] | null;
|
|
62
63
|
query?: string;
|
|
63
64
|
/** Items tagged with exactly this workspace. */
|
|
64
65
|
workspaceId?: string;
|
|
66
|
+
workspaceIds?: string[] | null;
|
|
65
67
|
/** A workspace's Inbox: its workspace tag, or no workspace tag and its project tag. */
|
|
66
68
|
inboxOf?: { workspaceId: string; projectKey: string | null };
|
|
67
69
|
sort?: ItemSort;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
export interface NoteInput {
|
|
71
|
-
kind: "note" | "scratch";
|
|
72
73
|
title?: string | null;
|
|
73
74
|
body: string;
|
|
74
75
|
project?: ProjectRef | null;
|
|
@@ -137,8 +138,9 @@ function sortItems(items: Item[], sort: ItemSort): Item[] {
|
|
|
137
138
|
export class InboxStore {
|
|
138
139
|
private readonly db: Database;
|
|
139
140
|
private readonly now: () => string;
|
|
141
|
+
private readonly onChange: () => void;
|
|
140
142
|
|
|
141
|
-
constructor(options: { dir?: string; now?: () => string } = {}) {
|
|
143
|
+
constructor(options: { dir?: string; now?: () => string; onChange?: () => void } = {}) {
|
|
142
144
|
const dir = options.dir ?? defaultDataDir();
|
|
143
145
|
mkdirSync(dir, { recursive: true });
|
|
144
146
|
const sqlite = loadSqlite();
|
|
@@ -148,10 +150,12 @@ export class InboxStore {
|
|
|
148
150
|
this.migrate();
|
|
149
151
|
this.db.exec(WORKSPACE_INDEX);
|
|
150
152
|
this.now = options.now ?? (() => new Date().toISOString());
|
|
153
|
+
this.onChange = options.onChange ?? (() => {});
|
|
151
154
|
this.deleteEmptyNotes();
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
private migrate(): void {
|
|
158
|
+
this.db.exec("UPDATE items SET kind = 'note' WHERE kind = 'scratch'");
|
|
155
159
|
const columns = this.db.prepare("PRAGMA table_info(items)").all() as Array<{ name: string }>;
|
|
156
160
|
if (!columns.some((column) => column.name === "workspace_id")) {
|
|
157
161
|
this.db.exec("ALTER TABLE items ADD COLUMN workspace_id TEXT");
|
|
@@ -166,15 +170,17 @@ export class InboxStore {
|
|
|
166
170
|
);
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
/** Drops notes
|
|
173
|
+
/** Drops notes with no title or text, e.g. left behind by an interrupted editor. */
|
|
170
174
|
deleteEmptyNotes(): number {
|
|
171
175
|
const result = this.db
|
|
172
176
|
.prepare(
|
|
173
|
-
`DELETE FROM items WHERE kind
|
|
177
|
+
`DELETE FROM items WHERE kind = 'note'
|
|
174
178
|
AND trim(coalesce(title, '')) = '' AND trim(body) = ''`,
|
|
175
179
|
)
|
|
176
180
|
.run();
|
|
177
|
-
|
|
181
|
+
const changes = Number(result.changes);
|
|
182
|
+
if (changes > 0) this.onChange();
|
|
183
|
+
return changes;
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
close(): void {
|
|
@@ -196,15 +202,24 @@ export class InboxStore {
|
|
|
196
202
|
list(filter: ListFilter = {}): Item[] {
|
|
197
203
|
const where: string[] = [];
|
|
198
204
|
const params: string[] = [];
|
|
199
|
-
if (filter.
|
|
200
|
-
|
|
201
|
-
|
|
205
|
+
if (filter.kinds) {
|
|
206
|
+
if (filter.kinds.length === 0) return [];
|
|
207
|
+
where.push(`kind IN (${filter.kinds.map(() => "?").join(", ")})`);
|
|
208
|
+
params.push(...filter.kinds);
|
|
202
209
|
}
|
|
203
|
-
|
|
210
|
+
const projectKeys = [...new Set([...(filter.projectKeys ?? []), ...(filter.projectKey ? [filter.projectKey] : [])])];
|
|
211
|
+
if (filter.projectKeys && filter.projectKeys.length > 0) {
|
|
212
|
+
where.push(`(project_key IN (${projectKeys.map(() => "?").join(", ")}) OR project_key IS NULL)`);
|
|
213
|
+
params.push(...projectKeys);
|
|
214
|
+
} else if (filter.projectKey) {
|
|
204
215
|
where.push("project_key = ?");
|
|
205
216
|
params.push(filter.projectKey);
|
|
206
217
|
}
|
|
207
|
-
|
|
218
|
+
const workspaceIds = [...new Set([...(filter.workspaceIds ?? []), ...(filter.workspaceId ? [filter.workspaceId] : [])])];
|
|
219
|
+
if (filter.workspaceIds && filter.workspaceIds.length > 0) {
|
|
220
|
+
where.push(`(workspace_id IN (${workspaceIds.map(() => "?").join(", ")}) OR workspace_id IS NULL)`);
|
|
221
|
+
params.push(...workspaceIds);
|
|
222
|
+
} else if (filter.workspaceId) {
|
|
208
223
|
where.push("workspace_id = ?");
|
|
209
224
|
params.push(filter.workspaceId);
|
|
210
225
|
}
|
|
@@ -232,39 +247,45 @@ export class InboxStore {
|
|
|
232
247
|
return sortItems(items, filter.sort ?? "updated");
|
|
233
248
|
}
|
|
234
249
|
|
|
235
|
-
projects(
|
|
250
|
+
projects(kinds?: ItemKind[]): Array<{ key: string; label: string; count: number }> {
|
|
236
251
|
const rows = this.db
|
|
237
252
|
.prepare(
|
|
238
253
|
`SELECT project_key AS key, MAX(project_label) AS label, COUNT(*) AS count
|
|
239
|
-
FROM items WHERE project_key IS NOT NULL ${
|
|
254
|
+
FROM items WHERE project_key IS NOT NULL ${kinds ? `AND kind IN (${kinds.map(() => "?").join(", ")})` : ""}
|
|
240
255
|
GROUP BY project_key ORDER BY MAX(updated_at) DESC`,
|
|
241
256
|
)
|
|
242
|
-
.all(...(
|
|
257
|
+
.all(...(kinds ?? [])) as Array<{ key: string; label: string | null; count: number }>;
|
|
243
258
|
return rows.map((row) => ({ key: row.key, label: row.label ?? row.key, count: Number(row.count) }));
|
|
244
259
|
}
|
|
245
260
|
|
|
246
261
|
/** Item counts per workspace tag, most recently updated first. */
|
|
247
|
-
workspaces(
|
|
262
|
+
workspaces(kinds?: ItemKind[]): Array<{ id: string; label: string; count: number }> {
|
|
248
263
|
const rows = this.db
|
|
249
264
|
.prepare(
|
|
250
265
|
`SELECT workspace_id AS id, MAX(workspace_label) AS label, COUNT(*) AS count
|
|
251
|
-
FROM items WHERE workspace_id IS NOT NULL ${
|
|
266
|
+
FROM items WHERE workspace_id IS NOT NULL ${kinds ? `AND kind IN (${kinds.map(() => "?").join(", ")})` : ""}
|
|
252
267
|
GROUP BY workspace_id ORDER BY MAX(updated_at) DESC`,
|
|
253
268
|
)
|
|
254
|
-
.all(...(
|
|
269
|
+
.all(...(kinds ?? [])) as Array<{ id: string; label: string | null; count: number }>;
|
|
255
270
|
return rows.map((row) => ({ id: row.id, label: row.label ?? row.id, count: Number(row.count) }));
|
|
256
271
|
}
|
|
257
272
|
|
|
258
273
|
/** Writes current names of active projects / workspaces into the snapshots. */
|
|
259
274
|
refreshLabels(projects: ReadonlyMap<string, string>, workspaces: ReadonlyMap<string, string>): void {
|
|
275
|
+
let changed = false;
|
|
260
276
|
const project = this.db.prepare(
|
|
261
277
|
"UPDATE items SET project_label = ? WHERE project_key = ? AND project_label IS NOT ?",
|
|
262
278
|
);
|
|
263
|
-
for (const [key, label] of projects)
|
|
279
|
+
for (const [key, label] of projects) {
|
|
280
|
+
if (Number(project.run(label, key, label).changes) > 0) changed = true;
|
|
281
|
+
}
|
|
264
282
|
const workspace = this.db.prepare(
|
|
265
283
|
"UPDATE items SET workspace_label = ? WHERE workspace_id = ? AND workspace_label IS NOT ?",
|
|
266
284
|
);
|
|
267
|
-
for (const [id, label] of workspaces)
|
|
285
|
+
for (const [id, label] of workspaces) {
|
|
286
|
+
if (Number(workspace.run(label, id, label).changes) > 0) changed = true;
|
|
287
|
+
}
|
|
288
|
+
if (changed) this.onChange();
|
|
268
289
|
}
|
|
269
290
|
|
|
270
291
|
/** Writes current agent titles into starred agents; true when any title changed. */
|
|
@@ -278,6 +299,7 @@ export class InboxStore {
|
|
|
278
299
|
for (const [agentId, title] of titles) {
|
|
279
300
|
if (Number(update.run(title, title, agentId, title).changes) > 0) changed = true;
|
|
280
301
|
}
|
|
302
|
+
if (changed) this.onChange();
|
|
281
303
|
return changed;
|
|
282
304
|
}
|
|
283
305
|
|
|
@@ -293,7 +315,7 @@ export class InboxStore {
|
|
|
293
315
|
)
|
|
294
316
|
.run(
|
|
295
317
|
id,
|
|
296
|
-
|
|
318
|
+
"note",
|
|
297
319
|
input.title ?? null,
|
|
298
320
|
input.body,
|
|
299
321
|
input.project?.key ?? null,
|
|
@@ -303,15 +325,19 @@ export class InboxStore {
|
|
|
303
325
|
now,
|
|
304
326
|
now,
|
|
305
327
|
);
|
|
328
|
+
this.onChange();
|
|
306
329
|
return this.require(id);
|
|
307
330
|
}
|
|
308
331
|
|
|
309
|
-
updateNote(id: string, patch: {
|
|
332
|
+
updateNote(id: string, patch: { title?: string | null; body: string }): Item {
|
|
310
333
|
const existing = this.require(id);
|
|
311
334
|
if (existing.kind === "agent") throw new Error("Starred agents have no editable note body");
|
|
335
|
+
const title = patch.title === undefined ? existing.title : patch.title;
|
|
336
|
+
if (existing.title === title && existing.body === patch.body) return existing;
|
|
312
337
|
this.db
|
|
313
338
|
.prepare("UPDATE items SET kind = ?, title = ?, body = ?, updated_at = ? WHERE id = ?")
|
|
314
|
-
.run(
|
|
339
|
+
.run("note", title, patch.body, this.now(), id);
|
|
340
|
+
this.onChange();
|
|
315
341
|
return this.require(id);
|
|
316
342
|
}
|
|
317
343
|
|
|
@@ -321,7 +347,7 @@ export class InboxStore {
|
|
|
321
347
|
if (tags.workspace && !tags.project) throw new Error("A workspace tag needs its project");
|
|
322
348
|
this.db
|
|
323
349
|
.prepare(
|
|
324
|
-
`UPDATE items SET project_key = ?, project_label = ?, workspace_id = ?, workspace_label =
|
|
350
|
+
`UPDATE items SET project_key = ?, project_label = ?, workspace_id = ?, workspace_label = ?
|
|
325
351
|
WHERE id = ?`,
|
|
326
352
|
)
|
|
327
353
|
.run(
|
|
@@ -329,25 +355,21 @@ export class InboxStore {
|
|
|
329
355
|
tags.project?.label ?? null,
|
|
330
356
|
tags.workspace?.id ?? null,
|
|
331
357
|
tags.workspace?.label ?? null,
|
|
332
|
-
this.now(),
|
|
333
358
|
id,
|
|
334
359
|
);
|
|
360
|
+
this.onChange();
|
|
335
361
|
return this.require(id);
|
|
336
362
|
}
|
|
337
363
|
|
|
338
|
-
update(id: string, patch: { pinned?: boolean
|
|
364
|
+
update(id: string, patch: { pinned?: boolean }): Item {
|
|
339
365
|
const existing = this.require(id);
|
|
340
|
-
if (patch.kind && existing.kind !== "scratch") {
|
|
341
|
-
throw new Error("Only scratch items can be promoted to notes");
|
|
342
|
-
}
|
|
343
366
|
this.db
|
|
344
|
-
.prepare("UPDATE items SET pinned =
|
|
367
|
+
.prepare("UPDATE items SET pinned = ? WHERE id = ?")
|
|
345
368
|
.run(
|
|
346
369
|
patch.pinned === undefined ? (existing.pinned ? 1 : 0) : patch.pinned ? 1 : 0,
|
|
347
|
-
patch.kind ?? existing.kind,
|
|
348
|
-
this.now(),
|
|
349
370
|
id,
|
|
350
371
|
);
|
|
372
|
+
this.onChange();
|
|
351
373
|
return this.require(id);
|
|
352
374
|
}
|
|
353
375
|
|
|
@@ -379,11 +401,13 @@ export class InboxStore {
|
|
|
379
401
|
now,
|
|
380
402
|
now,
|
|
381
403
|
);
|
|
404
|
+
this.onChange();
|
|
382
405
|
return { item: this.require(id), created: true };
|
|
383
406
|
}
|
|
384
407
|
|
|
385
408
|
delete(id: string): void {
|
|
386
|
-
this.db.prepare("DELETE FROM items WHERE id = ?").run(id);
|
|
409
|
+
const result = this.db.prepare("DELETE FROM items WHERE id = ?").run(id);
|
|
410
|
+
if (Number(result.changes) > 0) this.onChange();
|
|
387
411
|
}
|
|
388
412
|
|
|
389
413
|
private require(id: string): Item {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineSubscription } from "@getpaseo/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const InboxChange = z.object({ type: z.literal("invalidate") }).strict();
|
|
5
|
+
export type InboxChange = z.infer<typeof InboxChange>;
|
|
6
|
+
|
|
7
|
+
export const itemsChanged = defineSubscription({
|
|
8
|
+
name: "items.changes",
|
|
9
|
+
input: z.object({}),
|
|
10
|
+
event: InboxChange,
|
|
11
|
+
});
|
package/shared/contracts.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineRpc } from "@getpaseo/plugin";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
export const ItemKind = z.enum(["agent", "note"
|
|
4
|
+
export const ItemKind = z.enum(["agent", "note"]);
|
|
5
5
|
export type ItemKind = z.infer<typeof ItemKind>;
|
|
6
6
|
|
|
7
7
|
export const AgentSnapshot = z.object({
|
|
@@ -63,11 +63,13 @@ export type AgentState = z.infer<typeof AgentState>;
|
|
|
63
63
|
export const listItems = defineRpc({
|
|
64
64
|
name: "items.list",
|
|
65
65
|
input: z.object({
|
|
66
|
-
|
|
66
|
+
kinds: z.array(ItemKind).optional(),
|
|
67
67
|
projectKey: z.string().optional(),
|
|
68
|
+
projectKeys: z.array(z.string()).nullable().optional(),
|
|
68
69
|
query: z.string().optional(),
|
|
69
70
|
/** Items tagged with exactly this workspace. */
|
|
70
71
|
workspaceId: z.string().optional(),
|
|
72
|
+
workspaceIds: z.array(z.string()).nullable().optional(),
|
|
71
73
|
/**
|
|
72
74
|
* A workspace's Inbox: items tagged with this workspace, plus items tagged
|
|
73
75
|
* only with its project.
|
|
@@ -90,7 +92,6 @@ export const saveNote = defineRpc({
|
|
|
90
92
|
name: "items.save",
|
|
91
93
|
input: z.object({
|
|
92
94
|
id: z.string().optional(),
|
|
93
|
-
kind: z.enum(["note", "scratch"]),
|
|
94
95
|
title: z.string().nullable().optional(),
|
|
95
96
|
body: z.string(),
|
|
96
97
|
/** On create: tag this workspace and its project. */
|
|
@@ -133,8 +134,6 @@ export const updateItem = defineRpc({
|
|
|
133
134
|
input: z.object({
|
|
134
135
|
id: z.string(),
|
|
135
136
|
pinned: z.boolean().optional(),
|
|
136
|
-
/** Only `note` is accepted: promotes a scratch entry. */
|
|
137
|
-
kind: z.literal("note").optional(),
|
|
138
137
|
}),
|
|
139
138
|
output: z.object({ item: Item }),
|
|
140
139
|
});
|
|
@@ -180,6 +179,8 @@ export const agentStates = defineRpc({
|
|
|
180
179
|
states: z.record(z.string(), AgentState),
|
|
181
180
|
/** Only agents the host still knows. */
|
|
182
181
|
live: z.record(z.string(), AgentLive).optional(),
|
|
182
|
+
/** Host update timestamps; absent when the agent is missing. */
|
|
183
|
+
lastActivityAt: z.record(z.string(), z.string()).optional(),
|
|
183
184
|
/** A starred agent was renamed on the host and the stored title updated; the list is stale. */
|
|
184
185
|
titlesChanged: z.boolean().optional(),
|
|
185
186
|
}),
|
|
@@ -2,26 +2,34 @@ import { defineSettings } from "@getpaseo/plugin";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { ItemSort } from "./contracts.ts";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const FilterKinds = z.array(z.enum(["agent", "note"]));
|
|
6
6
|
|
|
7
7
|
/** Older documents have no `sort`; the schema default fills it in. */
|
|
8
8
|
export function migrateInboxFilters(values: unknown, fromVersion: number): unknown {
|
|
9
|
-
if (
|
|
10
|
-
|
|
9
|
+
if (!values || typeof values !== "object" || Array.isArray(values)) return values;
|
|
10
|
+
const filters = values as Record<string, unknown>;
|
|
11
|
+
if (fromVersion >= 5) return { ...filters, projectKeys: [], workspaceIds: [] };
|
|
12
|
+
const migrateKind = (kind: unknown) => Array.isArray(kind) ? kind : kind === "agent" || kind === "note" ? [kind] : ["agent", "note"];
|
|
13
|
+
const selected = (value: unknown) => typeof value === "string" ? [value] : [];
|
|
14
|
+
return {
|
|
15
|
+
...("sort" in filters ? { sort: filters.sort } : {}),
|
|
16
|
+
kinds: migrateKind(filters.kind ?? filters.kinds),
|
|
17
|
+
panelKinds: migrateKind(filters.panelKind ?? filters.panelKinds),
|
|
18
|
+
projectKeys: selected(filters.projectKey),
|
|
19
|
+
workspaceIds: selected(filters.workspaceId),
|
|
20
|
+
};
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
/** Host-scoped Inbox filters. The global page and the Explorer panel each keep their own group. */
|
|
14
24
|
export const inboxFilterSettings = defineSettings({
|
|
15
25
|
id: "list-filters",
|
|
16
26
|
scope: "host",
|
|
17
|
-
version:
|
|
27
|
+
version: 7,
|
|
18
28
|
schema: z.object({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
workspaceId: z.string().nullable().default(null),
|
|
24
|
-
panelKind: FilterKind.default("all"),
|
|
29
|
+
kinds: FilterKinds.default(["agent", "note"]),
|
|
30
|
+
projectKeys: z.array(z.string()).default([]),
|
|
31
|
+
workspaceIds: z.array(z.string()).default([]),
|
|
32
|
+
panelKinds: FilterKinds.default(["agent", "note"]),
|
|
25
33
|
/** Global page sort. The Explorer panel always lists by last update. */
|
|
26
34
|
sort: ItemSort.default("updated"),
|
|
27
35
|
}),
|
|
@@ -31,19 +39,19 @@ export const inboxFilterSettings = defineSettings({
|
|
|
31
39
|
export type InboxFilters = z.infer<typeof inboxFilterSettings.schema>;
|
|
32
40
|
|
|
33
41
|
export const INBOX_FILTER_DEFAULTS: InboxFilters = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
kinds: ["agent", "note"],
|
|
43
|
+
projectKeys: [],
|
|
44
|
+
workspaceIds: [],
|
|
45
|
+
panelKinds: ["agent", "note"],
|
|
38
46
|
sort: "updated",
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
export function sameInboxFilters(a: InboxFilters, b: InboxFilters): boolean {
|
|
42
50
|
return (
|
|
43
|
-
a.
|
|
44
|
-
a.
|
|
45
|
-
a.
|
|
46
|
-
a.
|
|
51
|
+
a.kinds.length === b.kinds.length && a.kinds.every((kind, index) => kind === b.kinds[index]) &&
|
|
52
|
+
JSON.stringify(a.projectKeys) === JSON.stringify(b.projectKeys) &&
|
|
53
|
+
JSON.stringify(a.workspaceIds) === JSON.stringify(b.workspaceIds) &&
|
|
54
|
+
a.panelKinds.length === b.panelKinds.length && a.panelKinds.every((kind, index) => kind === b.panelKinds[index]) &&
|
|
47
55
|
a.sort === b.sort
|
|
48
56
|
);
|
|
49
57
|
}
|
|
@@ -54,9 +62,9 @@ export function inboxListSort(filters: InboxFilters, surface: { workspaceId?: st
|
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
export interface VisibleInboxFilters {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
kinds: InboxFilters["kinds"];
|
|
66
|
+
projectKeys: string[] | null;
|
|
67
|
+
workspaceIds: string[];
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
/**
|
|
@@ -68,7 +76,7 @@ export function visibleInboxFilters(
|
|
|
68
76
|
surface: { workspaceId?: string },
|
|
69
77
|
): VisibleInboxFilters {
|
|
70
78
|
if (surface.workspaceId) {
|
|
71
|
-
return {
|
|
79
|
+
return { kinds: filters.panelKinds, projectKeys: null, workspaceIds: [surface.workspaceId] };
|
|
72
80
|
}
|
|
73
|
-
return {
|
|
81
|
+
return { kinds: filters.kinds, projectKeys: filters.projectKeys, workspaceIds: filters.workspaceIds };
|
|
74
82
|
}
|
package/shared/item-title.ts
CHANGED
|
@@ -4,5 +4,5 @@ export function itemTitle(item: Item): string {
|
|
|
4
4
|
if (item.kind === "agent") return item.agentSnapshot?.title || item.title || "Untitled agent";
|
|
5
5
|
if (item.title) return item.title;
|
|
6
6
|
const firstLine = item.body.split("\n").find((line) => line.trim());
|
|
7
|
-
return firstLine?.trim() ||
|
|
7
|
+
return firstLine?.trim() || "Untitled note";
|
|
8
8
|
}
|
package/shared/note.ts
CHANGED
|
@@ -2,3 +2,13 @@
|
|
|
2
2
|
export function isEmptyNote(title: string | null | undefined, body: string): boolean {
|
|
3
3
|
return !title?.trim() && !body.trim();
|
|
4
4
|
}
|
|
5
|
+
|
|
6
|
+
export interface NoteText {
|
|
7
|
+
title: string;
|
|
8
|
+
body: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function syncNoteText(current: NoteText, saved: NoteText, incoming: NoteText): NoteText | null {
|
|
12
|
+
if (current.title !== saved.title || current.body !== saved.body) return null;
|
|
13
|
+
return incoming;
|
|
14
|
+
}
|
package/shared/slash-command.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface InboxCommand {
|
|
2
|
-
/** Empty: star the current agent; otherwise save as
|
|
2
|
+
/** Empty: star the current agent; otherwise save as a note. */
|
|
3
3
|
text: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
/** The whole argument is
|
|
6
|
+
/** The whole argument is note text as typed; there are no options. */
|
|
7
7
|
export function parseInboxCommand(args: string): InboxCommand {
|
|
8
8
|
return { text: args.trim() };
|
|
9
9
|
}
|