deep-projects 0.0.0-stage → 0.4.1

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/lib/client.js ADDED
@@ -0,0 +1,1597 @@
1
+ // deep-projects client bundle (esbuild CJS + __ModuleLoader__ banner). Do not edit.
2
+ window.__ModuleLoader__.load({id:"deep-projects",factory:Pt=>{
3
+ var module={exports:{}},exports=module.exports,require=Pt;
4
+ "use strict";
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+
23
+ // src/client/index.tsx
24
+ var index_exports = {};
25
+ __export(index_exports, {
26
+ PANEL_ID: () => PANEL_ID,
27
+ apply: () => apply,
28
+ inject: () => inject
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+ var import_react = require("react");
32
+ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
33
+
34
+ // src/locales.ts
35
+ var en = {
36
+ "nav": "Projects",
37
+ "tab.title": "Projects",
38
+ "tab.project": "Project",
39
+ "tab.project.hint": "Memories, instructions, and knowledge for this project \u2014 the agent loads them in every chat that opens here.",
40
+ "header.open": "Project info",
41
+ "tree.title": "Projects",
42
+ "tree.search": "Filter projects\u2026",
43
+ "tree.collapse": "Collapse",
44
+ "tree.expand": "Expand",
45
+ "tree.pin": "Pin in sidebar (built-in panel pin)",
46
+ "memory.title": "Memory",
47
+ "memory.hint": "Loaded into every chat in this project. Agents add and update entries as they learn; you can edit them too.",
48
+ "memory.edit": "Edit",
49
+ "memory.placeholder.edit": "- One memory per line",
50
+ "knowledge.drop": "Drop files here, or click to upload",
51
+ "menu.more": "More",
52
+ "menu.open": "Open project",
53
+ "menu.edit": "Edit name & description",
54
+ "menu.archive": "Archive",
55
+ "menu.unarchive": "Restore from archive",
56
+ "tree.archived": "Archived",
57
+ "detail.archived": "Archived",
58
+ "goal.title": "Goal",
59
+ "goal.placeholder": "What is this project for? What does done look like?",
60
+ "goal.empty": "Set a goal. Every chat in this project will see it.",
61
+ "note.title": "Quick memory",
62
+ "note.hint": "One line the agent will remember for this project \u2014 saved as a dated bullet in notes.md (inside the project folder).",
63
+ "note.placeholder": "e.g. The production database is read-only; never write to it from here.",
64
+ "note.add": "Add",
65
+ "note.added": "Saved.",
66
+ "note.error": "Could not save the note.",
67
+ "note.empty": "No memories yet.",
68
+ "note.view": "notes.md",
69
+ "note.collapse": "Hide notes",
70
+ "empty.title": "No projects yet",
71
+ "empty.hint": "Create a project to group chats, instructions, and knowledge files under one workspace.",
72
+ "create.title": "New project",
73
+ "create.name": "Name",
74
+ "create.name.placeholder": "My project",
75
+ "create.description": "Description (optional)",
76
+ "create.description.placeholder": "What is this project about?",
77
+ "create.submit": "Create",
78
+ "create.cancel": "Cancel",
79
+ "create.invalid": "Name must be 1-60 characters (letters, numbers, - _).",
80
+ "create.exists": "A project with this name already exists.",
81
+ "create.error": "Could not create the project.",
82
+ "detail.back": "All projects",
83
+ "detail.open": "Open chat",
84
+ "detail.newChat": "New chat",
85
+ "detail.star": "Pin to sidebar",
86
+ "detail.unstar": "Unpin",
87
+ "row.pin": "Pin in sidebar",
88
+ "row.unpin": "Unpin from sidebar",
89
+ "row.newChat": "New chat in this project",
90
+ "detail.delete": "Delete project",
91
+ "detail.delete.confirm": "This deletes the project folder (instructions, knowledge files) and its metadata. Sessions are kept. Continue?",
92
+ "section.instructions": "Custom instructions",
93
+ "instructions.hint": "Stored in AGENTS.md in the project folder. The agent loads it automatically in every chat that opens here.",
94
+ "instructions.save": "Save",
95
+ "instructions.saved": "Saved.",
96
+ "instructions.error": "Could not save instructions.",
97
+ "instructions.placeholder": "# Project instructions\n\nDescribe the project, conventions, and anything the agent should always know\u2026",
98
+ "section.knowledge": "Knowledge files",
99
+ "knowledge.hint": "Files the agent can read in this project (docs, specs, references).",
100
+ "knowledge.upload": "Upload files",
101
+ "knowledge.empty": "No knowledge files yet.",
102
+ "knowledge.delete": "Delete",
103
+ "knowledge.error": "Upload failed.",
104
+ "section.sessions": "Chats in this project",
105
+ "sessions.empty": "No chats yet. Start one with \u201CNew chat\u201D.",
106
+ "sessions.new": "New chat",
107
+ "session.none.title": "Untitled",
108
+ "loading": "Loading\u2026",
109
+ "error.generic": "Something went wrong.",
110
+ "retry": "Retry",
111
+ "path.label": "Folder",
112
+ "created.label": "Created",
113
+ "chats.label": "chats",
114
+ "files.label": "files"
115
+ };
116
+ var zh = {
117
+ "nav": "\u9879\u76EE",
118
+ "goal.title": "\u76EE\u6807",
119
+ "goal.placeholder": "\u8FD9\u4E2A\u9879\u76EE\u662F\u505A\u4EC0\u4E48\u7684\uFF1F\u600E\u6837\u7B97\u5B8C\u6210\uFF1F",
120
+ "goal.empty": "\u8BBE\u7F6E\u76EE\u6807\uFF0C\u672C\u9879\u76EE\u7684\u6BCF\u4E2A\u5BF9\u8BDD\u90FD\u80FD\u770B\u5230\u3002",
121
+ "menu.archive": "\u5F52\u6863",
122
+ "menu.unarchive": "\u4ECE\u5F52\u6863\u6062\u590D",
123
+ "tree.archived": "\u5DF2\u5F52\u6863",
124
+ "detail.archived": "\u5DF2\u5F52\u6863",
125
+ "menu.more": "\u66F4\u591A",
126
+ "menu.open": "\u6253\u5F00\u9879\u76EE",
127
+ "menu.edit": "\u7F16\u8F91\u540D\u79F0\u548C\u63CF\u8FF0",
128
+ "memory.title": "\u8BB0\u5FC6",
129
+ "memory.hint": "\u4F1A\u8F7D\u5165\u672C\u9879\u76EE\u7684\u6BCF\u4E2A\u5BF9\u8BDD\u3002\u667A\u80FD\u4F53\u5728\u5B66\u5230\u65B0\u4FE1\u606F\u65F6\u4F1A\u6DFB\u52A0\u548C\u66F4\u65B0\u6761\u76EE\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u7F16\u8F91\u3002",
130
+ "memory.edit": "\u7F16\u8F91",
131
+ "memory.placeholder.edit": "- \u6BCF\u884C\u4E00\u6761\u8BB0\u5FC6",
132
+ "knowledge.drop": "\u62D6\u653E\u6587\u4EF6\u5230\u6B64\u5904\uFF0C\u6216\u70B9\u51FB\u4E0A\u4F20",
133
+ "tab.title": "\u9879\u76EE",
134
+ "tab.project": "\u9879\u76EE",
135
+ "tab.project.hint": "\u672C\u9879\u76EE\u7684\u8BB0\u5FC6\u3001\u6307\u4EE4\u4E0E\u77E5\u8BC6\u6587\u4EF6\u2014\u2014\u5728\u6B64\u6253\u5F00\u7684\u6BCF\u6B21\u804A\u5929\u90FD\u4F1A\u81EA\u52A8\u52A0\u8F7D\u3002",
136
+ "header.open": "\u9879\u76EE\u4FE1\u606F",
137
+ "empty.title": "\u8FD8\u6CA1\u6709\u9879\u76EE",
138
+ "empty.hint": "\u521B\u5EFA\u4E00\u4E2A\u9879\u76EE\uFF0C\u628A\u804A\u5929\u3001\u6307\u4EE4\u548C\u77E5\u8BC6\u6587\u4EF6\u5F52\u5230\u540C\u4E00\u4E2A\u5DE5\u4F5C\u533A\u3002",
139
+ "create.title": "\u65B0\u5EFA\u9879\u76EE",
140
+ "create.name": "\u540D\u79F0",
141
+ "create.name.placeholder": "\u6211\u7684\u9879\u76EE",
142
+ "create.description": "\u63CF\u8FF0\uFF08\u53EF\u9009\uFF09",
143
+ "create.description.placeholder": "\u8FD9\u4E2A\u9879\u76EE\u662F\u505A\u4EC0\u4E48\u7684\uFF1F",
144
+ "create.submit": "\u521B\u5EFA",
145
+ "create.cancel": "\u53D6\u6D88",
146
+ "create.invalid": "\u540D\u79F0\u9700\u4E3A 1-60 \u4E2A\u5B57\u7B26\uFF08\u5B57\u6BCD\u3001\u6570\u5B57\u3001- _\uFF09\u3002",
147
+ "create.exists": "\u5DF2\u5B58\u5728\u540C\u540D\u9879\u76EE\u3002",
148
+ "create.error": "\u65E0\u6CD5\u521B\u5EFA\u9879\u76EE\u3002",
149
+ "detail.back": "\u5168\u90E8\u9879\u76EE",
150
+ "detail.open": "\u6253\u5F00\u804A\u5929",
151
+ "detail.newChat": "\u65B0\u5EFA\u804A\u5929",
152
+ "detail.star": "\u56FA\u5B9A\u5230\u4FA7\u680F",
153
+ "detail.unstar": "\u53D6\u6D88\u56FA\u5B9A",
154
+ "row.pin": "\u56FA\u5B9A\u5728\u4FA7\u680F",
155
+ "row.unpin": "\u53D6\u6D88\u56FA\u5B9A",
156
+ "row.newChat": "\u5728\u6B64\u9879\u76EE\u65B0\u5EFA\u804A\u5929",
157
+ "detail.delete": "\u5220\u9664\u9879\u76EE",
158
+ "detail.delete.confirm": "\u8FD9\u5C06\u5220\u9664\u9879\u76EE\u6587\u4EF6\u5939\uFF08\u6307\u4EE4\u3001\u77E5\u8BC6\u6587\u4EF6\uFF09\u53CA\u5176\u5143\u6570\u636E\uFF0C\u4F46\u4FDD\u7559\u4F1A\u8BDD\u3002\u7EE7\u7EED\uFF1F",
159
+ "section.instructions": "\u81EA\u5B9A\u4E49\u6307\u4EE4",
160
+ "instructions.hint": "\u5B58\u50A8\u5728\u9879\u76EE\u6587\u4EF6\u5939\u7684 AGENTS.md \u4E2D\u3002\u5728\u6B64\u6253\u5F00\u7684\u6BCF\u6B21\u804A\u5929\u90FD\u4F1A\u81EA\u52A8\u52A0\u8F7D\u3002",
161
+ "instructions.save": "\u4FDD\u5B58",
162
+ "instructions.saved": "\u5DF2\u4FDD\u5B58\u3002",
163
+ "instructions.error": "\u65E0\u6CD5\u4FDD\u5B58\u6307\u4EE4\u3002",
164
+ "instructions.placeholder": "# \u9879\u76EE\u6307\u4EE4\n\n\u63CF\u8FF0\u9879\u76EE\u3001\u7EA6\u5B9A\uFF0C\u4EE5\u53CA\u4EE3\u7406\u5E94\u59CB\u7EC8\u77E5\u9053\u7684\u5185\u5BB9\u2026",
165
+ "section.knowledge": "\u77E5\u8BC6\u6587\u4EF6",
166
+ "knowledge.hint": "\u4EE3\u7406\u5728\u672C\u9879\u76EE\u4E2D\u53EF\u8BFB\u53D6\u7684\u6587\u4EF6\uFF08\u6587\u6863\u3001\u89C4\u683C\u3001\u53C2\u8003\u8D44\u6599\uFF09\u3002",
167
+ "knowledge.upload": "\u4E0A\u4F20\u6587\u4EF6",
168
+ "knowledge.empty": "\u8FD8\u6CA1\u6709\u77E5\u8BC6\u6587\u4EF6\u3002",
169
+ "knowledge.delete": "\u5220\u9664",
170
+ "knowledge.error": "\u4E0A\u4F20\u5931\u8D25\u3002",
171
+ "section.sessions": "\u672C\u9879\u76EE\u7684\u804A\u5929",
172
+ "sessions.empty": "\u8FD8\u6CA1\u6709\u804A\u5929\u3002\u7528\u300C\u65B0\u5EFA\u804A\u5929\u300D\u5F00\u59CB\u3002",
173
+ "sessions.new": "\u65B0\u5EFA\u804A\u5929",
174
+ "session.none.title": "\u672A\u547D\u540D",
175
+ "loading": "\u52A0\u8F7D\u4E2D\u2026",
176
+ "error.generic": "\u51FA\u9519\u4E86\u3002",
177
+ "retry": "\u91CD\u8BD5",
178
+ "path.label": "\u6587\u4EF6\u5939",
179
+ "created.label": "\u521B\u5EFA\u4E8E",
180
+ "chats.label": "\u4E2A\u804A\u5929",
181
+ "files.label": "\u4E2A\u6587\u4EF6"
182
+ };
183
+
184
+ // src/client/index.tsx
185
+ var import_jsx_runtime = require("react/jsx-runtime");
186
+ var PANEL_ID = "dsh-projects";
187
+ var TAB_ID = "dsh-projects";
188
+ var inject = ["slots", "locale", "layout", "sessions", "sidebarRight", "sidebarRightTabs", "contextMenus"];
189
+ var appCtx = null;
190
+ var STYLE_ID = "dshpx-styles";
191
+ var CSS = `
192
+ .dshpx-root {
193
+ --dshpx-line: color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);
194
+ --dshpx-fill: var(--dsw-alias-bg-skeleton);
195
+ --dshpx-hover: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-skeleton));
196
+ font-family: inherit; color: var(--dsw-alias-label-primary);
197
+ }
198
+ .dshpx-side, .dshpx-tabpane { --dshpx-line: color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);
199
+ --dshpx-fill: var(--dsw-alias-bg-skeleton); --dshpx-hover: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-skeleton)); }
200
+ .dshpx-split { display: flex; width: 100%; height: 100%; min-height: 0; }
201
+ .dshpx-root svg, .dshpx-side svg, .dshpx-tabpane svg, .dshpx-header-btn svg { fill: currentColor; }
202
+ .dshpx-root button, .dshpx-tabpane button { font-family: inherit; }
203
+
204
+ /* ---- left: project tree ---- */
205
+ .dshpx-tree {
206
+ width: 280px; min-width: 240px; flex: none; box-sizing: border-box;
207
+ border-right: 1px solid var(--dshpx-line);
208
+ display: flex; flex-direction: column; gap: 12px; padding: 16px 12px; overflow-y: auto;
209
+ }
210
+ .dshpx-tree-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
211
+ .dshpx-tree-title { font-size: 15px; font-weight: 600; color: var(--dsw-alias-label-primary); }
212
+ .dshpx-search {
213
+ display: flex; align-items: center; gap: 8px; padding: 7px 12px;
214
+ background: var(--dshpx-fill); border: 1px solid transparent; border-radius: 10px;
215
+ color: var(--dsw-alias-label-caption); transition: border-color 120ms ease;
216
+ }
217
+ .dshpx-search:focus-within { border-color: var(--dshpx-line); }
218
+ .dshpx-search input {
219
+ flex: 1; min-width: 0; border: none; outline: none; background: transparent;
220
+ font-size: 13px; color: var(--dsw-alias-label-primary); font-family: inherit;
221
+ }
222
+ .dshpx-search input::placeholder { color: var(--dsw-alias-label-caption); }
223
+
224
+ .dshpx-list { display: flex; flex-direction: column; gap: 1px; }
225
+ .dshpx-row {
226
+ display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
227
+ padding: 7px 8px; border: none; border-radius: 8px; background: transparent;
228
+ cursor: pointer; font-size: 13.5px; color: var(--dsw-alias-label-primary); text-align: left;
229
+ font-family: inherit; transition: background 120ms ease;
230
+ }
231
+ .dshpx-row:hover { background: var(--dshpx-hover); }
232
+ .dshpx-row-active, .dshpx-row-active:hover { background: var(--dshpx-fill); font-weight: 550; }
233
+ .dshpx-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
234
+ .dshpx-row-actions { display: inline-flex; flex: none; gap: 2px; opacity: 0; transition: opacity 100ms ease; }
235
+ .dshpx-row:hover .dshpx-row-actions, .dshpx-row:focus-within .dshpx-row-actions { opacity: 1; }
236
+ .dshpx-icon-btn {
237
+ display: inline-flex; align-items: center; justify-content: center;
238
+ border: none; background: transparent; cursor: pointer; padding: 5px; border-radius: 6px;
239
+ color: var(--dsw-alias-label-caption); transition: background 120ms ease, color 120ms ease;
240
+ }
241
+ .dshpx-icon-btn:hover { background: var(--dshpx-hover); color: var(--dsw-alias-label-primary); }
242
+ .dshpx-icon-btn-danger:hover { color: var(--dsw-alias-state-error-primary); background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent); }
243
+ .dshpx-pin-on { color: var(--dsw-alias-label-primary); }
244
+ .dshpx-count {
245
+ flex: none; min-width: 18px; padding: 1px 7px; border-radius: 999px; text-align: center;
246
+ font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums;
247
+ color: var(--dsw-alias-label-caption); background: var(--dshpx-fill);
248
+ }
249
+ .dshpx-children { margin: 1px 0 4px 24px; display: flex; flex-direction: column; gap: 1px; }
250
+ .dshpx-child {
251
+ display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
252
+ padding: 5px 8px; border: none; border-radius: 6px; background: transparent; cursor: pointer;
253
+ font-size: 13px; color: var(--dsw-alias-label-secondary); text-align: left; font-family: inherit;
254
+ transition: background 120ms ease, color 120ms ease;
255
+ }
256
+ .dshpx-child:hover { background: var(--dshpx-hover); color: var(--dsw-alias-label-primary); }
257
+ .dshpx-child-dot { display: none; }
258
+ .dshpx-child-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
259
+ .dshpx-child-time { flex: none; font-size: 11px; color: var(--dsw-alias-label-caption); }
260
+ .dshpx-empty { font-size: 12.5px; padding: 4px 8px; color: var(--dsw-alias-label-caption); }
261
+ .dshpx-muted { margin: 0; color: var(--dsw-alias-label-caption); font-size: 13px; }
262
+ .dshpx-notice {
263
+ display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px;
264
+ border-radius: 10px; font-size: 13px; color: var(--dsw-alias-state-error-primary);
265
+ background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 8%, transparent);
266
+ }
267
+
268
+ /* ---- right: detail ---- */
269
+ .dshpx-detail { flex: 1; min-width: 0; overflow-y: auto; padding: 32px 40px; display: flex; justify-content: center; }
270
+ .dshpx-detail-inner { display: flex; flex-direction: column; gap: 20px; max-width: 920px; width: 100%; }
271
+ .dshpx-placeholder {
272
+ flex: 1; display: flex; flex-direction: column; gap: 8px;
273
+ align-items: center; justify-content: center; padding: 48px 24px; text-align: center;
274
+ }
275
+ .dshpx-h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; margin: 0; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }
276
+ .dshpx-h2 { font-size: 14px; font-weight: 600; margin: 0; color: var(--dsw-alias-label-primary); display: flex; align-items: center; gap: 8px; }
277
+ .dshpx-desc { margin: 0; font-size: 14px; color: var(--dsw-alias-label-secondary); line-height: 1.5; }
278
+ .dshpx-path {
279
+ align-self: flex-start; margin: 0; padding: 2px 8px; border-radius: 6px; font-size: 12px; word-break: break-all;
280
+ color: var(--dsw-alias-label-caption); background: var(--dshpx-fill); font-family: var(--ds-font-family-code, ui-monospace, monospace);
281
+ }
282
+ .dshpx-head { display: flex; flex-direction: column; gap: 8px; padding-bottom: 4px; }
283
+ .dshpx-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
284
+ .dshpx-head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
285
+ .dshpx-grid { display: flex; flex-direction: column; gap: 20px; }
286
+ .dshpx-card {
287
+ border: 1px solid var(--dshpx-line); border-radius: 14px; padding: 18px 20px;
288
+ display: flex; flex-direction: column; gap: 12px; min-width: 0;
289
+ }
290
+ .dshpx-card-accent { background: var(--dshpx-fill); border-color: transparent; }
291
+ .dshpx-card-head { display: flex; flex-direction: column; gap: 4px; }
292
+ .dshpx-hint { margin: 0; font-size: 12.5px; color: var(--dsw-alias-label-caption); line-height: 1.5; }
293
+ .dshpx-row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
294
+ .dshpx-input-row { display: flex; gap: 8px; align-items: center; }
295
+ .dshpx-input {
296
+ flex: 1; min-width: 0; box-sizing: border-box;
297
+ background: var(--dsw-alias-bg-base); border: 1px solid var(--dshpx-line);
298
+ border-radius: 10px; padding: 9px 12px; font-size: 13.5px; color: var(--dsw-alias-label-primary); font-family: inherit;
299
+ outline: none; transition: border-color 120ms ease, box-shadow 120ms ease;
300
+ }
301
+ .dshpx-input:focus, .dshpx-textarea:focus {
302
+ border-color: color-mix(in srgb, var(--dsw-alias-label-primary) 30%, transparent);
303
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);
304
+ }
305
+ .dshpx-input::placeholder, .dshpx-textarea::placeholder { color: var(--dsw-alias-label-caption); }
306
+ .dshpx-textarea {
307
+ width: 100%; min-height: 200px; resize: vertical; box-sizing: border-box;
308
+ background: var(--dsw-alias-bg-base); border: 1px solid var(--dshpx-line);
309
+ border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.6;
310
+ color: var(--dsw-alias-label-primary); font-family: var(--ds-font-family-code, ui-monospace, monospace);
311
+ outline: none; transition: border-color 120ms ease, box-shadow 120ms ease;
312
+ }
313
+ .dshpx-notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow-y: auto; }
314
+ .dshpx-note {
315
+ font-size: 13px; color: var(--dsw-alias-label-secondary); line-height: 1.5; overflow-wrap: anywhere;
316
+ padding: 3px 10px; border-radius: 6px;
317
+ }
318
+ .dshpx-note-h { margin: 10px 0 2px; padding: 0 10px; font-size: 12.5px; font-weight: 600; color: var(--dsw-alias-label-primary); }
319
+ .dshpx-note-h:first-child { margin-top: 0; }
320
+ .dshpx-note-h1, .dshpx-note-h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dsw-alias-label-caption); }
321
+ .dshpx-note-h4 { font-weight: 550; color: var(--dsw-alias-label-secondary); }
322
+ .dshpx-note-date { margin-left: 8px; font-size: 11px; color: var(--dsw-alias-label-caption); white-space: nowrap; }
323
+ .dshpx-note:hover { background: var(--dshpx-hover); }
324
+ .dshpx-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
325
+ .dshpx-file { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border-radius: 8px; font-size: 13px; }
326
+ .dshpx-file:hover { background: var(--dshpx-hover); }
327
+ .dshpx-file > svg { flex: none; color: var(--dsw-alias-label-caption); }
328
+ .dshpx-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-primary); }
329
+ .dshpx-file-size { flex: none; font-size: 11.5px; color: var(--dsw-alias-label-caption); font-variant-numeric: tabular-nums; }
330
+ .dshpx-drop {
331
+ display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
332
+ padding: 22px 16px; border: 1.5px dashed var(--dshpx-line); border-radius: 12px;
333
+ font-size: 13px; color: var(--dsw-alias-label-caption); text-align: center; cursor: pointer;
334
+ transition: border-color 120ms ease, background 120ms ease;
335
+ }
336
+ .dshpx-drop:hover { background: var(--dshpx-hover); }
337
+ .dshpx-card-drag { border-color: var(--dsw-alias-label-caption); background: var(--dshpx-fill); }
338
+ .dshpx-card-drag .dshpx-drop { border-color: var(--dsw-alias-label-caption); }
339
+
340
+ /* ---- buttons ---- */
341
+ .dshpx-btn {
342
+ display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
343
+ border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 550; line-height: 1.2;
344
+ cursor: pointer; border: 1px solid transparent; font-family: inherit;
345
+ transition: background 120ms ease, opacity 120ms ease, color 120ms ease;
346
+ }
347
+ .dshpx-btn:disabled { opacity: 0.4; cursor: default; }
348
+ .dshpx-btn-primary {
349
+ background: var(--dsw-alias-button-primary-fill, var(--dsw-alias-label-primary));
350
+ color: var(--dsw-alias-label-primary-inverted, var(--dsw-alias-bg-base));
351
+ }
352
+ .dshpx-btn-primary:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover, var(--dsw-alias-label-primary)); }
353
+ .dshpx-btn-ghost { background: transparent; color: var(--dsw-alias-label-secondary); border-color: var(--dshpx-line); }
354
+ .dshpx-btn-ghost:hover:not(:disabled) { background: var(--dshpx-hover); color: var(--dsw-alias-label-primary); }
355
+ .dshpx-btn-danger { background: transparent; color: var(--dsw-alias-state-error-primary); border-color: color-mix(in srgb, var(--dsw-alias-state-error-primary) 35%, transparent); }
356
+ .dshpx-btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--dsw-alias-state-error-primary) 10%, transparent); }
357
+ .dshpx-btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
358
+ .dshpx-btns { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
359
+
360
+ /* ---- create form ---- */
361
+ .dshpx-form { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--dshpx-fill); }
362
+ .dshpx-label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--dsw-alias-label-secondary); font-weight: 550; }
363
+
364
+ /* ---- status texts ---- */
365
+ .dshpx-ok { color: var(--dsw-alias-state-success-primary); font-size: 12.5px; }
366
+ .dshpx-err { color: var(--dsw-alias-state-error-primary); font-size: 12.5px; }
367
+
368
+ /* ---- leading slot (matches dsh workspace rows) ---- */
369
+ .dshpx-lead { position: relative; flex: none; width: 16px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-caption)); }
370
+ .dshpx-lead-folder { display: inline-flex; }
371
+ .dshpx-lead-arrow {
372
+ display: none; position: absolute; inset: -2px -4px; align-items: center; justify-content: center;
373
+ border: none; background: transparent; color: inherit; padding: 0; border-radius: 4px; cursor: pointer;
374
+ }
375
+ .dshpx-lead-arrow svg { transition: transform 150ms ease-in-out; }
376
+ .dshpx-lead-arrow .dshpx-arrow-open { transform: rotate(90deg); }
377
+ .dshpx-lead-arrow:hover { color: var(--dsw-alias-label-primary); }
378
+ @media (hover: hover) {
379
+ .dshpx-row:hover .dshpx-lead-arrow, .dshpx-side-row:hover .dshpx-lead-arrow { display: inline-flex; }
380
+ .dshpx-row:hover .dshpx-lead-folder, .dshpx-side-row:hover .dshpx-lead-folder { visibility: hidden; }
381
+ }
382
+ @media (hover: none) { .dshpx-lead-arrow { display: inline-flex; } .dshpx-lead-folder { visibility: hidden; } }
383
+
384
+ /* ---- sidebar group (sidebar.projects seat): mirrors dsh workspace rows ---- */
385
+ .dshpx-side { display: flex; flex-direction: column; margin: 4px 0 8px; }
386
+ .dshpx-side-row {
387
+ display: flex; align-items: center; gap: var(--dsh-sidebar-label-gap, 10px); width: 100%; box-sizing: border-box;
388
+ height: 34px; padding: 0 8px; padding-inline-start: calc(var(--dsh-sidebar-row-padding, 12px) - var(--dsh-sidebar-paint-inset, 4px));
389
+ border-inline: var(--dsh-sidebar-paint-inset, 4px) solid transparent; background-clip: padding-box;
390
+ border-radius: var(--dsw-radius-md, 8px); background-color: transparent;
391
+ color: var(--dsw-alias-label-primary); cursor: pointer; user-select: none; -webkit-user-select: none;
392
+ }
393
+ .dshpx-side-row:hover, .dshpx-side-row:focus-visible { background-color: var(--dsw-alias-interactive-bg-hover); outline: none; }
394
+ .dshpx-side-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
395
+ .dshpx-side-actions { display: inline-flex; flex: none; opacity: 0; }
396
+ .dshpx-side-row:hover .dshpx-side-actions, .dshpx-side-row:focus-within .dshpx-side-actions { opacity: 1; }
397
+ .dshpx-side-children { display: flex; flex-direction: column; }
398
+ .dshpx-side-child {
399
+ display: block; width: 100%; box-sizing: border-box; height: 32px; line-height: 32px;
400
+ padding: 0 8px; padding-inline-start: calc(var(--dsh-sidebar-row-padding, 12px) - var(--dsh-sidebar-paint-inset, 4px) + 16px + var(--dsh-sidebar-label-gap, 10px));
401
+ border: none; border-inline: var(--dsh-sidebar-paint-inset, 4px) solid transparent; background-clip: padding-box;
402
+ border-radius: var(--dsw-radius-md, 8px); background-color: transparent; color: var(--dsw-alias-label-primary);
403
+ font: inherit; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
404
+ }
405
+ .dshpx-side-child:hover { background-color: var(--dsw-alias-interactive-bg-hover); }
406
+ .dshpx-side .dshpx-empty { padding-inline-start: calc(var(--dsh-sidebar-row-padding, 12px) + 16px + var(--dsh-sidebar-label-gap, 10px)); }
407
+
408
+ .dshpx-side-child { display: flex; align-items: center; gap: 6px; }
409
+ .dshpx-side-child-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
410
+ .dshpx-side-child .dshpx-side-actions { opacity: 0; }
411
+ .dshpx-side-child:hover .dshpx-side-actions, .dshpx-side-child:focus-within .dshpx-side-actions { opacity: 1; }
412
+ .dshpx-more { width: 24px; height: 24px; padding: 0; color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-caption)); }
413
+ .dshpx-child-actions { display: none; flex: none; }
414
+ .dshpx-child:hover .dshpx-child-actions, .dshpx-child:focus-within .dshpx-child-actions { display: inline-flex; }
415
+ .dshpx-child:hover .dshpx-child-time, .dshpx-child:focus-within .dshpx-child-time { display: none; }
416
+ .dshpx-edit { gap: 10px; }
417
+ .dshpx-edit-name { font-size: 20px; font-weight: 650; padding: 8px 12px; }
418
+
419
+ .dshpx-archived-head {
420
+ display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 8px; border: none; background: transparent;
421
+ border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 550; color: var(--dsw-alias-label-caption); text-align: left;
422
+ }
423
+ .dshpx-archived-head:hover { background: var(--dshpx-hover); color: var(--dsw-alias-label-secondary); }
424
+ .dshpx-archived-head svg { transition: transform 150ms ease-in-out; }
425
+ .dshpx-archived-head .dshpx-arrow-open { transform: rotate(90deg); }
426
+ .dshpx-archived .dshpx-row-name { color: var(--dsw-alias-label-secondary); }
427
+
428
+ .dshpx-goal {
429
+ margin-top: 6px; padding: 12px 16px; border-radius: 12px; text-align: left; font: inherit;
430
+ background: var(--dshpx-fill); border: 1px solid transparent; display: flex; flex-direction: column; gap: 4px;
431
+ }
432
+ .dshpx-goal p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--dsw-alias-label-primary); white-space: pre-wrap; }
433
+ .dshpx-goal-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dsw-alias-label-caption); }
434
+ .dshpx-goal-empty { cursor: pointer; background: transparent; border: 1.5px dashed var(--dshpx-line); }
435
+ .dshpx-goal-empty p { color: var(--dsw-alias-label-caption); }
436
+ .dshpx-goal-empty:hover { background: var(--dshpx-hover); }
437
+ .dshpx-goal-input { min-height: 90px; font-family: inherit; font-size: 13.5px; }
438
+
439
+ /* ---- right-sidebar tab body + header button ---- */
440
+ .dshpx-tabpane {
441
+ width: 100%; height: 100%; min-height: 0; overflow-y: auto; box-sizing: border-box;
442
+ padding: 16px; display: flex; flex-direction: column; gap: 14px;
443
+ }
444
+ .dshpx-tabpane .dshpx-detail-inner { max-width: none; gap: 14px; }
445
+ .dshpx-tabpane .dshpx-grid { gap: 14px; }
446
+ .dshpx-tabpane .dshpx-h1 { font-size: 20px; }
447
+ .dshpx-tabpane .dshpx-card { padding: 14px 16px; }
448
+ .dshpx-header-btn {
449
+ display: inline-flex; align-items: center; justify-content: center;
450
+ background: transparent; border: none; border-radius: 6px; padding: 4px; cursor: pointer;
451
+ color: var(--dsw-alias-label-caption); transition: background 120ms ease, color 120ms ease;
452
+ }
453
+ .dshpx-header-btn:hover { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-skeleton)); color: var(--dsw-alias-label-primary); }
454
+
455
+ /* ---- mobile: single pane (JS decides which pane; CSS keeps it full-bleed) ---- */
456
+ @media (max-width: 820px) {
457
+ .dshpx-tree { width: 100%; min-width: 0; border-right: none; }
458
+ .dshpx-detail { padding: 16px; }
459
+ .dshpx-h1 { font-size: 22px; }
460
+ }
461
+ `;
462
+ function ensureStyles() {
463
+ if (typeof document === "undefined") return;
464
+ if (!document.getElementById(STYLE_ID)) {
465
+ const el = document.createElement("style");
466
+ el.id = STYLE_ID;
467
+ el.textContent = CSS;
468
+ document.head.appendChild(el);
469
+ }
470
+ }
471
+ var selectedSlug = null;
472
+ var selectionListeners = /* @__PURE__ */ new Set();
473
+ function select(slug) {
474
+ if (selectedSlug === slug) return;
475
+ selectedSlug = slug;
476
+ for (const l of selectionListeners) l();
477
+ }
478
+ function subscribeSelection(cb) {
479
+ selectionListeners.add(cb);
480
+ return () => {
481
+ selectionListeners.delete(cb);
482
+ };
483
+ }
484
+ function useSelection() {
485
+ return (0, import_react.useSyncExternalStore)(subscribeSelection, () => selectedSlug, () => selectedSlug);
486
+ }
487
+ function useNarrow() {
488
+ const [narrow, setNarrow] = (0, import_react.useState)(
489
+ () => typeof window !== "undefined" ? window.matchMedia("(max-width: 820px)").matches : false
490
+ );
491
+ (0, import_react.useEffect)(() => {
492
+ const mq = window.matchMedia("(max-width: 820px)");
493
+ const onChange = (e) => setNarrow(e.matches);
494
+ mq.addEventListener("change", onChange);
495
+ return () => mq.removeEventListener("change", onChange);
496
+ }, []);
497
+ return narrow;
498
+ }
499
+ var q = (p) => "/api/deep-projects/" + p;
500
+ async function getJson(path) {
501
+ const res = await fetch(q(path), { headers: { accept: "application/json" } });
502
+ return res.json();
503
+ }
504
+ async function postJson(path, body) {
505
+ const res = await fetch(q(path), {
506
+ method: "POST",
507
+ headers: { accept: "application/json", "content-type": "application/json" },
508
+ body: body === void 0 ? void 0 : JSON.stringify(body)
509
+ });
510
+ return res.json();
511
+ }
512
+ async function postRaw(path, bytes) {
513
+ const res = await fetch(q(path), { method: "POST", body: bytes });
514
+ return res.json();
515
+ }
516
+ var EMPTY_SESSIONS = { byId: {}, all: [] };
517
+ function sessionTitle(row, t) {
518
+ var _a;
519
+ const v = (_a = row.projections) == null ? void 0 : _a.values;
520
+ const title = v && typeof v.title === "string" && v.title.trim() ? v.title : "";
521
+ return title || t("session.none.title");
522
+ }
523
+ function sessionsFor(project, all) {
524
+ if (!(project == null ? void 0 : project.path)) return [];
525
+ const p = project.path;
526
+ return all.filter((r) => {
527
+ var _a, _b;
528
+ return ((_a = r.cwd) != null ? _a : "") === p || ((_b = r.cwd) != null ? _b : "").startsWith(p + "/");
529
+ }).sort((a, b) => b.updatedAt - a.updatedAt);
530
+ }
531
+ async function startProjectChat(cwd) {
532
+ const ctx = appCtx;
533
+ if (!ctx) return;
534
+ const sessions = ctx.get("sessions");
535
+ const id = await sessions.create({ cwd });
536
+ const ws = ctx.get("uiWorkspace");
537
+ ws.openSession(id);
538
+ }
539
+ function relTime(ts) {
540
+ const d = Date.now() - ts;
541
+ if (d < 6e4) return "now";
542
+ if (d < 36e5) return Math.round(d / 6e4) + "m";
543
+ if (d < 864e5) return Math.round(d / 36e5) + "h";
544
+ if (d < 7 * 864e5) return Math.round(d / 864e5) + "d";
545
+ return new Date(ts).toLocaleDateString();
546
+ }
547
+ var changeListeners = /* @__PURE__ */ new Set();
548
+ function notifyChanged() {
549
+ for (const fn of changeListeners) fn();
550
+ }
551
+ function useOnChanged(fn) {
552
+ (0, import_react.useEffect)(() => {
553
+ changeListeners.add(fn);
554
+ return () => {
555
+ changeListeners.delete(fn);
556
+ };
557
+ }, [fn]);
558
+ }
559
+ var editRequest = null;
560
+ var menus = () => appCtx.contextMenus;
561
+ function pointOf(e) {
562
+ const r = e.currentTarget.getBoundingClientRect();
563
+ return { x: r.left, y: r.bottom };
564
+ }
565
+ function toggleMenu(kind, value, match, point) {
566
+ const active = menus().active.getSnapshot();
567
+ if ((active == null ? void 0 : active.kind) === kind && match(active.value)) menus().close();
568
+ else menus().open({ kind, value }, point);
569
+ }
570
+ function openChatMenu(e, sessionId, displayTitle) {
571
+ e.stopPropagation();
572
+ toggleMenu("session", { sessionId, displayTitle }, (v) => v.sessionId === sessionId, pointOf(e));
573
+ }
574
+ function openProjectMenu(e, p) {
575
+ e.stopPropagation();
576
+ toggleMenu("dsh-project", { slug: p.slug, name: p.name, path: p.path, starred: !!p.starred, archived: !!p.archived }, (v) => v.slug === p.slug, pointOf(e));
577
+ }
578
+ function showProject(slug) {
579
+ select(slug);
580
+ appCtx.layout.selectPanel(PANEL_ID);
581
+ }
582
+ function MoreButton({ label, onClick }) {
583
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshpx-icon-btn dshpx-more", title: label, "aria-label": label, "aria-haspopup": "menu", onClick, onKeyDown: (e) => e.stopPropagation(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconEllipsisOutlineRegular, { size: 16 }) });
584
+ }
585
+ function LeadSlot({ open, onToggle, label }) {
586
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshpx-lead", children: [
587
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-lead-folder", "aria-hidden": "true", children: open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconFolderOpenRegular, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconFolderCloseRegular, { size: 16 }) }),
588
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
589
+ "button",
590
+ {
591
+ type: "button",
592
+ className: "dshpx-lead-arrow",
593
+ "aria-label": label,
594
+ "aria-expanded": open,
595
+ onClick: (e) => {
596
+ e.stopPropagation();
597
+ onToggle();
598
+ },
599
+ onKeyDown: (e) => e.stopPropagation(),
600
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTriangleRightFillRegular, { size: 12, className: open ? "dshpx-arrow-open" : void 0 })
601
+ }
602
+ )
603
+ ] });
604
+ }
605
+ function ProjectsPanelIcon({ size }) {
606
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconFolderCloseRegular, { size });
607
+ }
608
+ function forcedFallback() {
609
+ try {
610
+ return localStorage.getItem("deep-projects:fallback") === "1";
611
+ } catch {
612
+ return false;
613
+ }
614
+ }
615
+ function useFallbackRows(ctx) {
616
+ var _a, _b;
617
+ try {
618
+ if (localStorage.getItem("deep-projects:fallback") === "1") return true;
619
+ } catch {
620
+ }
621
+ return !((_b = (_a = ctx.slots).spec) == null ? void 0 : _b.call(_a, "sidebar.projects"));
622
+ }
623
+ function PinnedProjectPanel({ slug }) {
624
+ (0, import_react.useEffect)(() => {
625
+ select(slug);
626
+ }, [slug]);
627
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectsPanel, {});
628
+ }
629
+ function ProjectsPanel() {
630
+ const ctx = appCtx;
631
+ if (!ctx) return null;
632
+ const t = ctx.locale.bind("projects");
633
+ const list = ctx.sessions.list;
634
+ const snapshot = (0, import_react.useSyncExternalStore)(
635
+ (cb) => list.subscribe(cb),
636
+ () => list.getSnapshot()
637
+ );
638
+ const allSessions = (0, import_react.useMemo)(
639
+ () => Object.values(snapshot.byId),
640
+ [snapshot]
641
+ );
642
+ const selected = useSelection();
643
+ const narrow = useNarrow();
644
+ if (narrow && selected) {
645
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshpx-root dshpx-split", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshpx-detail", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-detail-inner", children: [
646
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm", onClick: () => select(null), children: [
647
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronLeftOutlineRegular, { size: 14 }),
648
+ " ",
649
+ t("detail.back")
650
+ ] }),
651
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DetailPane, { t, slug: selected })
652
+ ] }) }) });
653
+ }
654
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-root dshpx-split", children: [
655
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreePane, { t, allSessions }),
656
+ !narrow && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshpx-detail", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshpx-detail-inner", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DetailPane, { t, slug: selected }) }) })
657
+ ] });
658
+ }
659
+ function TreePane({ t, allSessions }) {
660
+ const [rows, setRows] = (0, import_react.useState)(null);
661
+ const [error, setError] = (0, import_react.useState)(null);
662
+ const [filter, setFilter] = (0, import_react.useState)("");
663
+ const [creating, setCreating] = (0, import_react.useState)(false);
664
+ const [expanded, setExpanded] = (0, import_react.useState)(() => /* @__PURE__ */ new Set());
665
+ const [showArchived, setShowArchived] = (0, import_react.useState)(false);
666
+ const selected = useSelection();
667
+ const load = (0, import_react.useCallback)(() => {
668
+ setError(null);
669
+ getJson("list").then((d) => {
670
+ const list = Array.isArray(d == null ? void 0 : d.projects) ? d.projects : [];
671
+ list.sort(
672
+ (a, b) => a.starred === b.starred ? new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() : a.starred ? -1 : 1
673
+ );
674
+ setRows(list);
675
+ }).catch(() => setError(t("error.generic")));
676
+ }, [t]);
677
+ (0, import_react.useEffect)(load, [load]);
678
+ useOnChanged(load);
679
+ const toggle = (slug) => {
680
+ setExpanded((prev) => {
681
+ const next = new Set(prev);
682
+ if (next.has(slug)) next.delete(slug);
683
+ else next.add(slug);
684
+ return next;
685
+ });
686
+ };
687
+ const openProject = (p) => {
688
+ select(p.slug);
689
+ };
690
+ const openChat = (id) => {
691
+ const ws = appCtx.get("uiWorkspace");
692
+ ws.openSession(id);
693
+ appCtx.layout.selectPanel(null);
694
+ };
695
+ const togglePin = async (p) => {
696
+ await postJson("star?slug=" + encodeURIComponent(p.slug), { starred: !p.starred });
697
+ load();
698
+ };
699
+ const visible = (rows != null ? rows : []).filter((p) => {
700
+ var _a;
701
+ if (!filter.trim()) return true;
702
+ const f = filter.toLowerCase();
703
+ return p.name.toLowerCase().includes(f) || ((_a = p.description) != null ? _a : "").toLowerCase().includes(f);
704
+ });
705
+ const active = visible.filter((p) => !p.archived);
706
+ const archived = visible.filter((p) => p.archived);
707
+ const renderRow = (p) => {
708
+ const isOpen = expanded.has(p.slug);
709
+ const chats = sessionsFor(p, allSessions);
710
+ const isActive = selected === p.slug;
711
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
712
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
713
+ "div",
714
+ {
715
+ className: `dshpx-row${isActive ? " dshpx-row-active" : ""}${p.starred ? " dshpx-row-pinned" : ""}`,
716
+ role: "button",
717
+ tabIndex: 0,
718
+ onClick: () => openProject(p),
719
+ onKeyDown: (e) => {
720
+ if (e.key === "Enter") openProject(p);
721
+ },
722
+ children: [
723
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LeadSlot, { open: isOpen, onToggle: () => toggle(p.slug), label: isOpen ? t("tree.collapse") : t("tree.expand") }),
724
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-row-name", children: p.name }),
725
+ chats.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-count", children: chats.length }),
726
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshpx-row-actions", children: [
727
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreButton, { label: t("menu.more"), onClick: (e) => openProjectMenu(e, p) }),
728
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
729
+ "button",
730
+ {
731
+ className: "dshpx-icon-btn",
732
+ title: t("row.newChat"),
733
+ disabled: !p.path,
734
+ onClick: (e) => {
735
+ e.stopPropagation();
736
+ if (p.path) void startProjectChat(p.path);
737
+ },
738
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconNewChatOutlineRegular, { size: 13 })
739
+ }
740
+ )
741
+ ] })
742
+ ]
743
+ }
744
+ ),
745
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-children", children: [
746
+ chats.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-empty", children: t("sessions.empty") }),
747
+ chats.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-child", role: "button", tabIndex: 0, onClick: () => openChat(r.sessionId), onKeyDown: (e) => {
748
+ if (e.key === "Enter") openChat(r.sessionId);
749
+ }, children: [
750
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-child-title", children: sessionTitle(r, t) }),
751
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-child-time", children: relTime(r.updatedAt) }),
752
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-child-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreButton, { label: t("menu.more"), onClick: (e) => openChatMenu(e, r.sessionId, sessionTitle(r, t)) }) })
753
+ ] }, r.sessionId))
754
+ ] })
755
+ ] }, p.slug);
756
+ };
757
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-tree", children: [
758
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-tree-head", children: [
759
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-tree-title", children: t("tree.title") }),
760
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-icon-btn", title: t("create.title"), onClick: () => setCreating(true), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPlusOutlineRegular, { size: 14 }) })
761
+ ] }),
762
+ creating && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
763
+ CreateForm,
764
+ {
765
+ t,
766
+ onDone: (p) => {
767
+ setCreating(false);
768
+ openProject(p);
769
+ },
770
+ onCancel: () => setCreating(false)
771
+ }
772
+ ),
773
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshpx-search", children: [
774
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconSearchOutlineRegular, { size: 13 }),
775
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
776
+ "input",
777
+ {
778
+ value: filter,
779
+ placeholder: t("tree.search"),
780
+ onChange: (e) => setFilter(e.target.value)
781
+ }
782
+ )
783
+ ] }),
784
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBox, { t, message: error, onRetry: load }),
785
+ !error && rows === null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: t("loading") }),
786
+ !error && rows !== null && visible.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: rows.length === 0 ? t("empty.title") : "\u2014" }),
787
+ !error && rows !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-list", children: [
788
+ active.map(renderRow),
789
+ archived.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshpx-archived-head", "aria-expanded": showArchived, onClick: () => setShowArchived((v) => !v), children: [
790
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTriangleRightFillRegular, { size: 10, className: showArchived ? "dshpx-arrow-open" : void 0 }),
791
+ t("tree.archived"),
792
+ " ",
793
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-count", children: archived.length })
794
+ ] }),
795
+ showArchived && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshpx-archived", children: archived.map(renderRow) })
796
+ ] })
797
+ ] });
798
+ }
799
+ function ProjectsSidebarGroup({ wide }) {
800
+ const [rows, setRows] = (0, import_react.useState)(null);
801
+ const [error, setError] = (0, import_react.useState)(null);
802
+ const [expanded, setExpanded] = (0, import_react.useState)(() => /* @__PURE__ */ new Set());
803
+ const selected = useSelection();
804
+ const t = appCtx == null ? void 0 : appCtx.locale.bind("projects");
805
+ const load = (0, import_react.useCallback)(() => {
806
+ setError(null);
807
+ getJson("list").then((d) => {
808
+ const list2 = Array.isArray(d == null ? void 0 : d.projects) ? d.projects : [];
809
+ list2.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
810
+ setRows(list2.filter((p) => p.starred && !p.archived));
811
+ }).catch(() => {
812
+ if (t) setError(t("error.generic"));
813
+ setRows([]);
814
+ });
815
+ }, [t]);
816
+ (0, import_react.useEffect)(() => {
817
+ load();
818
+ }, [load, selected]);
819
+ useOnChanged(load);
820
+ const list = appCtx == null ? void 0 : appCtx.sessions.list;
821
+ const snapshot = (0, import_react.useSyncExternalStore)(
822
+ (cb) => {
823
+ var _a;
824
+ return (_a = list == null ? void 0 : list.subscribe(cb)) != null ? _a : (() => () => {
825
+ });
826
+ },
827
+ () => {
828
+ var _a;
829
+ return (_a = list == null ? void 0 : list.getSnapshot()) != null ? _a : EMPTY_SESSIONS;
830
+ }
831
+ );
832
+ const allSessions = (0, import_react.useMemo)(
833
+ () => Object.values(snapshot.byId),
834
+ [snapshot]
835
+ );
836
+ if (!wide || !t || forcedFallback()) return null;
837
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { padding: "2px 8px", fontSize: 12, opacity: 0.7 }, title: t("error.generic"), children: "\u26A0" });
838
+ if (rows === null) return null;
839
+ if (rows.length === 0) return null;
840
+ const toggle = (slug) => {
841
+ setExpanded((prev) => {
842
+ const next = new Set(prev);
843
+ if (next.has(slug)) next.delete(slug);
844
+ else next.add(slug);
845
+ return next;
846
+ });
847
+ };
848
+ const openChat = (id) => {
849
+ const ws = appCtx.get("uiWorkspace");
850
+ ws.openSession(id);
851
+ appCtx.layout.selectPanel(null);
852
+ };
853
+ const openProject = showProject;
854
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { className: "dshpx-side", "aria-label": t("nav"), children: rows.map((p) => {
855
+ const isOpen = expanded.has(p.slug);
856
+ const chats = sessionsFor(p, allSessions);
857
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
858
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
859
+ "div",
860
+ {
861
+ className: `dshpx-side-row${isOpen ? " dshpx-side-row-open" : ""}`,
862
+ role: "button",
863
+ tabIndex: 0,
864
+ "aria-expanded": isOpen,
865
+ title: p.name,
866
+ onClick: () => openProject(p.slug),
867
+ onKeyDown: (e) => {
868
+ if (e.key === "Enter") openProject(p.slug);
869
+ },
870
+ children: [
871
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LeadSlot, { open: isOpen, onToggle: () => toggle(p.slug), label: isOpen ? t("tree.collapse") : t("tree.expand") }),
872
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-side-row-name", children: p.name }),
873
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshpx-side-actions", children: [
874
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreButton, { label: t("menu.more"), onClick: (e) => openProjectMenu(e, p) }),
875
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
876
+ "button",
877
+ {
878
+ className: "dshpx-icon-btn",
879
+ title: t("row.newChat"),
880
+ disabled: !p.path,
881
+ onClick: (e) => {
882
+ e.stopPropagation();
883
+ if (p.path) void startProjectChat(p.path);
884
+ },
885
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconNewChatOutlineRegular, { size: 16 })
886
+ }
887
+ )
888
+ ] })
889
+ ]
890
+ }
891
+ ),
892
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-side-children", children: [
893
+ chats.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-empty", children: t("sessions.empty") }),
894
+ chats.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-side-child", role: "button", tabIndex: 0, onClick: () => openChat(r.sessionId), onKeyDown: (e) => {
895
+ if (e.key === "Enter") openChat(r.sessionId);
896
+ }, title: sessionTitle(r, t), children: [
897
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-side-child-title", children: sessionTitle(r, t) }),
898
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-side-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoreButton, { label: t("menu.more"), onClick: (e) => openChatMenu(e, r.sessionId, sessionTitle(r, t)) }) })
899
+ ] }, r.sessionId))
900
+ ] })
901
+ ] }, p.slug);
902
+ }) });
903
+ }
904
+ function CreateForm({
905
+ t,
906
+ onDone,
907
+ onCancel
908
+ }) {
909
+ const [name, setName] = (0, import_react.useState)("");
910
+ const [description, setDescription] = (0, import_react.useState)("");
911
+ const [error, setError] = (0, import_react.useState)(null);
912
+ const [busy, setBusy] = (0, import_react.useState)(false);
913
+ const submit = async () => {
914
+ if (busy) return;
915
+ setBusy(true);
916
+ setError(null);
917
+ try {
918
+ const d = await postJson("create", { name, description });
919
+ if ((d == null ? void 0 : d.ok) && d.project) onDone(d.project);
920
+ else setError(t("create.error"));
921
+ } catch {
922
+ setError(t("create.error"));
923
+ } finally {
924
+ setBusy(false);
925
+ }
926
+ };
927
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-form", children: [
928
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshpx-label", children: [
929
+ t("create.name"),
930
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
931
+ "input",
932
+ {
933
+ className: "dshpx-input",
934
+ value: name,
935
+ maxLength: 60,
936
+ autoFocus: true,
937
+ placeholder: t("create.name.placeholder"),
938
+ onChange: (e) => setName(e.target.value),
939
+ onKeyDown: (e) => {
940
+ if (e.key === "Enter") void submit();
941
+ }
942
+ }
943
+ )
944
+ ] }),
945
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshpx-label", children: [
946
+ t("create.description"),
947
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
948
+ "input",
949
+ {
950
+ className: "dshpx-input",
951
+ value: description,
952
+ placeholder: t("create.description.placeholder"),
953
+ onChange: (e) => setDescription(e.target.value),
954
+ onKeyDown: (e) => {
955
+ if (e.key === "Enter") void submit();
956
+ }
957
+ }
958
+ )
959
+ ] }),
960
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-err", children: error }),
961
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-btns", children: [
962
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-primary", disabled: busy || !name.trim(), onClick: () => void submit(), children: t("create.submit") }),
963
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-ghost", onClick: onCancel, children: t("create.cancel") })
964
+ ] })
965
+ ] });
966
+ }
967
+ function DetailPane({ t, slug }) {
968
+ if (!slug) {
969
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-placeholder", children: [
970
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-h1", children: t("tab.title") }),
971
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: t("empty.hint") })
972
+ ] });
973
+ }
974
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectContent, { t, slug });
975
+ }
976
+ function ProjectHeaderButton(props) {
977
+ const t = props.t;
978
+ const { sessionId, useSessions } = props;
979
+ const cwd = useSessions((s) => {
980
+ var _a;
981
+ return (_a = s.byId[sessionId]) == null ? void 0 : _a.cwd;
982
+ });
983
+ const [rows, setRows] = (0, import_react.useState)(null);
984
+ (0, import_react.useEffect)(() => {
985
+ let live = true;
986
+ getJson("list").then((r) => {
987
+ var _a;
988
+ if (live) setRows((r == null ? void 0 : r.ok) ? (_a = r.projects) != null ? _a : [] : null);
989
+ }).catch(() => {
990
+ if (live) setRows(null);
991
+ });
992
+ return () => {
993
+ live = false;
994
+ };
995
+ }, []);
996
+ const inProject = (0, import_react.useMemo)(() => {
997
+ if (!rows || !cwd) return false;
998
+ return rows.some((r) => r.path && (cwd === r.path || cwd.startsWith(r.path + "/")));
999
+ }, [rows, cwd]);
1000
+ if (!inProject) return null;
1001
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1002
+ "button",
1003
+ {
1004
+ className: "dshpx-header-btn",
1005
+ type: "button",
1006
+ title: t("header.open"),
1007
+ onClick: () => appCtx == null ? void 0 : appCtx.sidebarRight.openTab("project"),
1008
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconFolderCloseRegular, { size: 16 })
1009
+ }
1010
+ );
1011
+ }
1012
+ function ProjectContent({ t, slug, compact }) {
1013
+ const [detail, setDetail] = (0, import_react.useState)(null);
1014
+ const [notes, setNotes] = (0, import_react.useState)("");
1015
+ const [error, setError] = (0, import_react.useState)(null);
1016
+ const load = (0, import_react.useCallback)(() => {
1017
+ setError(null);
1018
+ Promise.all([
1019
+ getJson("detail?slug=" + encodeURIComponent(slug)),
1020
+ getJson("notes?slug=" + encodeURIComponent(slug))
1021
+ ]).then(([d, n]) => {
1022
+ var _a;
1023
+ if ((d == null ? void 0 : d.ok) && d.project) {
1024
+ setDetail(d.project);
1025
+ setNotes((_a = n == null ? void 0 : n.notes) != null ? _a : "");
1026
+ } else setError(t("error.generic"));
1027
+ }).catch(() => setError(t("error.generic")));
1028
+ }, [slug, t]);
1029
+ (0, import_react.useEffect)(load, [load]);
1030
+ const [editing, setEditing] = (0, import_react.useState)(null);
1031
+ const [editErr, setEditErr] = (0, import_react.useState)(false);
1032
+ const checkEdit = (0, import_react.useCallback)(() => {
1033
+ var _a, _b;
1034
+ if (editRequest === slug && detail) {
1035
+ editRequest = null;
1036
+ setEditing({ name: detail.name, description: (_a = detail.description) != null ? _a : "", goal: (_b = detail.goal) != null ? _b : "" });
1037
+ }
1038
+ }, [slug, detail]);
1039
+ (0, import_react.useEffect)(checkEdit, [checkEdit]);
1040
+ useOnChanged(load);
1041
+ useOnChanged(checkEdit);
1042
+ (0, import_react.useEffect)(() => {
1043
+ setEditing(null);
1044
+ }, [slug]);
1045
+ const saveEdit = async () => {
1046
+ if (!detail || !editing) return;
1047
+ const d = await postJson("rename?slug=" + encodeURIComponent(detail.slug), { name: editing.name, description: editing.description, goal: editing.goal }).catch(() => null);
1048
+ if (!(d == null ? void 0 : d.ok)) {
1049
+ setEditErr(true);
1050
+ return;
1051
+ }
1052
+ setEditErr(false);
1053
+ setEditing(null);
1054
+ notifyChanged();
1055
+ };
1056
+ const togglePin = async () => {
1057
+ if (!detail) return;
1058
+ await postJson("star?slug=" + encodeURIComponent(detail.slug), { starred: !detail.starred });
1059
+ notifyChanged();
1060
+ };
1061
+ const remove = async () => {
1062
+ if (!detail) return;
1063
+ if (!confirm(t("detail.delete.confirm"))) return;
1064
+ await postJson("delete?slug=" + encodeURIComponent(detail.slug));
1065
+ select(null);
1066
+ notifyChanged();
1067
+ };
1068
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1069
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBox, { t, message: error, onRetry: load }),
1070
+ !error && detail === null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: t("loading") }),
1071
+ !error && detail !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1072
+ editing ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-head dshpx-edit", children: [
1073
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1074
+ "input",
1075
+ {
1076
+ className: "dshpx-input dshpx-edit-name",
1077
+ value: editing.name,
1078
+ maxLength: 60,
1079
+ autoFocus: true,
1080
+ "aria-label": t("create.name"),
1081
+ onChange: (e) => setEditing({ ...editing, name: e.target.value }),
1082
+ onKeyDown: (e) => {
1083
+ if (e.key === "Enter") void saveEdit();
1084
+ if (e.key === "Escape") setEditing(null);
1085
+ }
1086
+ }
1087
+ ),
1088
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1089
+ "input",
1090
+ {
1091
+ className: "dshpx-input",
1092
+ value: editing.description,
1093
+ placeholder: t("create.description.placeholder"),
1094
+ "aria-label": t("create.description"),
1095
+ onChange: (e) => setEditing({ ...editing, description: e.target.value }),
1096
+ onKeyDown: (e) => {
1097
+ if (e.key === "Enter") void saveEdit();
1098
+ if (e.key === "Escape") setEditing(null);
1099
+ }
1100
+ }
1101
+ ),
1102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshpx-label", children: [
1103
+ t("goal.title"),
1104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1105
+ "textarea",
1106
+ {
1107
+ className: "dshpx-textarea dshpx-goal-input",
1108
+ value: editing.goal,
1109
+ placeholder: t("goal.placeholder"),
1110
+ maxLength: 2e3,
1111
+ onChange: (e) => setEditing({ ...editing, goal: e.target.value }),
1112
+ onKeyDown: (e) => {
1113
+ if (e.key === "Escape") setEditing(null);
1114
+ }
1115
+ }
1116
+ )
1117
+ ] }),
1118
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-btns", children: [
1119
+ editErr && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-err", children: t("create.invalid") }),
1120
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm", onClick: () => {
1121
+ setEditing(null);
1122
+ setEditErr(false);
1123
+ }, children: t("create.cancel") }),
1124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-primary dshpx-btn-sm", disabled: !editing.name.trim(), onClick: () => void saveEdit(), children: t("instructions.save") })
1125
+ ] })
1126
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-head", children: [
1127
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-head-row", children: [
1128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "dshpx-h1", children: detail.name }),
1129
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-head-actions", children: [
1130
+ detail.archived && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1131
+ "button",
1132
+ {
1133
+ className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm",
1134
+ type: "button",
1135
+ onClick: async () => {
1136
+ await postJson("archive?slug=" + encodeURIComponent(detail.slug), { archived: false });
1137
+ notifyChanged();
1138
+ },
1139
+ children: [
1140
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconUnarchiveOutlineRegular, { size: 14 }),
1141
+ " ",
1142
+ t("menu.unarchive")
1143
+ ]
1144
+ }
1145
+ ),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-icon-btn", type: "button", title: t("menu.edit"), onClick: () => {
1147
+ var _a, _b;
1148
+ return setEditing({ name: detail.name, description: (_a = detail.description) != null ? _a : "", goal: (_b = detail.goal) != null ? _b : "" });
1149
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconEditOutlineRegular, { size: 16 }) }),
1150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-icon-btn", type: "button", title: detail.starred ? t("detail.unstar") : t("detail.star"), onClick: () => void togglePin(), children: detail.starred ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPinFillRegular, { size: 16, className: "dshpx-pin-on" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPinOutlineRegular, { size: 16 }) }),
1151
+ !compact && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-icon-btn dshpx-icon-btn-danger", type: "button", title: t("detail.delete"), onClick: () => void remove(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTrashOutlineRegular, { size: 16 }) }),
1152
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: "dshpx-btn dshpx-btn-primary dshpx-btn-sm", type: "button", disabled: !detail.path, onClick: () => {
1153
+ if (detail.path) void startProjectChat(detail.path);
1154
+ }, children: [
1155
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconNewChatOutlineRegular, { size: 14 }),
1156
+ t("detail.newChat")
1157
+ ] })
1158
+ ] })
1159
+ ] }),
1160
+ detail.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-desc", children: detail.description }),
1161
+ detail.path && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-path", children: detail.path }),
1162
+ detail.goal ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-goal", children: [
1163
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-goal-label", children: t("goal.title") }),
1164
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: detail.goal })
1165
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshpx-goal dshpx-goal-empty", onClick: () => {
1166
+ var _a;
1167
+ return setEditing({ name: detail.name, description: (_a = detail.description) != null ? _a : "", goal: "" });
1168
+ }, children: [
1169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-goal-label", children: t("goal.title") }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("goal.empty") })
1171
+ ] })
1172
+ ] }),
1173
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-grid", children: [
1174
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Memory, { t, slug: detail.slug, notes, onSaved: setNotes }),
1175
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KnowledgeFiles, { t, detail, onChange: load })
1176
+ ] }),
1177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InstructionsEditor, { t, detail, onChange: load })
1178
+ ] })
1179
+ ] });
1180
+ }
1181
+ function ProjectInfoBody(props) {
1182
+ const t = props.t;
1183
+ const { sessionId, useSessions } = props;
1184
+ const cwd = useSessions((s) => {
1185
+ var _a;
1186
+ return (_a = s.byId[sessionId]) == null ? void 0 : _a.cwd;
1187
+ });
1188
+ const [rows, setRows] = (0, import_react.useState)(null);
1189
+ (0, import_react.useEffect)(() => {
1190
+ let live = true;
1191
+ getJson("list").then((r) => {
1192
+ var _a;
1193
+ if (live) setRows((r == null ? void 0 : r.ok) ? (_a = r.projects) != null ? _a : [] : null);
1194
+ }).catch(() => {
1195
+ if (live) setRows(null);
1196
+ });
1197
+ return () => {
1198
+ live = false;
1199
+ };
1200
+ }, []);
1201
+ const project = (0, import_react.useMemo)(() => {
1202
+ var _a;
1203
+ if (!rows || !cwd) return null;
1204
+ return (_a = rows.find((r) => r.path && (cwd === r.path || cwd.startsWith(r.path + "/")))) != null ? _a : null;
1205
+ }, [rows, cwd]);
1206
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshpx-tabpane", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-detail-inner", children: [
1207
+ rows === null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: t("loading") }),
1208
+ rows !== null && project === null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-placeholder", children: [
1209
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-h1", children: t("tab.project") }),
1210
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: t("tab.project.hint") })
1211
+ ] }),
1212
+ project !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1213
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-hint", children: t("tab.project.hint") }),
1214
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProjectContent, { t, slug: project.slug, compact: true })
1215
+ ] })
1216
+ ] }) });
1217
+ }
1218
+ function Memory({ t, slug, notes, onSaved }) {
1219
+ const [text, setText] = (0, import_react.useState)("");
1220
+ const [draft, setDraft] = (0, import_react.useState)(null);
1221
+ const [status, setStatus] = (0, import_react.useState)("idle");
1222
+ const lines = notes.split("\n").filter((l) => l.trim());
1223
+ const count = lines.filter((l) => /^\s*[-*]\s/.test(l)).length;
1224
+ const send = async (path, body) => {
1225
+ var _a;
1226
+ setStatus("saving");
1227
+ try {
1228
+ const d = await postJson(path + "?slug=" + encodeURIComponent(slug), body);
1229
+ if (!(d == null ? void 0 : d.ok)) {
1230
+ setStatus("error");
1231
+ return false;
1232
+ }
1233
+ onSaved((_a = d.notes) != null ? _a : "");
1234
+ setStatus("idle");
1235
+ return true;
1236
+ } catch {
1237
+ setStatus("error");
1238
+ return false;
1239
+ }
1240
+ };
1241
+ const add = async () => {
1242
+ if (text.trim() && status !== "saving" && await send("note", { text })) setText("");
1243
+ };
1244
+ const save = async () => {
1245
+ if (draft !== null && await send("notes", { text: draft })) setDraft(null);
1246
+ };
1247
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshpx-card", children: [
1248
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-row-head", children: [
1249
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "dshpx-h2", children: [
1250
+ t("memory.title"),
1251
+ " ",
1252
+ count > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-count", children: count })
1253
+ ] }),
1254
+ draft === null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm", onClick: () => setDraft(notes), children: t("memory.edit") })
1255
+ ] }),
1256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-hint", children: t("memory.hint") }),
1257
+ draft !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1258
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dshpx-textarea", value: draft, placeholder: t("memory.placeholder.edit"), onChange: (e) => setDraft(e.target.value), autoFocus: true }),
1259
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-btns", children: [
1260
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-err", children: t("note.error") }),
1261
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm", onClick: () => {
1262
+ setDraft(null);
1263
+ setStatus("idle");
1264
+ }, children: t("create.cancel") }),
1265
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-primary dshpx-btn-sm", disabled: status === "saving" || draft === notes, onClick: () => void save(), children: t("instructions.save") })
1266
+ ] })
1267
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1268
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-input-row", children: [
1269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1270
+ "input",
1271
+ {
1272
+ className: "dshpx-input",
1273
+ value: text,
1274
+ placeholder: t("note.placeholder"),
1275
+ maxLength: 2e3,
1276
+ onChange: (e) => setText(e.target.value),
1277
+ onKeyDown: (e) => {
1278
+ if (e.key === "Enter") void add();
1279
+ }
1280
+ }
1281
+ ),
1282
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { className: "dshpx-btn dshpx-btn-primary", disabled: !text.trim() || status === "saving", onClick: () => void add(), children: [
1283
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPlusOutlineRegular, { size: 14 }),
1284
+ " ",
1285
+ t("note.add")
1286
+ ] })
1287
+ ] }),
1288
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-err", children: t("note.error") }),
1289
+ lines.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-muted", children: t("note.empty") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "dshpx-notes", children: lines.map((l, i) => {
1290
+ const h = /^(#{1,6})\s+(.*)$/.exec(l);
1291
+ if (h) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: `dshpx-note-h dshpx-note-h${Math.min(h[1].length, 4)}`, children: h[2] }, i);
1292
+ const m = /^(.*?)\s*_\((\d{4}-\d\d-\d\d)\)_\s*$/.exec(l.replace(/^[-*]\s+/, ""));
1293
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "dshpx-note", children: [
1294
+ m ? m[1] : l.replace(/^[-*]\s+/, ""),
1295
+ m && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-note-date", children: m[2] })
1296
+ ] }, i);
1297
+ }) })
1298
+ ] })
1299
+ ] });
1300
+ }
1301
+ function InstructionsEditor({
1302
+ t,
1303
+ detail,
1304
+ onChange
1305
+ }) {
1306
+ const [text, setText] = (0, import_react.useState)(detail.instructions);
1307
+ const [status, setStatus] = (0, import_react.useState)("idle");
1308
+ (0, import_react.useEffect)(() => {
1309
+ setText(detail.instructions);
1310
+ setStatus("idle");
1311
+ }, [detail.slug, detail.instructions]);
1312
+ const save = async () => {
1313
+ setStatus("saving");
1314
+ const d = await postJson("instructions?slug=" + encodeURIComponent(detail.slug), { text });
1315
+ setStatus((d == null ? void 0 : d.ok) ? "saved" : "error");
1316
+ if (d == null ? void 0 : d.ok) onChange();
1317
+ };
1318
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshpx-card", children: [
1319
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-card-head", children: [
1320
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "dshpx-h2", children: t("section.instructions") }),
1321
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-hint", children: t("instructions.hint") })
1322
+ ] }),
1323
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1324
+ "textarea",
1325
+ {
1326
+ className: "dshpx-textarea",
1327
+ value: text,
1328
+ placeholder: t("instructions.placeholder"),
1329
+ onChange: (e) => setText(e.target.value)
1330
+ }
1331
+ ),
1332
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-btns", children: [
1333
+ status === "saved" && text === detail.instructions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-ok", children: t("instructions.saved") }),
1334
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-err", children: t("instructions.error") }),
1335
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-primary dshpx-btn-sm", disabled: status === "saving" || text === detail.instructions, onClick: () => void save(), children: t("instructions.save") })
1336
+ ] })
1337
+ ] });
1338
+ }
1339
+ function KnowledgeFiles({
1340
+ t,
1341
+ detail,
1342
+ onChange
1343
+ }) {
1344
+ const [busy, setBusy] = (0, import_react.useState)(false);
1345
+ const [dragOver, setDragOver] = (0, import_react.useState)(false);
1346
+ const upload = async (files) => {
1347
+ if (!files || files.length === 0) return;
1348
+ setBusy(true);
1349
+ try {
1350
+ for (const f of Array.from(files)) {
1351
+ const bytes = await f.arrayBuffer();
1352
+ await postRaw(
1353
+ "knowledge-upload?slug=" + encodeURIComponent(detail.slug) + "&name=" + encodeURIComponent(f.name),
1354
+ bytes
1355
+ );
1356
+ }
1357
+ } finally {
1358
+ setBusy(false);
1359
+ onChange();
1360
+ }
1361
+ };
1362
+ const onDrop = (e) => {
1363
+ var _a, _b;
1364
+ e.preventDefault();
1365
+ setDragOver(false);
1366
+ void upload((_b = (_a = e.dataTransfer) == null ? void 0 : _a.files) != null ? _b : null);
1367
+ };
1368
+ const remove = async (name) => {
1369
+ await postJson("knowledge-delete?slug=" + encodeURIComponent(detail.slug) + "&name=" + encodeURIComponent(name));
1370
+ onChange();
1371
+ };
1372
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1373
+ "section",
1374
+ {
1375
+ className: `dshpx-card${dragOver ? " dshpx-card-drag" : ""}`,
1376
+ onDragOver: (e) => {
1377
+ e.preventDefault();
1378
+ setDragOver(true);
1379
+ },
1380
+ onDragLeave: () => setDragOver(false),
1381
+ onDrop,
1382
+ children: [
1383
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-row-head", children: [
1384
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "dshpx-h2", children: [
1385
+ t("section.knowledge"),
1386
+ " ",
1387
+ detail.knowledge.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-count", children: detail.knowledge.length })
1388
+ ] }),
1389
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm", style: { cursor: "pointer" }, children: [
1390
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPlusOutlineRegular, { size: 13 }),
1391
+ " ",
1392
+ busy ? t("loading") : t("knowledge.upload"),
1393
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1394
+ "input",
1395
+ {
1396
+ type: "file",
1397
+ multiple: true,
1398
+ style: { display: "none" },
1399
+ disabled: busy,
1400
+ onChange: (e) => {
1401
+ void upload(e.target.files);
1402
+ e.target.value = "";
1403
+ }
1404
+ }
1405
+ )
1406
+ ] })
1407
+ ] }),
1408
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshpx-hint", children: t("knowledge.hint") }),
1409
+ detail.knowledge.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshpx-drop", children: [
1410
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDeliverDocRegular, { size: 20 }),
1411
+ t("knowledge.drop"),
1412
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "file", multiple: true, style: { display: "none" }, disabled: busy, onChange: (e) => {
1413
+ void upload(e.target.files);
1414
+ e.target.value = "";
1415
+ } })
1416
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "dshpx-files", children: detail.knowledge.map((f) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "dshpx-file", children: [
1417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDeliverDocRegular, { size: 15 }),
1418
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-file-name", title: f.name, children: f.name }),
1419
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshpx-file-size", children: formatBytes(f.size) }),
1420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-icon-btn dshpx-icon-btn-danger", title: t("knowledge.delete"), onClick: () => void remove(f.name), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTrashOutlineRegular, { size: 13 }) })
1421
+ ] }, f.name)) })
1422
+ ]
1423
+ }
1424
+ );
1425
+ }
1426
+ function formatBytes(n) {
1427
+ if (n < 1024) return n + " B";
1428
+ if (n < 1024 * 1024) return (n / 1024).toFixed(1) + " KB";
1429
+ return (n / 1024 / 1024).toFixed(1) + " MB";
1430
+ }
1431
+ function ErrorBox({ t, message, onRetry }) {
1432
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshpx-notice", children: [
1433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: message || t("error.generic") }),
1434
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "dshpx-btn dshpx-btn-ghost dshpx-btn-sm", onClick: onRetry, children: t("retry") })
1435
+ ] });
1436
+ }
1437
+ function apply(ctx) {
1438
+ appCtx = ctx;
1439
+ ensureStyles();
1440
+ const t = ctx.locale.bind("projects");
1441
+ ctx.effect(() => {
1442
+ ctx.locale.register("projects", { en, zh });
1443
+ }, "deep-projects: locales");
1444
+ ctx.slots.inject("contextMenu.icon", function* () {
1445
+ for (const [key, Icon] of Object.entries({
1446
+ "deep-projects.open": import_dsh_client_ui_primitives.IconFolderOpenRegular,
1447
+ "deep-projects.newChat": import_dsh_client_ui_primitives.IconNewChatOutlineRegular,
1448
+ "deep-projects.edit": import_dsh_client_ui_primitives.IconEditOutlineRegular,
1449
+ "deep-projects.pin": import_dsh_client_ui_primitives.IconPinOutlineRegular,
1450
+ "deep-projects.unpin": import_dsh_client_ui_primitives.IconPinFillRegular,
1451
+ "deep-projects.delete": import_dsh_client_ui_primitives.IconTrashOutlineRegular,
1452
+ "deep-projects.archive": import_dsh_client_ui_primitives.IconArchiveOutlineRegular,
1453
+ "deep-projects.unarchive": import_dsh_client_ui_primitives.IconUnarchiveOutlineRegular
1454
+ })) yield ctx.slots.register({ name: "contextMenu.icon", key }, Icon);
1455
+ });
1456
+ ctx.effect(() => ctx.contextMenus.register({
1457
+ id: "deep-projects.actions",
1458
+ target: "dsh-project",
1459
+ order: 100,
1460
+ resolve: (p) => [
1461
+ { id: "open", label: t("menu.open"), icon: { key: "deep-projects.open" }, run: () => showProject(p.slug) },
1462
+ {
1463
+ id: "newChat",
1464
+ label: t("detail.newChat"),
1465
+ icon: { key: "deep-projects.newChat" },
1466
+ disabled: !p.path,
1467
+ run: () => {
1468
+ if (p.path) void startProjectChat(p.path);
1469
+ }
1470
+ },
1471
+ {
1472
+ id: "edit",
1473
+ label: t("menu.edit"),
1474
+ icon: { key: "deep-projects.edit" },
1475
+ separatorBefore: true,
1476
+ run: () => {
1477
+ editRequest = p.slug;
1478
+ showProject(p.slug);
1479
+ notifyChanged();
1480
+ }
1481
+ },
1482
+ ...p.archived ? [] : [{
1483
+ id: "pin",
1484
+ label: p.starred ? t("row.unpin") : t("row.pin"),
1485
+ icon: { key: p.starred ? "deep-projects.unpin" : "deep-projects.pin" },
1486
+ run: async () => {
1487
+ await postJson("star?slug=" + encodeURIComponent(p.slug), { starred: !p.starred });
1488
+ notifyChanged();
1489
+ }
1490
+ }],
1491
+ {
1492
+ id: "archive",
1493
+ label: p.archived ? t("menu.unarchive") : t("menu.archive"),
1494
+ icon: { key: p.archived ? "deep-projects.unarchive" : "deep-projects.archive" },
1495
+ run: async () => {
1496
+ await postJson("archive?slug=" + encodeURIComponent(p.slug), { archived: !p.archived });
1497
+ notifyChanged();
1498
+ }
1499
+ },
1500
+ {
1501
+ id: "delete",
1502
+ label: t("detail.delete"),
1503
+ icon: { key: "deep-projects.delete" },
1504
+ danger: true,
1505
+ separatorBefore: true,
1506
+ run: async () => {
1507
+ if (!confirm(t("detail.delete.confirm"))) return;
1508
+ await postJson("delete?slug=" + encodeURIComponent(p.slug));
1509
+ if (selectedSlug === p.slug) select(null);
1510
+ notifyChanged();
1511
+ }
1512
+ }
1513
+ ]
1514
+ }), "deep-projects: project menu");
1515
+ ctx.effect(() => {
1516
+ ctx.slots.inject(
1517
+ "sidebar.panellist",
1518
+ () => ctx.slots.register(
1519
+ { name: "sidebar.panellist", id: PANEL_ID, order: 20, label: () => t("nav"), locale: "projects" },
1520
+ ProjectsPanelIcon
1521
+ )
1522
+ );
1523
+ }, "deep-projects: sidebar");
1524
+ ctx.effect(() => {
1525
+ ctx.slots.inject(
1526
+ "sidebar.projects",
1527
+ () => ctx.slots.register({ name: "sidebar.projects", locale: "projects" }, ProjectsSidebarGroup)
1528
+ );
1529
+ }, "deep-projects: sidebar projects");
1530
+ ctx.effect(() => ctx.slots.inject("sidebar.panellist", () => {
1531
+ if (!useFallbackRows(ctx)) return () => {
1532
+ };
1533
+ let disposers = [];
1534
+ let live = true;
1535
+ const clear = () => {
1536
+ for (const off of disposers) off();
1537
+ disposers = [];
1538
+ };
1539
+ const sync = () => {
1540
+ getJson("list").then((d) => {
1541
+ if (!live) return;
1542
+ clear();
1543
+ const pinned = (Array.isArray(d == null ? void 0 : d.projects) ? d.projects : []).filter((p) => p.starred && !p.archived);
1544
+ pinned.forEach((p, i) => {
1545
+ const id = PANEL_ID + ":" + p.slug;
1546
+ const Panel = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PinnedProjectPanel, { slug: p.slug });
1547
+ disposers.push(ctx.slots.register({ name: "main", key: id, locale: "projects" }, Panel));
1548
+ disposers.push(ctx.slots.register({ name: "sidebar.panellist", id, order: 21 + i, label: () => p.name, locale: "projects" }, ProjectsPanelIcon));
1549
+ });
1550
+ }).catch(() => {
1551
+ });
1552
+ };
1553
+ sync();
1554
+ changeListeners.add(sync);
1555
+ return () => {
1556
+ live = false;
1557
+ changeListeners.delete(sync);
1558
+ clear();
1559
+ };
1560
+ }), "deep-projects: sidebar rows (stock dsh)");
1561
+ ctx.effect(() => {
1562
+ ctx.sidebarRightTabs.register({
1563
+ id: TAB_ID,
1564
+ kind: "project",
1565
+ multiple: true,
1566
+ priority: "extension",
1567
+ title: () => t("tab.project")
1568
+ });
1569
+ }, "deep-projects: sidebar tab type");
1570
+ ctx.effect(() => {
1571
+ ctx.slots.inject(
1572
+ "sidebar.right.pane.tab",
1573
+ () => ctx.slots.register({ name: "sidebar.right.pane.tab", key: TAB_ID, locale: "projects" }, ProjectInfoBody)
1574
+ );
1575
+ }, "deep-projects: sidebar tab body");
1576
+ ctx.effect(() => {
1577
+ ctx.slots.inject(
1578
+ "sidebar.right.pane.tab.title",
1579
+ () => ctx.slots.register({ name: "sidebar.right.pane.tab.title", key: TAB_ID, locale: "projects" }, () => t("tab.project"))
1580
+ );
1581
+ }, "deep-projects: sidebar tab title");
1582
+ ctx.effect(() => {
1583
+ ctx.slots.inject(
1584
+ "conversation.session.header.utilities",
1585
+ () => ctx.slots.register({ name: "conversation.session.header.utilities", id: TAB_ID, order: 50, locale: "projects" }, ProjectHeaderButton)
1586
+ );
1587
+ }, "deep-projects: header button");
1588
+ ctx.effect(() => {
1589
+ ctx.slots.inject(
1590
+ "main",
1591
+ () => ctx.slots.register({ name: "main", key: PANEL_ID, locale: "projects" }, ProjectsPanel)
1592
+ );
1593
+ }, "deep-projects: main");
1594
+ }
1595
+
1596
+ return module.exports;
1597
+ }});