deep-projects 0.0.0-stage → 0.4.3

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