dsh-plugin-github-issues 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -2
  3. package/assets/panel.png +0 -0
  4. package/cordis.patch.yml +20 -0
  5. package/docs/README.zh.md +138 -0
  6. package/icon.svg +9 -0
  7. package/lib/client.js +3348 -0
  8. package/lib/controller.js +296 -0
  9. package/lib/controller.js.map +1 -0
  10. package/lib/github/auth.js +249 -0
  11. package/lib/github/auth.js.map +1 -0
  12. package/lib/github/client.js +797 -0
  13. package/lib/github/client.js.map +1 -0
  14. package/lib/github/queries.js +508 -0
  15. package/lib/github/queries.js.map +1 -0
  16. package/lib/github/state.js +190 -0
  17. package/lib/github/state.js.map +1 -0
  18. package/lib/github/types.js +29 -0
  19. package/lib/github/types.js.map +1 -0
  20. package/lib/github/vm.js +362 -0
  21. package/lib/github/vm.js.map +1 -0
  22. package/lib/index.js +65 -0
  23. package/lib/index.js.map +1 -0
  24. package/lib/prompt.js +87 -0
  25. package/lib/prompt.js.map +1 -0
  26. package/lib/remote-methods.js +33 -0
  27. package/lib/remote-methods.js.map +1 -0
  28. package/lib/types/controller.d.ts +109 -0
  29. package/lib/types/controller.d.ts.map +1 -0
  30. package/lib/types/github/auth.d.ts +52 -0
  31. package/lib/types/github/auth.d.ts.map +1 -0
  32. package/lib/types/github/client.d.ts +40 -0
  33. package/lib/types/github/client.d.ts.map +1 -0
  34. package/lib/types/github/queries.d.ts +181 -0
  35. package/lib/types/github/queries.d.ts.map +1 -0
  36. package/lib/types/github/state.d.ts +51 -0
  37. package/lib/types/github/state.d.ts.map +1 -0
  38. package/lib/types/github/types.d.ts +83 -0
  39. package/lib/types/github/types.d.ts.map +1 -0
  40. package/lib/types/github/vm.d.ts +260 -0
  41. package/lib/types/github/vm.d.ts.map +1 -0
  42. package/lib/types/index.d.ts +46 -0
  43. package/lib/types/index.d.ts.map +1 -0
  44. package/lib/types/prompt.d.ts +30 -0
  45. package/lib/types/prompt.d.ts.map +1 -0
  46. package/lib/types/remote-methods.d.ts +32 -0
  47. package/lib/types/remote-methods.d.ts.map +1 -0
  48. package/lib/types/vm.d.ts +268 -0
  49. package/lib/types/vm.d.ts.map +1 -0
  50. package/lib/types/workspace.d.ts +43 -0
  51. package/lib/types/workspace.d.ts.map +1 -0
  52. package/lib/vm.js +43 -0
  53. package/lib/vm.js.map +1 -0
  54. package/lib/workspace.js +57 -0
  55. package/lib/workspace.js.map +1 -0
  56. package/locale/en.json +6 -0
  57. package/locale/zh.json +6 -0
  58. package/package.json +99 -4
package/lib/client.js ADDED
@@ -0,0 +1,3348 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-plugin-github-issues",
3
+ factory: function (require) {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ (function (module, exports, require) {
7
+ "use strict";
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/client/index.tsx
27
+ var index_exports = {};
28
+ __export(index_exports, {
29
+ apply: () => apply,
30
+ inject: () => inject
31
+ });
32
+ module.exports = __toCommonJS(index_exports);
33
+
34
+ // src/client/containers.tsx
35
+ var import_react5 = require("react");
36
+
37
+ // src/vm.ts
38
+ var DEFAULT_PROMPT_TEMPLATE = [
39
+ "\u5904\u7406 GitHub Issue\uFF1A{{repo}}#{{number}} {{title}}",
40
+ "\u94FE\u63A5\uFF1A{{url}}",
41
+ "\u72B6\u6001\uFF1A{{state}} \uFF5C \u91CC\u7A0B\u7891\uFF1A{{milestone}} \uFF5C \u4F18\u5148\u7EA7\uFF1A{{priority}} \uFF5C \u6307\u6D3E\uFF1A{{assignees}}",
42
+ "\u6807\u7B7E\uFF1A{{labels}}",
43
+ "\u5173\u8054 PR\uFF1A{{prs}}",
44
+ "\u8981\u6C42\uFF1A\u5148\u8BFB Issue \u6B63\u6587\u4E0E\u5173\u8054 PR\uFF0C\u786E\u8BA4\u9A8C\u6536\u6807\u51C6\u540E\u518D\u52A8\u624B\uFF1B\u7528 subagent_codex \u6267\u884C\u5177\u4F53\u6539\u52A8\uFF0C\u5B8C\u6210\u540E\u8DD1\u76F8\u5173\u6D4B\u8BD5\u5E76\u56DE\u62A5\u3002"
45
+ ].join("\n");
46
+ var DEFAULT_PREFS = {
47
+ org: void 0,
48
+ projectId: void 0,
49
+ repo: void 0,
50
+ milestone: void 0,
51
+ assignee: "@me",
52
+ state: "open",
53
+ handoffMode: "draft",
54
+ promptTemplate: DEFAULT_PROMPT_TEMPLATE,
55
+ pinned: void 0
56
+ };
57
+
58
+ // src/prompt.ts
59
+ function fill(template, token, value) {
60
+ return template.split(`{{${token}}}`).join(value);
61
+ }
62
+ function stateText(issue) {
63
+ if (issue.state === "OPEN") return "Open";
64
+ return issue.stateReason === "COMPLETED" ? "Closed (completed)" : `Closed (${issue.stateReason ?? "no reason"})`;
65
+ }
66
+ function prsText(issue) {
67
+ if (issue.linkedPRs.length === 0) return "\u65E0";
68
+ return issue.linkedPRs.map((pr) => {
69
+ const state = pr.merged ? "merged" : pr.state.toLowerCase();
70
+ return `#${String(pr.number)} (${state}${pr.checks === null ? "" : `, checks ${pr.checks.toLowerCase()}`})`;
71
+ }).join("\u3001");
72
+ }
73
+ function milestoneText(issue) {
74
+ if (issue.milestone === void 0) return "\u65E0";
75
+ const due = issue.milestone.dueOn === null ? "" : `, due ${issue.milestone.dueOn}`;
76
+ const progress = issue.milestone.progress === null ? "" : `, ${String(issue.milestone.progress)}%`;
77
+ return `${issue.milestone.title}${due}${progress}`;
78
+ }
79
+ function priorityText(issue) {
80
+ if (issue.priority === void 0) return "\u65E0";
81
+ const source = issue.priority.source === "project" ? "project field" : issue.priority.source === "issue-field" ? "issue field" : "label";
82
+ return `${issue.priority.name} (${source})`;
83
+ }
84
+ function renderPrompt(issue, template) {
85
+ const source = template === "" ? DEFAULT_PROMPT_TEMPLATE : template;
86
+ let text = source;
87
+ text = fill(text, "repo", issue.repo);
88
+ text = fill(text, "number", String(issue.number));
89
+ text = fill(text, "title", issue.title);
90
+ text = fill(text, "url", issue.url);
91
+ text = fill(text, "state", stateText(issue));
92
+ text = fill(text, "milestone", milestoneText(issue));
93
+ text = fill(text, "priority", priorityText(issue));
94
+ text = fill(text, "assignees", issue.assignees.length === 0 ? "\u672A\u6307\u6D3E" : issue.assignees.map((a) => a.login).join(", "));
95
+ text = fill(text, "labels", issue.labels.length === 0 ? "\u65E0" : issue.labels.map((l) => l.name).join(", "));
96
+ text = fill(text, "prs", prsText(issue));
97
+ if (text.length > 8e3) return `${text.slice(0, 7990)}
98
+ \u2026\uFF08\u5DF2\u622A\u65AD\uFF09`;
99
+ return text;
100
+ }
101
+ var EMPTY_DRAFT_HOLD = "\u200B\n";
102
+ function composeHandoffPrompt(prompt, memo) {
103
+ const extra = memo.replace(/\u200b/g, "").replace(/^\n+/, "").trim();
104
+ return extra === "" ? prompt : `${prompt}
105
+
106
+ ${extra}`;
107
+ }
108
+
109
+ // src/client/views/Dock.tsx
110
+ var import_react = require("react");
111
+
112
+ // src/client/views/format.ts
113
+ var MINUTES_PER_HOUR = 60;
114
+ var HEX_COLOR = /^[0-9a-f]{3}$|^[0-9a-f]{6}$/i;
115
+ function normalizeHex(hex) {
116
+ const cleaned = hex.trim().replace(/^#/, "");
117
+ if (!HEX_COLOR.test(cleaned)) return void 0;
118
+ if (cleaned.length === 3) {
119
+ return cleaned.split("").map((digit) => `${digit}${digit}`).join("").toLowerCase();
120
+ }
121
+ return cleaned.toLowerCase();
122
+ }
123
+ function linearize(channel) {
124
+ const value = channel / 255;
125
+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
126
+ }
127
+ function labelTextColor(hex) {
128
+ const normalized = normalizeHex(hex);
129
+ if (normalized === void 0) return "#ffffff";
130
+ const red = Number.parseInt(normalized.slice(0, 2), 16);
131
+ const green = Number.parseInt(normalized.slice(2, 4), 16);
132
+ const blue = Number.parseInt(normalized.slice(4, 6), 16);
133
+ const luminance = 0.2126 * linearize(red) + 0.7152 * linearize(green) + 0.0722 * linearize(blue);
134
+ return luminance > 0.5 ? "#111111" : "#ffffff";
135
+ }
136
+ function labelColorPair(hex) {
137
+ const normalized = normalizeHex(hex);
138
+ if (normalized === void 0) return void 0;
139
+ return { background: `#${normalized}`, text: labelTextColor(normalized) };
140
+ }
141
+ function relativeTime(iso, now = Date.now()) {
142
+ const timestamp = Date.parse(iso);
143
+ if (Number.isNaN(timestamp)) return "";
144
+ const elapsedMinutes = Math.max(0, now - timestamp) / 6e4;
145
+ if (elapsedMinutes < 1) return "just now";
146
+ if (elapsedMinutes < MINUTES_PER_HOUR) return `${String(Math.floor(elapsedMinutes))}m`;
147
+ const hours = elapsedMinutes / MINUTES_PER_HOUR;
148
+ if (hours < 24) return `${String(Math.floor(hours))}h`;
149
+ const days = hours / 24;
150
+ if (days < 7) return `${String(Math.floor(days))}d`;
151
+ const weeks = days / 7;
152
+ if (weeks < 5) return `${String(Math.floor(weeks))}w`;
153
+ const months = days / 30;
154
+ if (months < 12) return `${String(Math.floor(months))}mo`;
155
+ return `${String(Math.floor(days / 365))}y`;
156
+ }
157
+ function formatDue(iso) {
158
+ if (iso === null || iso === void 0 || iso === "") return "";
159
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso);
160
+ if (dateOnly !== null) {
161
+ const [, year = "", month2 = "", day2 = ""] = dateOnly;
162
+ return `${year}-${month2}-${day2}`;
163
+ }
164
+ const parsed = new Date(iso);
165
+ if (Number.isNaN(parsed.getTime())) return iso;
166
+ const month = String(parsed.getMonth() + 1).padStart(2, "0");
167
+ const day = String(parsed.getDate()).padStart(2, "0");
168
+ return `${String(parsed.getFullYear())}-${month}-${day}`;
169
+ }
170
+ function priorityTone(name) {
171
+ const key = name.trim().toLowerCase();
172
+ if (key.startsWith("p0") || key === "urgent" || key === "critical" || key === "blocker") return "error";
173
+ if (key.startsWith("p1") || key === "high") return "warn";
174
+ if (key.startsWith("p2") || key === "medium" || key === "normal") return "info";
175
+ return "neutral";
176
+ }
177
+ function prioritySourceLabel(source) {
178
+ switch (source) {
179
+ case "project":
180
+ return "panel.priority.project";
181
+ case "issue-field":
182
+ return "panel.priority.issueField";
183
+ case "label":
184
+ return "panel.priority.label";
185
+ }
186
+ }
187
+ function stateLabelKey(state) {
188
+ return state === "OPEN" ? "panel.state.open" : "panel.state.closed";
189
+ }
190
+ function stateTone(state, stateReason) {
191
+ if (state === "OPEN") return "success";
192
+ if (stateReason === "NOT_PLANNED" || stateReason === "DUPLICATE") return "neutral";
193
+ return "info";
194
+ }
195
+ function prGlyph(pr) {
196
+ if (pr.merged) return { glyph: "\u25C6", tone: "info", label: "panel.merged" };
197
+ if (pr.isDraft) return { glyph: "\u25CD", tone: "neutral", label: "panel.draft" };
198
+ if (pr.state === "OPEN") return { glyph: "\u25CF", tone: "success", label: "panel.openPR" };
199
+ return { glyph: "\u2715", tone: "error", label: "panel.closedPR" };
200
+ }
201
+ function checksGlyph(pr) {
202
+ switch (pr.checks) {
203
+ case null:
204
+ return void 0;
205
+ case "SUCCESS":
206
+ return { glyph: "\u2713", tone: "success", label: "panel.checks.success" };
207
+ case "FAILURE":
208
+ case "ERROR":
209
+ return { glyph: "\u2715", tone: "error", label: "panel.checks.failure" };
210
+ case "PENDING":
211
+ case "EXPECTED":
212
+ return { glyph: "\u2026", tone: "warn", label: "panel.checks.pending" };
213
+ default:
214
+ return { glyph: "\u2013", tone: "neutral", label: "panel.checks.none" };
215
+ }
216
+ }
217
+ function reviewGlyph(pr) {
218
+ switch (pr.reviewDecision) {
219
+ case null:
220
+ return void 0;
221
+ case "APPROVED":
222
+ return { glyph: "\u2713", tone: "success", label: "panel.review.approved" };
223
+ case "CHANGES_REQUESTED":
224
+ return { glyph: "\u2715", tone: "error", label: "panel.review.changes" };
225
+ case "REVIEW_REQUIRED":
226
+ return { glyph: "\u25D4", tone: "warn", label: "panel.review.required" };
227
+ }
228
+ }
229
+ function labelsWithoutPriority(card) {
230
+ const priority = card.priority;
231
+ if (priority === void 0 || priority.source !== "label") return card.labels;
232
+ const name = priority.name.toLowerCase();
233
+ return card.labels.filter((label) => label.name.toLowerCase() !== name);
234
+ }
235
+
236
+ // src/client/views/Icon.tsx
237
+ var import_jsx_runtime = require("react/jsx-runtime");
238
+ function Glyph({ size = 14, children }) {
239
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
240
+ "svg",
241
+ {
242
+ width: size,
243
+ height: size,
244
+ viewBox: "0 0 24 24",
245
+ fill: "none",
246
+ stroke: "currentColor",
247
+ strokeWidth: 1.7,
248
+ strokeLinecap: "round",
249
+ strokeLinejoin: "round",
250
+ "aria-hidden": "true",
251
+ focusable: "false",
252
+ children
253
+ }
254
+ );
255
+ }
256
+ function GitHubIcon({ size = 16, active }) {
257
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
258
+ "svg",
259
+ {
260
+ width: size,
261
+ height: size,
262
+ viewBox: "0 0 24 24",
263
+ fill: "none",
264
+ stroke: "currentColor",
265
+ strokeWidth: 1.8,
266
+ strokeLinecap: "round",
267
+ strokeLinejoin: "round",
268
+ "aria-hidden": "true",
269
+ focusable: "false",
270
+ children: [
271
+ active === true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "0", y: "0", width: "24", height: "24", rx: "6", fill: "currentColor", opacity: 0.1, stroke: "none" }),
272
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7", cy: "7", r: "3.1" }),
273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7", cy: "7", r: "1", fill: "currentColor", stroke: "none" }),
274
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M7 10.2v3.3a4.5 4.5 0 0 0 4.5 4.5h2.3" }),
275
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "17", cy: "18", r: "2.4" }),
276
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17 15.5v-6" }),
277
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "17", cy: "7", r: "2.4" })
278
+ ]
279
+ }
280
+ );
281
+ }
282
+ function CloseGlyph(props) {
283
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { ...props, children: [
284
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 6l12 12" }),
285
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6L6 18" })
286
+ ] });
287
+ }
288
+ function SearchGlyph(props) {
289
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { ...props, children: [
290
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "10.5", cy: "10.5", r: "6.2" }),
291
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15.2 15.2L20 20" })
292
+ ] });
293
+ }
294
+ function RefreshGlyph(props) {
295
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { ...props, children: [
296
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 12a8 8 0 1 1-2.4-5.7" }),
297
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 4v4.6h-4.6" })
298
+ ] });
299
+ }
300
+ function LinkGlyph(props) {
301
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { ...props, children: [
302
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10.3 13.7a4 4 0 0 0 5.7 0l2.7-2.7a4 4 0 0 0-5.7-5.7l-1.4 1.4" }),
303
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13.7 10.3a4 4 0 0 0-5.7 0l-2.7 2.7a4 4 0 1 0 5.7 5.7l1.4-1.4" })
304
+ ] });
305
+ }
306
+ function CommentGlyph(props) {
307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Glyph, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 15a3 3 0 0 1-3 3H9l-5 3V7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3z" }) });
308
+ }
309
+ function CopyGlyph(props) {
310
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { ...props, children: [
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "9", y: "9", width: "11", height: "11", rx: "2" }),
312
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 15V6a2 2 0 0 1 2-2h9" })
313
+ ] });
314
+ }
315
+ function ExternalGlyph(props) {
316
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { ...props, children: [
317
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 5h5v5" }),
318
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M19 5l-8.5 8.5" }),
319
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 14.5V18a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4" })
320
+ ] });
321
+ }
322
+ function PlusGlyph(props) {
323
+ const { size = 14 } = props;
324
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 16 16", width: size, height: size, fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 3.5v9M3.5 8h9", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }) });
325
+ }
326
+
327
+ // src/client/views/controls.tsx
328
+ var import_jsx_runtime2 = require("react/jsx-runtime");
329
+ var TONE = {
330
+ neutral: {
331
+ fg: "var(--dsw-alias-label-secondary)",
332
+ bg: "var(--dsw-alias-bg-layer-2)",
333
+ border: "var(--dsw-alias-border-l2)",
334
+ dot: "var(--dsw-alias-label-tertiary)"
335
+ },
336
+ success: {
337
+ fg: "var(--dsw-alias-state-success-primary)",
338
+ bg: "var(--dsw-alias-state-success-tertiary, var(--dsw-alias-bg-layer-2))",
339
+ border: "transparent",
340
+ dot: "var(--dsw-alias-state-success-primary)"
341
+ },
342
+ warn: {
343
+ fg: "var(--dsw-alias-state-warn-primary)",
344
+ bg: "var(--dsw-alias-state-warn-tertiary, var(--dsw-alias-bg-layer-2))",
345
+ border: "transparent",
346
+ dot: "var(--dsw-alias-state-warn-primary)"
347
+ },
348
+ error: {
349
+ fg: "var(--dsw-alias-state-error-primary)",
350
+ bg: "var(--dsw-alias-state-error-secondary, var(--dsw-alias-bg-layer-2))",
351
+ border: "transparent",
352
+ dot: "var(--dsw-alias-state-error-primary)"
353
+ },
354
+ info: {
355
+ fg: "var(--dsw-alias-state-business-primary, var(--dsw-alias-link))",
356
+ bg: "var(--dsw-alias-state-business-tertiary, var(--dsw-alias-bg-layer-2))",
357
+ border: "transparent",
358
+ dot: "var(--dsw-alias-state-business-primary, var(--dsw-alias-link))"
359
+ }
360
+ };
361
+ var PROJECT_SCOPE_COMMAND = "gh auth refresh -h github.com -s read:project";
362
+ function Button({ children, onClick, variant = "outline", size = "md", disabled, title, ariaLabel }) {
363
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
364
+ "button",
365
+ {
366
+ type: "button",
367
+ className: `gh-btn gh-btn-${variant} gh-btn-${size}`,
368
+ onClick,
369
+ disabled,
370
+ title,
371
+ "aria-label": ariaLabel,
372
+ children
373
+ }
374
+ );
375
+ }
376
+ function Chip({ label, color, tone = "neutral", dot, title }) {
377
+ const pair = color === void 0 ? void 0 : labelColorPair(color);
378
+ const toneStyle = TONE[tone];
379
+ const style = pair === void 0 ? { background: toneStyle.bg, color: toneStyle.fg, borderColor: toneStyle.border } : { background: pair.background, color: pair.text, borderColor: "transparent" };
380
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "gh-chip", style, title, children: [
381
+ dot === true && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-dot", style: { background: toneStyle.dot }, "aria-hidden": "true" }),
382
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-chip-label", children: label })
383
+ ] });
384
+ }
385
+ function Badge({ children, tone = "neutral", title }) {
386
+ const toneStyle = TONE[tone];
387
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
388
+ "span",
389
+ {
390
+ className: "gh-badge",
391
+ style: { background: toneStyle.bg, color: toneStyle.fg, borderColor: toneStyle.border },
392
+ title,
393
+ children
394
+ }
395
+ );
396
+ }
397
+ function Pill({ children, tone = "neutral", dot, title }) {
398
+ const toneStyle = TONE[tone];
399
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
400
+ "span",
401
+ {
402
+ className: "gh-pill",
403
+ style: { background: toneStyle.bg, color: toneStyle.fg, borderColor: toneStyle.border },
404
+ title,
405
+ children: [
406
+ dot === true && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-dot", style: { background: toneStyle.dot }, "aria-hidden": "true" }),
407
+ children
408
+ ]
409
+ }
410
+ );
411
+ }
412
+ function ProgressBar({ value, width, label }) {
413
+ const clamped = Math.max(0, Math.min(100, Math.round(value)));
414
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
415
+ "div",
416
+ {
417
+ className: "gh-progress",
418
+ role: "progressbar",
419
+ "aria-valuemin": 0,
420
+ "aria-valuemax": 100,
421
+ "aria-valuenow": clamped,
422
+ "aria-label": label,
423
+ style: width === void 0 ? void 0 : { width },
424
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gh-progress-fill", style: { width: `${String(clamped)}%` } })
425
+ }
426
+ );
427
+ }
428
+ function Select({ options, value, onChange, label, ariaLabel, disabled, placeholder }) {
429
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "gh-select-wrap", children: [
430
+ label !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-field-label", children: label }),
431
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
432
+ "select",
433
+ {
434
+ className: "gh-select",
435
+ value: value ?? "",
436
+ "aria-label": ariaLabel ?? label,
437
+ disabled,
438
+ onChange: (event) => onChange(event.target.value),
439
+ children: [
440
+ placeholder !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "", disabled: true, children: placeholder }),
441
+ options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))
442
+ ]
443
+ }
444
+ )
445
+ ] });
446
+ }
447
+ function TextInput({ value, onChange, ariaLabel, placeholder, disabled }) {
448
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
449
+ "input",
450
+ {
451
+ className: "gh-input",
452
+ type: "text",
453
+ value,
454
+ "aria-label": ariaLabel,
455
+ placeholder,
456
+ disabled,
457
+ onChange: (event) => onChange(event.target.value)
458
+ }
459
+ );
460
+ }
461
+ function TextArea({ value, onChange, ariaLabel, rows = 8, mono }) {
462
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
463
+ "textarea",
464
+ {
465
+ className: `gh-textarea${mono === true ? " gh-textarea-mono" : ""}`,
466
+ value,
467
+ rows,
468
+ "aria-label": ariaLabel,
469
+ spellCheck: false,
470
+ onChange: (event) => onChange(event.target.value)
471
+ }
472
+ );
473
+ }
474
+ function IconButton({ label, children, onClick, disabled, active }) {
475
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
476
+ "button",
477
+ {
478
+ type: "button",
479
+ className: `gh-icon-btn${active === true ? " gh-icon-btn-active" : ""}`,
480
+ "aria-label": label,
481
+ title: label,
482
+ onClick,
483
+ disabled,
484
+ children
485
+ }
486
+ );
487
+ }
488
+ function Spinner({ size = 14 }) {
489
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-spinner", style: { width: size, height: size }, "aria-hidden": "true" });
490
+ }
491
+ function EmptyState({ title, hint, icon, action }) {
492
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-empty", children: [
493
+ icon !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gh-empty-icon", children: icon }),
494
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gh-empty-title", children: title }),
495
+ hint !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gh-empty-hint", children: hint }),
496
+ action !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "gh-empty-action", children: action })
497
+ ] });
498
+ }
499
+ function ErrorBanner({ message, retryLabel, onRetry, children }) {
500
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-error", role: "alert", children: [
501
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-error-row", children: [
502
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-error-glyph", "aria-hidden": "true", children: "!" }),
503
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-error-text", children: message }),
504
+ onRetry !== void 0 && retryLabel !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { size: "sm", variant: "ghost", onClick: onRetry, children: retryLabel })
505
+ ] }),
506
+ children
507
+ ] });
508
+ }
509
+ function Toast({ text, onDismiss, dismissLabel }) {
510
+ if (text === "") return null;
511
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-toast", role: "status", children: [
512
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "gh-toast-text", children: text }),
513
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "gh-toast-close", "aria-label": dismissLabel, title: dismissLabel, onClick: onDismiss, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CloseGlyph, { size: 12 }) })
514
+ ] });
515
+ }
516
+ function CommandBlock({ command, copyLabel, onCopy }) {
517
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "gh-command", children: [
518
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { className: "gh-command-text", children: command }),
519
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Button, { size: "sm", variant: "ghost", onClick: onCopy, children: [
520
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopyGlyph, { size: 12 }),
521
+ copyLabel
522
+ ] })
523
+ ] });
524
+ }
525
+ function StyleSheet({ chunks }) {
526
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: chunks.join("\n") });
527
+ }
528
+ var CONTROLS_CSS = `
529
+ .gh-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;box-sizing:border-box;border:0.5px solid transparent;border-radius:var(--dsw-radius-md,8px);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;cursor:pointer;white-space:nowrap;text-decoration:none;transition:background-color .15s,border-color .15s,color .15s;color:var(--dsw-alias-label-primary);background:transparent}
530
+ .gh-btn-md{height:32px;padding:0 12px}
531
+ .gh-btn-sm{height:26px;padding:0 8px;font-size:12px;border-radius:var(--dsw-radius-sm,6px)}
532
+ .gh-btn-primary{background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-state-business-primary,var(--dsw-alias-link)));color:var(--dsw-alias-label-primary-foreground,#fff)}
533
+ .gh-btn-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover,var(--dsw-alias-state-business-primary,var(--dsw-alias-link)))}
534
+ .gh-btn-outline{border-color:var(--dsw-alias-border-l3);color:var(--dsw-alias-label-primary)}
535
+ .gh-btn-outline:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l2)}
536
+ .gh-btn-ghost{color:var(--dsw-alias-label-secondary)}
537
+ .gh-btn-ghost:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
538
+ .gh-btn:disabled{opacity:.45;cursor:default}
539
+ .gh-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;box-sizing:border-box;border:0.5px solid transparent;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;flex:none}
540
+ .gh-icon-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
541
+ .gh-icon-btn-active{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
542
+ .gh-icon-btn:disabled{opacity:.45;cursor:default}
543
+ .gh-chip{display:inline-flex;align-items:center;gap:4px;box-sizing:border-box;min-width:0;max-width:180px;height:20px;padding:0 7px;border:0.5px solid transparent;border-radius:var(--dsw-radius-sm,6px);font-size:12px;line-height:18px;white-space:nowrap;vertical-align:middle}
544
+ .gh-chip-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
545
+ .gh-badge{display:inline-flex;align-items:center;gap:4px;box-sizing:border-box;max-width:100%;height:20px;padding:0 7px;border:0.5px solid transparent;border-radius:var(--dsw-radius-sm,6px);font-size:12px;line-height:18px;white-space:nowrap;vertical-align:middle}
546
+ .gh-pill{display:inline-flex;align-items:center;gap:6px;box-sizing:border-box;min-height:22px;padding:0 10px;border:0.5px solid transparent;border-radius:999px;font-size:12px;line-height:18px;white-space:nowrap}
547
+ .gh-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}
548
+ .gh-progress{position:relative;height:4px;border-radius:999px;background:var(--dsw-alias-bg-layer-3);overflow:hidden;flex:none}
549
+ .gh-progress-fill{height:100%;border-radius:999px;background:var(--dsw-alias-state-business-primary,var(--dsw-alias-link));transition:width .2s}
550
+ .gh-field-label{font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
551
+ .gh-select-wrap{display:inline-flex;align-items:center;gap:6px;min-width:0}
552
+ .gh-select{box-sizing:border-box;height:28px;max-width:240px;padding:0 6px;border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);cursor:pointer}
553
+ .gh-select:hover:not(:disabled){border-color:var(--dsw-alias-border-l2)}
554
+ .gh-select:disabled{opacity:.5;cursor:default}
555
+ .gh-input{box-sizing:border-box;height:32px;width:100%;padding:0 10px;border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px}
556
+ .gh-input::placeholder{color:var(--dsw-alias-label-tertiary)}
557
+ .gh-input:hover:not(:disabled){border-color:var(--dsw-alias-border-l2)}
558
+ .gh-input:focus{border-color:var(--dsw-alias-state-business-primary,var(--dsw-alias-link))}
559
+ .gh-textarea{box-sizing:border-box;width:100%;padding:8px 10px;border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;resize:vertical;min-height:80px}
560
+ .gh-textarea:hover{border-color:var(--dsw-alias-border-l2)}
561
+ .gh-textarea:focus{border-color:var(--dsw-alias-state-business-primary,var(--dsw-alias-link))}
562
+ .gh-textarea-mono{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace)}
563
+ .gh-spinner{display:inline-block;box-sizing:border-box;border:1.5px solid var(--dsw-alias-border-l3);border-top-color:var(--dsw-alias-label-secondary);border-radius:50%;animation:gh-spin .8s linear infinite;flex:none}
564
+ .gh-empty{display:flex;flex-direction:column;align-items:center;gap:6px;padding:44px 20px;text-align:center;color:var(--dsw-alias-label-tertiary)}
565
+ .gh-empty-icon{color:var(--dsw-alias-label-tertiary);margin-bottom:4px;display:flex}
566
+ .gh-empty-title{font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;color:var(--dsw-alias-label-secondary)}
567
+ .gh-empty-hint{font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary);max-width:420px}
568
+ .gh-empty-action{margin-top:8px}
569
+ .gh-error{display:flex;flex-direction:column;gap:8px;box-sizing:border-box;padding:10px 12px;border:0.5px solid var(--dsw-alias-state-error-primary);border-radius:var(--dsw-radius-lg,12px);background:var(--dsw-alias-state-error-secondary,var(--dsw-alias-bg-layer-1))}
570
+ .gh-error-row{display:flex;align-items:flex-start;gap:8px}
571
+ .gh-error-glyph{flex:none;color:var(--dsw-alias-state-error-primary);font-weight:600;line-height:20px}
572
+ .gh-error-text{flex:1;min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary)}
573
+ .gh-command{display:flex;align-items:center;gap:8px;flex-wrap:wrap;box-sizing:border-box;padding:6px 8px;border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1)}
574
+ .gh-command-text{flex:1;min-width:0;font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:20px;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
575
+ .gh-toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:40;display:inline-flex;align-items:center;gap:8px;box-sizing:border-box;max-width:min(480px,calc(100vw - 32px));padding:6px 8px 6px 12px;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-toast-bg,var(--dsw-alias-bg-layer-3));color:var(--dsw-alias-toast-label,var(--dsw-alias-label-primary));box-shadow:var(--dsw-shadow-lv3,0 6px 24px rgba(0,0,0,.18));font-size:12px;line-height:20px}
576
+ .gh-toast-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
577
+ .gh-toast-close{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:0;border-radius:var(--dsw-radius-xs,4px);background:transparent;color:inherit;cursor:pointer;flex:none;opacity:.75}
578
+ .gh-toast-close:hover{opacity:1}
579
+ .gh-btn:focus-visible,.gh-icon-btn:focus-visible,.gh-select:focus-visible,.gh-input:focus-visible,.gh-textarea:focus-visible,.gh-toast-close:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
580
+ @keyframes gh-spin{to{transform:rotate(360deg)}}
581
+ `.trim();
582
+
583
+ // src/client/views/Dock.tsx
584
+ var import_jsx_runtime3 = require("react/jsx-runtime");
585
+ var DOCK_CSS = `
586
+ .ghd-row{display:inline-flex;align-items:center;gap:6px;flex-wrap:nowrap;min-width:0;max-width:100%;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
587
+ .ghd-chip{display:inline-flex;align-items:center;gap:5px;box-sizing:border-box;height:22px;max-width:300px;min-width:0;padding:0 8px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;font-family:inherit;font-size:11px;line-height:18px}
588
+ .ghd-chip:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3)}
589
+ .ghd-chip:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
590
+ .ghd-dot{width:7px;height:7px;border-radius:50%;flex:none}
591
+ .ghd-state{flex:none;font-size:10px;line-height:14px}
592
+ .ghd-prefix{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
593
+ .ghd-num{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);flex:none}
594
+ .ghd-extra{flex:none;font-size:10px;line-height:14px;padding:0 4px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary)}
595
+ .ghd-pop{position:fixed;z-index:60;box-sizing:border-box;width:340px;max-width:calc(100vw - 16px);padding:12px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg,12px);background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));box-shadow:0 8px 24px rgba(0,0,0,.18);color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px}
596
+ .ghd-pop-head{display:flex;align-items:center;gap:8px;min-width:0}
597
+ .ghd-pop-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;color:var(--dsw-alias-label-secondary);text-decoration:none;white-space:nowrap}
598
+ .ghd-pop-ref:hover{color:var(--dsw-alias-link);text-decoration:underline}
599
+ .ghd-pop-spacer{flex:1}
600
+ .ghd-pop-title{margin-top:6px;font-weight:500;color:var(--dsw-alias-label-primary);display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden}
601
+ .ghd-pop-meta{margin-top:8px;display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
602
+ .ghd-pop-row{display:flex;gap:8px;min-width:0}
603
+ .ghd-pop-key{flex:none;width:64px;color:var(--dsw-alias-label-tertiary)}
604
+ .ghd-pop-val{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
605
+ .ghd-pop-actions{margin-top:10px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}
606
+ .ghd-pop-note{font-size:12px;color:var(--dsw-alias-label-tertiary)}
607
+ .ghd-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer}
608
+ .ghd-icon-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
609
+ `.trim();
610
+ function ChipPopover(props) {
611
+ const { chip, anchor, t, onClose, onOpenPanel, onRemove } = props;
612
+ const { card } = chip;
613
+ const state = stateTone(card.state, card.stateReason);
614
+ const pr = card.linkedPRs[0];
615
+ const prState = pr === void 0 ? void 0 : prGlyph(pr);
616
+ const repoShort = card.repo.split("/")[1] ?? card.repo;
617
+ const session = chip.sessions[0];
618
+ (0, import_react.useEffect)(() => {
619
+ const onKey = (event) => {
620
+ if (event.key === "Escape") onClose();
621
+ };
622
+ const onPointer = (event) => {
623
+ const target = event.target;
624
+ if (target?.closest(".ghd-pop") !== null || target?.closest(".ghd-chip") !== null) return;
625
+ onClose();
626
+ };
627
+ const onMove = () => onClose();
628
+ document.addEventListener("keydown", onKey);
629
+ document.addEventListener("mousedown", onPointer, true);
630
+ window.addEventListener("resize", onMove);
631
+ window.addEventListener("scroll", onMove, true);
632
+ return () => {
633
+ document.removeEventListener("keydown", onKey);
634
+ document.removeEventListener("mousedown", onPointer, true);
635
+ window.removeEventListener("resize", onMove);
636
+ window.removeEventListener("scroll", onMove, true);
637
+ };
638
+ }, [onClose]);
639
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop", style: { left: anchor.left, bottom: anchor.bottom }, role: "dialog", "aria-label": card.title, children: [
640
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, DOCK_CSS] }),
641
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-head", children: [
642
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GitHubIcon, { size: 13 }),
643
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "ghd-pop-ref", href: card.url, target: "_blank", rel: "noreferrer", children: `${repoShort}#${String(card.number)}` }),
644
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Badge, { tone: state, children: t(stateLabelKey(card.state)) }),
645
+ chip.state === "draft" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Badge, { tone: "warn", children: t("dock.pending") }),
646
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-spacer" }),
647
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "ghd-icon-btn", "aria-label": t("panel.close"), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CloseGlyph, { size: 12 }) })
648
+ ] }),
649
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ghd-pop-title", children: card.title === "" ? t("dock.loading") : card.title }),
650
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-meta", children: [
651
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-row", children: [
652
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-key", children: t("panel.repo") }),
653
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-val", children: card.repo })
654
+ ] }),
655
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-row", children: [
656
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-key", children: t("panel.milestone") }),
657
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-val", children: card.milestone === void 0 ? t("panel.noMilestone") : card.milestone.title })
658
+ ] }),
659
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-row", children: [
660
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-key", children: t("panel.priority") }),
661
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-val", children: card.priority === void 0 ? t("panel.noPriority") : card.priority.name })
662
+ ] }),
663
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-row", children: [
664
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-key", children: t("panel.linkedPRs") }),
665
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-val", children: pr === void 0 ? t("panel.noPRs") : `#${String(pr.number)} \xB7 ${t(prState?.label ?? "panel.noPRs")}` })
666
+ ] }),
667
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-row", children: [
668
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-key", children: t("dock.linked") }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-val", children: session === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-pop-note", children: t("dock.pending") }) : session.title })
670
+ ] })
671
+ ] }),
672
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-pop-actions", children: [
673
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Button, { size: "sm", variant: "outline", onClick: onOpenPanel, children: [
674
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ExternalGlyph, { size: 12 }),
675
+ t("panel.openInPanel")
676
+ ] }),
677
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button, { size: "sm", variant: "ghost", onClick: onRemove, children: chip.state === "draft" ? t("dock.removeDraft") : t("dock.unlink") })
678
+ ] })
679
+ ] });
680
+ }
681
+ function GitHubDock({ chips, t, onRemoveChip, onOpenChip }) {
682
+ const [openKey, setOpenKey] = (0, import_react.useState)(void 0);
683
+ const [anchor, setAnchor] = (0, import_react.useState)(void 0);
684
+ if (chips.length === 0) return null;
685
+ const toggle = (chip, element) => {
686
+ const key = `${chip.card.repo}#${String(chip.card.number)}`;
687
+ if (openKey === key) {
688
+ setOpenKey(void 0);
689
+ return;
690
+ }
691
+ const rect = element.getBoundingClientRect();
692
+ const width = 340;
693
+ const left = Math.min(Math.max(8, rect.left), window.innerWidth - width - 8);
694
+ setAnchor({ left, bottom: window.innerHeight - rect.top + 8 });
695
+ setOpenKey(key);
696
+ };
697
+ const open = openKey === void 0 ? void 0 : chips.find((chip) => `${chip.card.repo}#${String(chip.card.number)}` === openKey);
698
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
699
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ghd-row", "data-github-handoff": true, children: [
700
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, DOCK_CSS] }),
701
+ chips.map((chip) => {
702
+ const state = stateTone(chip.card.state, chip.card.stateReason);
703
+ const repoShort = chip.card.repo.split("/")[1] ?? chip.card.repo;
704
+ const key = `${chip.card.repo}#${String(chip.card.number)}`;
705
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
706
+ "button",
707
+ {
708
+ type: "button",
709
+ className: "ghd-chip",
710
+ "aria-expanded": openKey === key,
711
+ title: `${chip.card.repo}#${String(chip.card.number)}`,
712
+ onClick: (event) => toggle(chip, event.currentTarget),
713
+ children: [
714
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GitHubIcon, { size: 11 }),
715
+ chip.state !== "degraded" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
716
+ "span",
717
+ {
718
+ className: "ghd-dot",
719
+ style: { background: chip.card.state === "CLOSED" ? TONE.error.dot : TONE.success.dot },
720
+ "aria-label": t(stateLabelKey(chip.card.state))
721
+ }
722
+ ),
723
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-prefix", title: chip.card.repo, children: chip.card.repo }),
724
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-num", children: `#${String(chip.card.number)}` }),
725
+ chip.state === "draft" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ghd-extra", children: t("dock.pending") })
726
+ ]
727
+ },
728
+ key
729
+ );
730
+ })
731
+ ] }),
732
+ open !== void 0 && anchor !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
733
+ ChipPopover,
734
+ {
735
+ chip: open,
736
+ anchor,
737
+ t,
738
+ onClose: () => setOpenKey(void 0),
739
+ onOpenPanel: () => {
740
+ setOpenKey(void 0);
741
+ onOpenChip(open);
742
+ },
743
+ onRemove: () => {
744
+ setOpenKey(void 0);
745
+ onRemoveChip(open);
746
+ }
747
+ }
748
+ )
749
+ ] });
750
+ }
751
+
752
+ // src/client/views/DropZone.tsx
753
+ var import_jsx_runtime4 = require("react/jsx-runtime");
754
+ var DROPZONE_CSS = `
755
+ .ghz-bar{display:flex;align-items:center;gap:8px;box-sizing:border-box;margin-bottom:6px;padding:10px 12px;border:1px dashed var(--dsw-alias-state-business-primary,var(--dsw-alias-border-l3));border-radius:10px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;line-height:18px}
756
+ .ghz-bar strong{font-weight:600}
757
+ .ghz-hint{color:var(--dsw-alias-label-tertiary)}
758
+ `.trim();
759
+ function GitHubDropZone({ dragging, t, onDrop, onCancel }) {
760
+ if (dragging === void 0) return null;
761
+ const ref = `${dragging.repo}#${String(dragging.number)}`;
762
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
763
+ "div",
764
+ {
765
+ className: "ghz-bar",
766
+ "data-github-dropzone": true,
767
+ onDragOver: (event) => {
768
+ event.preventDefault();
769
+ event.dataTransfer.dropEffect = "copy";
770
+ },
771
+ onDrop: (event) => {
772
+ event.preventDefault();
773
+ event.stopPropagation();
774
+ onDrop();
775
+ },
776
+ children: [
777
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, DROPZONE_CSS] }),
778
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GitHubIcon, { size: 14 }),
779
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t("drop.release") }),
780
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: ref }),
781
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "ghz-hint", children: t("drop.hint") }),
782
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { flex: 1 } }),
783
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
784
+ "button",
785
+ {
786
+ type: "button",
787
+ className: "ghz-hint",
788
+ style: { border: 0, background: "transparent", cursor: "pointer", font: "inherit" },
789
+ onClick: onCancel,
790
+ children: t("drop.cancel")
791
+ }
792
+ )
793
+ ]
794
+ }
795
+ );
796
+ }
797
+
798
+ // src/client/views/Pending.tsx
799
+ var import_jsx_runtime5 = require("react/jsx-runtime");
800
+ var PENDING_CSS = `
801
+ .ghp3-row{position:absolute;top:8px;left:12px;right:12px;z-index:2;display:flex;align-items:center;gap:6px;min-width:0;height:22px;font-size:12px;line-height:18px;pointer-events:none}
802
+ .ghp3-chip{pointer-events:auto;display:inline-flex;align-items:center;gap:5px;box-sizing:border-box;height:22px;max-width:100%;padding:0 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font-size:11px;line-height:18px;cursor:pointer;border:0.5px solid var(--dsw-alias-border-l2)}
803
+ .ghp3-chip:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
804
+ .ghp3-chip:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
805
+ .ghp3-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
806
+ .ghp3-remove{pointer-events:auto;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;flex:none}
807
+ .ghp3-remove:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
808
+ `.trim();
809
+ function GitHubPendingChip(props) {
810
+ const { card, t, onOpenPanel, onRemove } = props;
811
+ const ref = `${card.repo}#${String(card.number)}`;
812
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "ghp3-row", "data-github-pending": true, children: [
813
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, PENDING_CSS] }),
814
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { type: "button", className: "ghp3-chip", title: `${ref} \xB7 ${card.title}
815
+ ${t("pending.tip")}`, onClick: onOpenPanel, children: [
816
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GitHubIcon, { size: 12 }),
817
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "ghp3-ref", children: ref })
818
+ ] }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "ghp3-remove", "aria-label": t("dock.removeDraft"), onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseGlyph, { size: 12 }) })
820
+ ] });
821
+ }
822
+
823
+ // src/client/views/Page.tsx
824
+ var import_react2 = require("react");
825
+
826
+ // src/client/views/IssueDetail.tsx
827
+ var import_jsx_runtime6 = require("react/jsx-runtime");
828
+ var ISSUE_DETAIL_CSS = `
829
+ .ghx-pane{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;flex:0 0 380px;width:380px;min-width:0;padding-left:20px;border-left:0.5px solid var(--dsw-alias-border-l2)}
830
+ .ghx-head{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}
831
+ .ghx-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
832
+ .ghx-ref:hover{color:var(--dsw-alias-link);text-decoration:underline}
833
+ .ghx-head-spacer{flex:1;min-width:0}
834
+ .ghx-title{margin:0;font-size:16px;line-height:24px;font-weight:500;overflow-wrap:anywhere;color:var(--dsw-alias-label-primary)}
835
+ .ghx-title a{color:inherit;text-decoration:none}
836
+ .ghx-title a:hover{text-decoration:underline}
837
+ .ghx-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
838
+ .ghx-actions-spacer{flex:1;min-width:0}
839
+ .ghx-inline-action{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:18px;cursor:pointer;padding:2px 4px;border-radius:6px;text-decoration:none;white-space:nowrap}
840
+ .ghx-inline-action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
841
+ .ghx-session-hint{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary)}
842
+ .ghx-session-list{display:flex;flex-direction:column;gap:6px}
843
+ .ghx-session{display:flex;align-items:center;gap:8px;min-width:0;padding:6px 8px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1)}
844
+ .ghx-session-dot{width:7px;height:7px;border-radius:50%;flex:none;background:var(--dsw-alias-state-success-primary)}
845
+ .ghx-session[data-available='no'] .ghx-session-dot{background:var(--dsw-alias-label-tertiary)}
846
+ .ghx-session-text{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}
847
+ .ghx-session-title{font-size:12px;line-height:16px;color:var(--dsw-alias-label-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
848
+ .ghx-session-ws{font-size:11px;line-height:15px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
849
+ .ghx-session-missing{font-size:11px;color:var(--dsw-alias-label-tertiary);flex:none}
850
+ .ghx-body{margin:0;max-height:320px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;box-sizing:border-box;padding:10px 12px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;color:var(--dsw-alias-label-primary)}
851
+ .ghx-section{display:flex;flex-direction:column;gap:6px}
852
+ .ghx-section-title{margin:0;font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-label-tertiary);text-transform:uppercase;letter-spacing:.02em}
853
+ .ghx-muted{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
854
+ .ghx-chips{display:flex;flex-wrap:wrap;gap:4px;align-items:center}
855
+ .ghx-assignees{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
856
+ .ghx-assignee{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
857
+ .ghx-avatar{width:18px;height:18px;border-radius:50%;flex:none;object-fit:cover}
858
+ .ghx-avatar-fallback{display:inline-flex;align-items:center;justify-content:center;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font-size:9px;font-weight:600;text-transform:uppercase}
859
+ .ghx-prs{display:flex;flex-direction:column;gap:6px}
860
+ .ghx-pr{display:flex;flex-direction:column;gap:2px;box-sizing:border-box;padding:6px 8px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-layer-1)}
861
+ .ghx-pr-head{display:flex;align-items:center;gap:6px;min-width:0;flex-wrap:wrap}
862
+ .ghx-pr-title{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
863
+ .ghx-pr-link{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:18px;color:var(--dsw-alias-link);text-decoration:none}
864
+ .ghx-pr-link:hover{text-decoration:underline}
865
+ .ghx-glyph{font-size:12px;line-height:1}
866
+ .ghx-skeleton{display:flex;flex-direction:column;gap:8px}
867
+ .ghx-skeleton-line{height:12px;border-radius:var(--dsw-radius-xs,4px);background:var(--dsw-alias-bg-skeleton,var(--dsw-alias-bg-layer-2));animation:gh-pulse 1.4s ease-in-out infinite}
868
+ @keyframes gh-pulse{0%,100%{opacity:.55}50%{opacity:1}}
869
+ `.trim();
870
+ function LinkedPRRow({ pr, t }) {
871
+ const state = prGlyph(pr);
872
+ const checks = checksGlyph(pr);
873
+ const review = reviewGlyph(pr);
874
+ const failing = pr.failingChecks ?? [];
875
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-pr", children: [
876
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-pr-head", children: [
877
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "ghx-pr-link", href: pr.url, target: "_blank", rel: "noreferrer", children: [
878
+ "#",
879
+ pr.number
880
+ ] }),
881
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Badge, { tone: state.tone, title: t(state.label), children: [
882
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-glyph", "aria-hidden": "true", children: state.glyph }),
883
+ t(state.label)
884
+ ] }),
885
+ checks !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { title: t(checks.label, { count: failing.length }), style: { color: TONE[checks.tone].dot }, children: [
886
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-glyph", "aria-hidden": "true", children: checks.glyph }),
887
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "ghx-muted", children: [
888
+ " ",
889
+ t(checks.label, { count: failing.length })
890
+ ] })
891
+ ] }),
892
+ review !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { title: t(review.label), style: { color: TONE[review.tone].dot }, children: [
893
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-glyph", "aria-hidden": "true", children: review.glyph }),
894
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "ghx-muted", children: [
895
+ " ",
896
+ t(review.label)
897
+ ] })
898
+ ] })
899
+ ] }),
900
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-pr-title", children: pr.title }),
901
+ failing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-muted", children: [
902
+ t("panel.checks.failure", { count: failing.length }),
903
+ ": ",
904
+ failing.slice(0, 4).join(", "),
905
+ failing.length > 4 ? "\u2026" : ""
906
+ ] })
907
+ ] });
908
+ }
909
+ function DetailFooter({ commentCount, updatedAt, t }) {
910
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-muted", children: [
911
+ t("panel.comments", { count: commentCount }),
912
+ " \xB7 ",
913
+ t("panel.updated", { time: relativeTime(updatedAt) })
914
+ ] });
915
+ }
916
+ function IssueDetailPane({ snapshot, actions, t, resolveSession }) {
917
+ const card = snapshot.detail ?? snapshot.selected;
918
+ if (card === void 0) return null;
919
+ const provisional = snapshot.detail === void 0 && snapshot.selected !== void 0 && snapshot.detailLoading;
920
+ const detail = snapshot.detail ?? (provisional ? { ...card, body: "", mentionedPRs: [] } : void 0);
921
+ const error = snapshot.error;
922
+ const detailFailed = detail === void 0 && !snapshot.detailLoading && error !== void 0;
923
+ const showHint = detail === void 0 && !snapshot.detailLoading && error === void 0;
924
+ const tone = stateTone(card.state, card.stateReason);
925
+ const body = detail?.body !== void 0 && detail.body !== "" ? detail.body : detail?.bodyExcerpt;
926
+ const sessionLinks = card.sessionLinks ?? [];
927
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("aside", { className: "ghx-pane", "aria-label": t("panel.detail"), children: [
928
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-head", children: [
929
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "ghx-ref", href: card.url, target: "_blank", rel: "noreferrer", children: [
930
+ card.repo,
931
+ "#",
932
+ card.number
933
+ ] }),
934
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone, children: t(stateLabelKey(card.state)) }),
935
+ card.priority !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: priorityTone(card.priority.name), title: t(prioritySourceLabel(card.priority.source)), children: card.priority.name }),
936
+ card.issueType !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "neutral", title: t("panel.type"), children: card.issueType.name }),
937
+ card.projectStatus !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { tone: "info", title: t("panel.project"), children: card.projectStatus.name }),
938
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-head-spacer" }),
939
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconButton, { label: t("panel.closeDetail"), onClick: () => actions.closeDetail(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CloseGlyph, { size: 14 }) })
940
+ ] }),
941
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { className: "ghx-title", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: card.url, target: "_blank", rel: "noreferrer", children: card.title }) }),
942
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-actions", children: [
943
+ sessionLinks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Button, { size: "sm", variant: "primary", onClick: () => actions.handoff(card), children: [
944
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PlusGlyph, { size: 12 }),
945
+ t("panel.handToAgent")
946
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
947
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
948
+ Button,
949
+ {
950
+ size: "sm",
951
+ variant: "primary",
952
+ onClick: () => actions.openSession(sessionLinks[sessionLinks.length - 1]?.sessionId ?? ""),
953
+ children: [
954
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LinkGlyph, { size: 12 }),
955
+ t("panel.openSession")
956
+ ]
957
+ }
958
+ ),
959
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Button, { size: "sm", variant: "outline", onClick: () => actions.handoff(card), children: [
960
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PlusGlyph, { size: 12 }),
961
+ t("panel.newSession")
962
+ ] })
963
+ ] }),
964
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-actions-spacer" }),
965
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "ghx-inline-action", href: card.url, target: "_blank", rel: "noreferrer", children: [
966
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ExternalGlyph, { size: 12 }),
967
+ t("panel.openOnGitHub")
968
+ ] }),
969
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "ghx-inline-action", onClick: () => actions.copyPrompt(card), children: [
970
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopyGlyph, { size: 12 }),
971
+ t("panel.copyPrompt")
972
+ ] })
973
+ ] }),
974
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
975
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.sessions") }),
976
+ sessionLinks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-muted", children: t("panel.noSession") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
977
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-session-hint", children: t("panel.sessionsHint") }),
978
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-session-list", children: sessionLinks.map((link) => {
979
+ const view = resolveSession(link.sessionId);
980
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
981
+ "div",
982
+ {
983
+ className: "ghx-session",
984
+ "data-available": view.available ? "yes" : "no",
985
+ children: [
986
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-session-dot", "aria-hidden": "true" }),
987
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "ghx-session-text", children: [
988
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-session-title", title: view.title, children: view.title }),
989
+ view.workspaceTitle !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-session-ws", children: view.workspaceTitle })
990
+ ] }),
991
+ view.available ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button, { size: "sm", variant: "outline", onClick: () => actions.openSession(link.sessionId), children: t("panel.enterSession") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-session-missing", children: t("panel.sessionUnavailable") }),
992
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
993
+ Button,
994
+ {
995
+ size: "sm",
996
+ variant: "ghost",
997
+ title: t("panel.unlinkSessionHint"),
998
+ onClick: () => actions.unlinkSession(card, link.sessionId),
999
+ children: t("panel.unlinkSession")
1000
+ }
1001
+ )
1002
+ ]
1003
+ },
1004
+ link.sessionId
1005
+ );
1006
+ }) })
1007
+ ] })
1008
+ ] }),
1009
+ detailFailed && error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1010
+ ErrorBanner,
1011
+ {
1012
+ message: t("panel.error", { message: error.message }),
1013
+ retryLabel: t("panel.retry"),
1014
+ onRetry: () => actions.selectIssue(card)
1015
+ }
1016
+ ),
1017
+ showHint && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(EmptyState, { title: t("panel.detail.empty"), icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(GitHubIcon, { size: 24 }) }),
1018
+ detail !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1019
+ provisional ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ghx-skeleton", "aria-hidden": "true", children: [
1020
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-skeleton-line", style: { width: "92%" } }),
1021
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-skeleton-line", style: { width: "78%" } }),
1022
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-skeleton-line", style: { width: "60%" } })
1023
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("pre", { className: "ghx-body", style: { whiteSpace: "pre-wrap" }, children: body === void 0 || body === "" ? t("panel.noBody") : body }),
1024
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
1025
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.milestone") }),
1026
+ detail.milestone === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-muted", children: t("panel.noMilestone") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1027
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { fontSize: "var(--dsh-content-font-size-secondary, 13px)", lineHeight: "20px", fontWeight: 500 }, children: detail.milestone.title }),
1028
+ detail.milestone.dueOn !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-muted", children: t("panel.due", { date: formatDue(detail.milestone.dueOn) }) }),
1029
+ detail.milestone.progress !== null && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1030
+ ProgressBar,
1031
+ {
1032
+ value: detail.milestone.progress,
1033
+ label: t("panel.progress", { percent: detail.milestone.progress })
1034
+ }
1035
+ )
1036
+ ] })
1037
+ ] }),
1038
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
1039
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.labels") }),
1040
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-chips", children: labelsWithoutPriority(detail).length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-muted", children: "\u2014" }) : labelsWithoutPriority(detail).map((label) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Chip, { label: label.name, color: label.color }, label.name)) })
1041
+ ] }),
1042
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
1043
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.assignees") }),
1044
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-assignees", children: detail.assignees.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-muted", children: t("panel.noAssignees") }) : detail.assignees.map((assignee) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "ghx-assignee", children: [
1045
+ assignee.avatarUrl === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ghx-avatar ghx-avatar-fallback", "aria-hidden": "true", children: assignee.login.slice(0, 1) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className: "ghx-avatar", src: assignee.avatarUrl, alt: "", width: 18, height: 18, loading: "lazy" }),
1046
+ assignee.login
1047
+ ] }, assignee.login)) })
1048
+ ] }),
1049
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
1050
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.linkedPRs") }),
1051
+ detail.linkedPRs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-muted", children: t("panel.noPRs") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-prs", children: detail.linkedPRs.map((pr) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LinkedPRRow, { pr, t }, pr.number)) })
1052
+ ] }),
1053
+ snapshot.mentionedLoading === true && detail.mentionedPRs.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
1054
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.mentionedPRs") }),
1055
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-muted", children: t("panel.loading") })
1056
+ ] }),
1057
+ detail.mentionedPRs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "ghx-section", children: [
1058
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "ghx-section-title", children: t("panel.mentionedPRs") }),
1059
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ghx-prs", children: detail.mentionedPRs.map((pr) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LinkedPRRow, { pr, t }, pr.number)) })
1060
+ ] }),
1061
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DetailFooter, { commentCount: detail.commentCount, updatedAt: detail.updatedAt, t })
1062
+ ] })
1063
+ ] });
1064
+ }
1065
+
1066
+ // src/client/views/IssueRow.tsx
1067
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1068
+ var ISSUE_MIME = "application/x-dsh-github-issue+json";
1069
+ var MAX_LABELS = 4;
1070
+ var MAX_ASSIGNEES = 3;
1071
+ var MAX_PRS = 2;
1072
+ var ISSUE_ROW_CSS = `
1073
+ .ghr-row{display:flex;flex-direction:column;gap:4px;box-sizing:border-box;padding:10px 8px;border-top:0.5px solid var(--dsw-alias-border-l2);cursor:pointer;outline:none;text-align:left;color:var(--dsw-alias-label-primary)}
1074
+ .ghr-row:first-child{border-top:0}
1075
+ .ghr-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
1076
+ .ghr-row:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px;border-radius:var(--dsw-radius-sm,6px)}
1077
+ .ghr-row[aria-pressed=true]{background:var(--dsw-alias-interactive-bg-hover)}
1078
+ .ghr-top{display:flex;align-items:center;gap:6px;min-width:0}
1079
+ .ghr-dot{width:8px;height:8px;border-radius:50%;flex:none}
1080
+ .ghr-ref{flex:none;font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);text-decoration:none;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1081
+ .ghr-ref:hover{color:var(--dsw-alias-link);text-decoration:underline}
1082
+ .ghr-private{display:inline-flex;align-items:center;color:var(--dsw-alias-label-tertiary);flex:none}
1083
+ .ghr-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;font-size:var(--dsh-content-font-size,14px);line-height:20px;font-weight:500;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
1084
+ .ghr-meta{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0;color:var(--dsw-alias-label-tertiary)}
1085
+ .ghr-milestone{display:inline-flex;align-items:center;gap:6px;min-width:0;max-width:260px}
1086
+ .ghr-meta-item{display:inline-flex;align-items:center;gap:3px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
1087
+ .ghr-avatar{width:16px;height:16px;border-radius:50%;flex:none;object-fit:cover}
1088
+ .ghr-avatar-fallback{display:inline-flex;align-items:center;justify-content:center;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font-size:9px;line-height:1;font-weight:600;text-transform:uppercase}
1089
+ .ghr-pr{display:inline-flex;align-items:center;gap:2px;padding:0 4px;border-radius:var(--dsw-radius-xs,4px);font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);text-decoration:none;background:var(--dsw-alias-bg-layer-2);white-space:nowrap}
1090
+ .ghr-pr:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
1091
+ .ghr-glyph{font-size:11px;line-height:1}
1092
+ `.trim();
1093
+ function IssueRow({ card, t, selected, onSelect, promptText }) {
1094
+ const tone = stateTone(card.state, card.stateReason);
1095
+ const updated = relativeTime(card.updatedAt);
1096
+ const renderable = labelsWithoutPriority(card);
1097
+ const labels = renderable.slice(0, MAX_LABELS);
1098
+ const hiddenLabels = renderable.length - labels.length;
1099
+ const assignees = card.assignees.slice(0, MAX_ASSIGNEES);
1100
+ const prs = card.linkedPRs.slice(0, MAX_PRS);
1101
+ const hiddenPRs = card.linkedPRs.length - prs.length;
1102
+ const handleDragStart = (event) => {
1103
+ const transfer = event.dataTransfer;
1104
+ transfer.setData("text/plain", promptText(card));
1105
+ transfer.setData(ISSUE_MIME, JSON.stringify(card));
1106
+ transfer.effectAllowed = "copy";
1107
+ };
1108
+ const handleKeyDown = (event) => {
1109
+ if (event.target !== event.currentTarget) return;
1110
+ if (event.key !== "Enter" && event.key !== " ") return;
1111
+ event.preventDefault();
1112
+ onSelect(card);
1113
+ };
1114
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1115
+ "div",
1116
+ {
1117
+ className: "ghr-row",
1118
+ role: "button",
1119
+ tabIndex: 0,
1120
+ "aria-pressed": selected,
1121
+ draggable: true,
1122
+ onClick: () => onSelect(card),
1123
+ onKeyDown: handleKeyDown,
1124
+ onDragStart: handleDragStart,
1125
+ "data-issue-id": card.id,
1126
+ children: [
1127
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ghr-top", children: [
1128
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ghr-dot", style: { background: TONE[tone].dot }, title: t(stateLabelKey(card.state)), "aria-hidden": "true" }),
1129
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1130
+ "a",
1131
+ {
1132
+ className: "ghr-ref",
1133
+ href: card.url,
1134
+ target: "_blank",
1135
+ rel: "noreferrer",
1136
+ onClick: (event) => event.stopPropagation(),
1137
+ children: [
1138
+ card.repo,
1139
+ "#",
1140
+ card.number
1141
+ ]
1142
+ }
1143
+ ),
1144
+ card.isPrivate && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ghr-private", role: "img", "aria-label": t("panel.private"), title: t("panel.private"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LinkGlyph, { size: 11 }) })
1145
+ ] }),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "ghr-title", children: card.title }),
1147
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ghr-meta", children: [
1148
+ card.priority !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1149
+ Chip,
1150
+ {
1151
+ label: card.priority.name,
1152
+ tone: priorityTone(card.priority.name),
1153
+ dot: true,
1154
+ title: `${t("panel.priority")} \xB7 ${t(prioritySourceLabel(card.priority.source))}`
1155
+ }
1156
+ ),
1157
+ card.milestone !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1158
+ "span",
1159
+ {
1160
+ className: "ghr-milestone",
1161
+ title: card.milestone.dueOn === null ? t("panel.milestone") : t("panel.due", { date: formatDue(card.milestone.dueOn) }),
1162
+ children: [
1163
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Chip, { label: card.milestone.title, tone: "info", dot: true }),
1164
+ card.milestone.progress !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1165
+ ProgressBar,
1166
+ {
1167
+ value: card.milestone.progress,
1168
+ width: 40,
1169
+ label: t("panel.progress", { percent: card.milestone.progress })
1170
+ }
1171
+ )
1172
+ ]
1173
+ }
1174
+ ),
1175
+ labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Chip, { label: label.name, color: label.color, title: label.name }, label.name)),
1176
+ hiddenLabels > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Chip, { label: t("panel.more", { count: hiddenLabels }) }),
1177
+ assignees.map((assignee) => assignee.avatarUrl === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ghr-avatar ghr-avatar-fallback", title: assignee.login, "aria-label": assignee.login, children: assignee.login.slice(0, 1) }, assignee.login) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1178
+ "img",
1179
+ {
1180
+ className: "ghr-avatar",
1181
+ src: assignee.avatarUrl,
1182
+ alt: assignee.login,
1183
+ title: assignee.login,
1184
+ width: 16,
1185
+ height: 16,
1186
+ loading: "lazy"
1187
+ },
1188
+ assignee.login
1189
+ )),
1190
+ card.commentCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "ghr-meta-item", title: t("panel.comments", { count: card.commentCount }), children: [
1191
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CommentGlyph, { size: 11 }),
1192
+ card.commentCount
1193
+ ] }),
1194
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { className: "ghr-meta-item", dateTime: card.updatedAt, title: card.updatedAt, children: updated }),
1195
+ prs.map((pr) => {
1196
+ const state = prGlyph(pr);
1197
+ const checks = checksGlyph(pr);
1198
+ const review = reviewGlyph(pr);
1199
+ const parts = [`#${pr.number}`, pr.title, t(state.label)];
1200
+ if (checks !== void 0) parts.push(t(checks.label, { count: pr.failingChecks?.length ?? 0 }));
1201
+ if (review !== void 0) parts.push(t(review.label));
1202
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1203
+ "a",
1204
+ {
1205
+ className: "ghr-pr",
1206
+ href: pr.url,
1207
+ target: "_blank",
1208
+ rel: "noreferrer",
1209
+ title: parts.join(" \xB7 "),
1210
+ onClick: (event) => event.stopPropagation(),
1211
+ children: [
1212
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ghr-glyph", style: { color: TONE[state.tone].dot }, "aria-hidden": "true", children: state.glyph }),
1213
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1214
+ "#",
1215
+ pr.number
1216
+ ] }),
1217
+ checks !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ghr-glyph", style: { color: TONE[checks.tone].dot }, "aria-hidden": "true", children: checks.glyph }),
1218
+ review !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ghr-glyph", style: { color: TONE[review.tone].dot }, "aria-hidden": "true", children: review.glyph })
1219
+ ]
1220
+ },
1221
+ pr.number
1222
+ );
1223
+ }),
1224
+ hiddenPRs > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Badge, { tone: "neutral", title: t("panel.linkedPRs"), children: t("panel.more", { count: hiddenPRs }) })
1225
+ ] })
1226
+ ]
1227
+ }
1228
+ );
1229
+ }
1230
+
1231
+ // src/client/views/Page.tsx
1232
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1233
+ var PAGE_ROOT_STYLE = {
1234
+ height: "100%",
1235
+ overflow: "auto",
1236
+ boxSizing: "border-box",
1237
+ color: "var(--dsw-alias-label-primary)",
1238
+ background: "var(--dsw-alias-bg-base)"
1239
+ };
1240
+ var PAGE_CONTENT_STYLE = {
1241
+ width: "100%",
1242
+ maxWidth: 960,
1243
+ margin: "0 auto",
1244
+ boxSizing: "border-box",
1245
+ padding: "0 clamp(24px, 4vw, 48px) 48px"
1246
+ };
1247
+ var PAGE_HEAD_STYLE = {
1248
+ display: "flex",
1249
+ justifyContent: "space-between",
1250
+ alignItems: "flex-start",
1251
+ gap: 16,
1252
+ flexWrap: "wrap",
1253
+ paddingTop: "calc(28px + var(--dsh-frame-top-clearance, 0px))"
1254
+ };
1255
+ var PAGE_H1_STYLE = {
1256
+ margin: 0,
1257
+ fontSize: 20,
1258
+ lineHeight: "28px",
1259
+ fontWeight: 500,
1260
+ color: "var(--dsw-alias-label-primary)"
1261
+ };
1262
+ var PAGE_SUBTITLE_STYLE = {
1263
+ marginTop: 2,
1264
+ fontSize: 13,
1265
+ lineHeight: "20px",
1266
+ color: "var(--dsw-alias-label-secondary)"
1267
+ };
1268
+ var PAGE_CSS = `
1269
+ .ghp-page{box-sizing:border-box;height:100%;overflow:auto;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);font-size:var(--dsh-content-font-size,14px)}
1270
+ .ghp-content{box-sizing:border-box;width:100%;max-width:960px;margin:0 auto;padding:0 clamp(24px,4vw,48px) 48px}
1271
+ /* The panel keeps its header, cascade and search fixed; only the list and the
1272
+ detail pane scroll. The settings page keeps the scrolling page shell above. */
1273
+ .ghp-panel{display:flex;flex-direction:column;height:100%;overflow:hidden}
1274
+ .ghp-panel .ghp-content{display:flex;flex-direction:column;flex:1;min-height:0;height:auto;padding-bottom:0}
1275
+ .ghp-panel .ghp-head,.ghp-panel .ghp-scope,.ghp-panel .ghp-notice,.ghp-panel .ghp-filters{flex:none}
1276
+ .ghp-panel .ghp-body{display:flex;flex:1;min-height:0;margin-top:0}
1277
+ .ghp-panel .ghp-split{flex:1;min-height:0;width:100%;align-items:stretch}
1278
+ .ghp-panel .ghp-list-pane{flex:1;min-width:0;overflow:auto;overscroll-behavior:contain;padding-bottom:32px}
1279
+ .ghp-panel .ghx-pane{flex:0 0 380px;box-sizing:border-box;width:380px;max-height:100%;min-height:0;overflow:auto;overscroll-behavior:contain;padding-bottom:32px}
1280
+ .ghp-panel .ghp-scope{grid-template-columns:minmax(0,.95fr) minmax(0,.95fr) minmax(0,1.3fr) minmax(0,1.3fr) minmax(0,.95fr) minmax(0,.75fr);gap:10px;margin-top:14px}
1281
+ @media (max-width:860px){.ghp-panel .ghp-scope{grid-template-columns:repeat(auto-fit,minmax(124px,1fr))}}
1282
+ .ghp-panel .ghp-filters{margin:12px 0 6px}
1283
+ @media (max-width:760px){
1284
+ .ghp-panel{overflow:auto}
1285
+ .ghp-panel .ghp-content{display:block;height:auto;min-height:100%}
1286
+ .ghp-panel .ghp-body{display:block}
1287
+ .ghp-panel .ghp-list-pane{overflow:visible}
1288
+ .ghp-panel .ghx-pane{width:100%;max-height:none;overflow:visible}
1289
+ }
1290
+ .ghp-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap}
1291
+ .ghp-title-block{min-width:0}
1292
+ .ghp-h1{margin:0;font-size:20px;line-height:28px;font-weight:500;color:var(--dsw-alias-label-primary)}
1293
+ .ghp-subtitle{margin-top:2px;font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}
1294
+ .ghp-head-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
1295
+ .ghp-scope{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;align-items:end;margin-top:18px}
1296
+ .ghp-field{display:flex;flex-direction:column;gap:4px;min-width:0}
1297
+ .ghp-field-label{font-size:12px;line-height:16px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
1298
+ .ghp-field .gh-select-wrap{width:100%;min-width:0}
1299
+ .ghp-field .gh-select-wrap .gh-field-label{display:none}
1300
+ .ghp-field .gh-select{width:100%;height:30px;box-sizing:border-box}
1301
+ .ghp-field .gh-input{width:100%;height:30px;box-sizing:border-box}
1302
+ .ghp-notice{display:flex;flex-direction:column;gap:6px;box-sizing:border-box;width:100%;padding:10px 12px;border:0.5px solid var(--dsw-alias-state-warn-primary);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-state-warn-tertiary,var(--dsw-alias-bg-layer-1));font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);margin-top:12px}
1303
+ .ghp-filters{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:16px 0 8px}
1304
+ .ghp-search{display:flex;align-items:center;gap:6px;flex:1;min-width:180px;max-width:360px;height:32px;padding:0 4px 0 10px;box-sizing:border-box;border:0.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-base)}
1305
+ .ghp-search:hover{border-color:var(--dsw-alias-border-l2)}
1306
+ .ghp-search:focus-within{border-color:var(--dsw-alias-state-business-primary,var(--dsw-alias-link))}
1307
+ .ghp-search .gh-input{flex:1;min-width:0;height:30px;width:auto;padding:0;border:0;background:transparent}
1308
+ .ghp-search .gh-input:hover,.ghp-search .gh-input:focus{border:0}
1309
+ .ghp-search-icon{display:inline-flex;align-items:center;color:var(--dsw-alias-label-tertiary);flex:none}
1310
+ .ghp-muted{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
1311
+ .ghp-body{display:block;margin-top:4px}
1312
+ .ghp-split{display:flex;align-items:flex-start;gap:24px}
1313
+ .ghp-list-pane{flex:1;min-width:0}
1314
+ .ghp-footer{display:flex;justify-content:center;padding-top:16px}
1315
+ .ghp-skeleton-row{display:flex;flex-direction:column;gap:6px;padding:12px 8px;border-top:0.5px solid var(--dsw-alias-border-l2)}
1316
+ .ghp-skeleton-row:first-child{border-top:0}
1317
+ .ghp-skeleton-line{height:10px;border-radius:var(--dsw-radius-xs,4px);background:var(--dsw-alias-bg-skeleton,var(--dsw-alias-bg-layer-2));animation:gh-pulse 1.4s ease-in-out infinite}
1318
+ @keyframes gh-pulse{0%,100%{opacity:.55}50%{opacity:1}}
1319
+ @media (max-width:760px){.ghp-split{flex-direction:column}.ghp-split .ghx-pane{flex:1 1 auto;width:100%;padding-left:0;border-left:0;padding-top:16px;border-top:0.5px solid var(--dsw-alias-border-l2)}}
1320
+ `.trim();
1321
+ var STATE_LABEL = {
1322
+ open: "panel.state.open",
1323
+ closed: "panel.state.closed",
1324
+ all: "panel.state.all"
1325
+ };
1326
+ function Field(props) {
1327
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-field", children: [
1328
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ghp-field-label", children: props.label }),
1329
+ props.children
1330
+ ] });
1331
+ }
1332
+ function ScopeCombo(props) {
1333
+ const { label, value, placeholder, options, disabled, onChange } = props;
1334
+ const listId = (0, import_react2.useId)();
1335
+ const selected = options.find((option) => option.value === value);
1336
+ const [text, setText] = (0, import_react2.useState)(selected?.label ?? "");
1337
+ (0, import_react2.useEffect)(() => {
1338
+ const current = options.find((option) => option.value === value);
1339
+ setText(current?.label ?? "");
1340
+ }, [value, options]);
1341
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1342
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1343
+ "input",
1344
+ {
1345
+ className: "gh-input",
1346
+ list: listId,
1347
+ value: text,
1348
+ disabled: disabled === true,
1349
+ placeholder,
1350
+ "aria-label": label,
1351
+ onChange: (event) => {
1352
+ const next = event.target.value;
1353
+ setText(next);
1354
+ if (next === "") {
1355
+ onChange(void 0);
1356
+ return;
1357
+ }
1358
+ const match = options.find((option) => option.label === next || option.value === next);
1359
+ if (match !== void 0) onChange(match.value);
1360
+ },
1361
+ onBlur: () => {
1362
+ const current = options.find((option) => option.value === value);
1363
+ setText(current?.label ?? "");
1364
+ }
1365
+ }
1366
+ ),
1367
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("datalist", { id: listId, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: option.label }, option.value)) })
1368
+ ] });
1369
+ }
1370
+ function GitHubPage({ snapshot, actions, t, resolveSession }) {
1371
+ const [filter, setFilter] = (0, import_react2.useState)("");
1372
+ const prefs = snapshot.prefs;
1373
+ (0, import_react2.useEffect)(() => {
1374
+ if (snapshot.catalog === void 0) actions.loadCatalog();
1375
+ }, [snapshot.catalog, actions]);
1376
+ const items = snapshot.list?.items;
1377
+ const filtered = (0, import_react2.useMemo)(() => {
1378
+ const all = items ?? [];
1379
+ const query = filter.trim().toLowerCase();
1380
+ if (query === "") return all;
1381
+ return all.filter((card) => {
1382
+ const haystack = `${card.repo}#${card.number} ${card.title} ${card.labels.map((label) => label.name).join(" ")}`;
1383
+ return haystack.toLowerCase().includes(query);
1384
+ });
1385
+ }, [items, filter]);
1386
+ const stateOptions = Object.keys(STATE_LABEL).map((state) => ({
1387
+ value: state,
1388
+ label: t(STATE_LABEL[state])
1389
+ }));
1390
+ const orgs = snapshot.catalog?.orgs ?? [];
1391
+ const orgOptions = [
1392
+ { value: "", label: t("panel.allOrgs") },
1393
+ ...orgs.map((org) => ({ value: org.login, label: org.name === void 0 ? org.login : `${org.login} \xB7 ${org.name}` }))
1394
+ ];
1395
+ const projectOptions = [
1396
+ { value: "", label: t("panel.allProjects") },
1397
+ ...(snapshot.orgProjects ?? []).map((project) => ({ value: project.id, label: project.title }))
1398
+ ];
1399
+ const repoSource = prefs.org === void 0 ? snapshot.catalog?.repos ?? [] : snapshot.orgRepos?.items ?? [];
1400
+ const repoOptions = repoSource.map((repo) => ({
1401
+ value: repo.nameWithOwner,
1402
+ label: `${repo.nameWithOwner}${repo.isPrivate ? ` \xB7 ${t("panel.private")}` : ""}${repo.isFork === true ? ` \xB7 ${t("panel.fork")}` : ""}`
1403
+ }));
1404
+ const assigneeOptions = [
1405
+ { value: "@me", label: t("panel.assignee.me") },
1406
+ { value: "all", label: t("panel.assignee.all") }
1407
+ ];
1408
+ const milestoneTitles = [
1409
+ ...prefs.milestone === void 0 ? [] : [prefs.milestone],
1410
+ ...snapshot.milestoneOptions ?? []
1411
+ ].filter((title, index, all) => title !== "" && all.indexOf(title) === index);
1412
+ const milestoneOptions = [
1413
+ { value: "", label: t("panel.allMilestones") },
1414
+ ...milestoneTitles.map((title) => ({ value: title, label: title }))
1415
+ ];
1416
+ const totalCount = snapshot.list?.totalCount;
1417
+ const waitingForDetail = snapshot.selected !== void 0 && snapshot.detail === void 0;
1418
+ const listError = snapshot.error !== void 0 && !waitingForDetail ? snapshot.error : void 0;
1419
+ const showSkeleton = snapshot.loading && snapshot.list === void 0;
1420
+ const showEmpty = !snapshot.loading && listError === void 0 && filtered.length === 0;
1421
+ const noAuth = snapshot.status?.signedIn === false;
1422
+ const subtitle = snapshot.status?.signedIn === true && snapshot.status.login !== void 0 ? t("settings.signedIn", { login: snapshot.status.login }) : snapshot.loading ? t("panel.loading") : "";
1423
+ const split = snapshot.selected !== void 0;
1424
+ const scopeHint = prefs.org === void 0 ? t("panel.scopeGlobal") : `${prefs.org}${prefs.projectId === void 0 ? "" : ` \xB7 ${t("panel.project")}`}${prefs.repo === void 0 ? "" : ` \xB7 ${prefs.repo}`}`;
1425
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "ghp-page ghp-panel", "data-github-panel": true, "aria-label": t("panel"), children: [
1426
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, PAGE_CSS, ISSUE_ROW_CSS, ISSUE_DETAIL_CSS] }),
1427
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-content", children: [
1428
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "ghp-head", style: PAGE_HEAD_STYLE, "data-window-drag": true, children: [
1429
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-title-block", children: [
1430
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "ghp-h1", style: PAGE_H1_STYLE, children: t("panel") }),
1431
+ (subtitle !== "" || scopeHint !== "") && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-subtitle", style: PAGE_SUBTITLE_STYLE, children: [
1432
+ subtitle,
1433
+ subtitle !== "" && scopeHint !== "" ? " \xB7 " : "",
1434
+ scopeHint
1435
+ ] })
1436
+ ] }),
1437
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-head-actions", children: [
1438
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Button, { variant: "ghost", onClick: () => actions.openInSidebar(), children: t("panel.openSidebar") }),
1439
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Button, { variant: "outline", onClick: () => actions.refresh(), disabled: snapshot.loading, children: [
1440
+ snapshot.loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RefreshGlyph, { size: 13 }),
1441
+ snapshot.loading ? t("panel.loading") : t("panel.refresh")
1442
+ ] })
1443
+ ] })
1444
+ ] }),
1445
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-scope", children: [
1446
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.org"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1447
+ Select,
1448
+ {
1449
+ ariaLabel: t("panel.org"),
1450
+ value: prefs.org ?? "",
1451
+ options: orgOptions,
1452
+ onChange: (value) => actions.setOrg(value === "" ? void 0 : value)
1453
+ }
1454
+ ) }),
1455
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.project"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1456
+ Select,
1457
+ {
1458
+ ariaLabel: t("panel.project"),
1459
+ value: prefs.org === void 0 ? "" : prefs.projectId ?? "",
1460
+ options: projectOptions,
1461
+ disabled: prefs.org === void 0 || snapshot.projectsBlocked,
1462
+ onChange: (value) => actions.setProject(value === "" ? void 0 : value)
1463
+ }
1464
+ ) }),
1465
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.repoFilter"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1466
+ ScopeCombo,
1467
+ {
1468
+ label: t("panel.repoFilter"),
1469
+ value: prefs.repo,
1470
+ placeholder: prefs.org === void 0 ? t("panel.allRepos") : `${t("panel.allRepos")}\uFF08${String(repoOptions.length)}\uFF09`,
1471
+ options: repoOptions,
1472
+ onChange: (repo) => actions.setRepo(repo)
1473
+ }
1474
+ ) }),
1475
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.milestoneFilter"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1476
+ Select,
1477
+ {
1478
+ ariaLabel: t("panel.milestoneFilter"),
1479
+ value: prefs.projectId === void 0 ? prefs.milestone ?? "" : "",
1480
+ options: milestoneOptions,
1481
+ disabled: prefs.projectId !== void 0,
1482
+ onChange: (value) => actions.setMilestone(value === "" ? void 0 : value)
1483
+ }
1484
+ ) }),
1485
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.assignee"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1486
+ Select,
1487
+ {
1488
+ ariaLabel: t("panel.assignee"),
1489
+ value: prefs.assignee,
1490
+ options: assigneeOptions,
1491
+ onChange: (value) => actions.setAssignee(value)
1492
+ }
1493
+ ) }),
1494
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: t("panel.stateFilter"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1495
+ Select,
1496
+ {
1497
+ ariaLabel: t("panel.stateFilter"),
1498
+ value: prefs.state,
1499
+ options: stateOptions,
1500
+ onChange: (value) => actions.setStateFilter(value)
1501
+ }
1502
+ ) })
1503
+ ] }),
1504
+ prefs.org === void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-notice", role: "note", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: t("panel.pickOrgHint") }) }),
1505
+ snapshot.projectsBlocked && prefs.org !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-notice", role: "note", children: [
1506
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: t("panel.projectsBlocked") }),
1507
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1508
+ CommandBlock,
1509
+ {
1510
+ command: PROJECT_SCOPE_COMMAND,
1511
+ copyLabel: t("panel.copyCommand"),
1512
+ onCopy: () => actions.copyText(PROJECT_SCOPE_COMMAND)
1513
+ }
1514
+ )
1515
+ ] }),
1516
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-filters", children: [
1517
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-search", children: [
1518
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ghp-search-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchGlyph, { size: 13 }) }),
1519
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1520
+ TextInput,
1521
+ {
1522
+ value: filter,
1523
+ onChange: setFilter,
1524
+ placeholder: t("panel.search"),
1525
+ ariaLabel: t("panel.search")
1526
+ }
1527
+ ),
1528
+ filter !== "" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconButton, { label: t("panel.clearSearch"), onClick: () => setFilter(""), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseGlyph, { size: 12 }) })
1529
+ ] }),
1530
+ totalCount !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ghp-muted", children: t("panel.total", { count: totalCount }) }),
1531
+ snapshot.scopeLoading && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ghp-muted", children: t("panel.loadingScope") })
1532
+ ] }),
1533
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: split ? "ghp-body ghp-split" : "ghp-body", children: [
1534
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-list-pane", children: [
1535
+ listError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1536
+ ErrorBanner,
1537
+ {
1538
+ message: t("panel.error", { message: listError.message }),
1539
+ retryLabel: t("panel.refresh"),
1540
+ onRetry: () => actions.refresh(),
1541
+ children: listError.code === "missing_scope" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1542
+ CommandBlock,
1543
+ {
1544
+ command: PROJECT_SCOPE_COMMAND,
1545
+ copyLabel: t("panel.copyCommand"),
1546
+ onCopy: () => actions.copyText(PROJECT_SCOPE_COMMAND)
1547
+ }
1548
+ )
1549
+ }
1550
+ ),
1551
+ showSkeleton && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-list", "aria-hidden": "true", children: [0, 1, 2, 3, 4].map((index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "ghp-skeleton-row", children: [
1552
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-skeleton-line", style: { width: `${String(30 + index * 8)}%` } }),
1553
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-skeleton-line", style: { width: `${String(70 + index % 3 * 8)}%` } })
1554
+ ] }, index)) }),
1555
+ showEmpty && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1556
+ EmptyState,
1557
+ {
1558
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GitHubIcon, { size: 28 }),
1559
+ title: noAuth ? t("panel.emptyAuth") : snapshot.list?.notice ?? emptyTitle(prefs, snapshot.list?.totalCount, t)
1560
+ }
1561
+ ),
1562
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-list", children: filtered.map((card) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1563
+ IssueRow,
1564
+ {
1565
+ card,
1566
+ t,
1567
+ selected: snapshot.selected?.id === card.id,
1568
+ onSelect: (selected) => actions.selectIssue(selected),
1569
+ promptText: (target) => actions.promptText(target)
1570
+ },
1571
+ card.id
1572
+ )) }),
1573
+ snapshot.list !== void 0 && snapshot.list.pageInfo.hasNextPage && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-footer", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Button, { variant: "outline", size: "sm", onClick: () => actions.loadMore(), disabled: snapshot.loadingMore, children: [
1574
+ snapshot.loadingMore && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, { size: 12 }),
1575
+ snapshot.loadingMore ? t("panel.loading") : t("panel.loadMore")
1576
+ ] }) }),
1577
+ snapshot.list !== void 0 && !snapshot.list.pageInfo.hasNextPage && filtered.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ghp-footer", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ghp-muted", children: t("panel.showing", { count: filtered.length }) }) })
1578
+ ] }),
1579
+ split && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IssueDetailPane, { snapshot, actions, t, resolveSession })
1580
+ ] })
1581
+ ] }),
1582
+ snapshot.toast !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Toast, { text: t(snapshot.toast), onDismiss: () => actions.clearToast(), dismissLabel: t("panel.close") })
1583
+ ] });
1584
+ }
1585
+ function emptyTitle(prefs, total, t) {
1586
+ const projectId = prefs.org === void 0 ? void 0 : prefs.projectId;
1587
+ if (projectId !== void 0 && prefs.assignee === "@me") {
1588
+ return t("panel.emptyProjectMe", { count: total ?? 0 });
1589
+ }
1590
+ if (projectId !== void 0 && prefs.state === "open") {
1591
+ return t("panel.emptyProjectOpen");
1592
+ }
1593
+ return t("panel.empty");
1594
+ }
1595
+
1596
+ // src/client/views/Settings.tsx
1597
+ var import_react3 = require("react");
1598
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1599
+ var SETTINGS_CSS = `
1600
+ .ghs-cards{display:flex;flex-direction:column;gap:16px;margin-top:20px;padding-bottom:8px}
1601
+ .ghs-card{display:flex;flex-direction:column;gap:10px;box-sizing:border-box;padding:16px;border:0.5px solid var(--dsw-alias-settings-card-stroke,var(--dsw-alias-border-l3));border-radius:var(--dsw-radius-xl,16px);background:var(--dsw-alias-settings-card-fill,var(--dsw-alias-bg-layer-1))}
1602
+ .ghs-card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
1603
+ .ghs-card-title{margin:0;font-size:var(--dsh-content-font-size,14px);line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary)}
1604
+ .ghs-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
1605
+ .ghs-kv{display:flex;flex-direction:column;gap:4px;margin:0}
1606
+ .ghs-kv-row{display:flex;gap:8px;align-items:baseline;font-size:12px;line-height:18px}
1607
+ .ghs-kv-row dt{flex:none;min-width:88px;margin:0;color:var(--dsw-alias-label-tertiary)}
1608
+ .ghs-kv-row dd{margin:0;color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
1609
+ .ghs-scopes{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
1610
+ .ghs-warn{display:flex;flex-direction:column;gap:6px;box-sizing:border-box;padding:10px 12px;border:0.5px solid var(--dsw-alias-state-warn-primary);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-state-warn-tertiary,var(--dsw-alias-bg-layer-1));font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
1611
+ .ghs-choices{display:flex;flex-direction:column;gap:6px}
1612
+ .ghs-choice{display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;padding:8px 10px;border:0.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-secondary);font-family:inherit;font-size:var(--dsh-content-font-size-secondary,13px);line-height:20px;cursor:pointer;text-align:left}
1613
+ .ghs-choice:hover{background:var(--dsw-alias-interactive-bg-hover)}
1614
+ .ghs-choice[aria-checked=true]{border-color:var(--dsw-alias-state-business-primary,var(--dsw-alias-link));background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}
1615
+ .ghs-choice:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
1616
+ .ghs-choice-dot{box-sizing:border-box;width:14px;height:14px;border:1.5px solid var(--dsw-alias-border-l3);border-radius:50%;flex:none}
1617
+ .ghs-choice[aria-checked=true] .ghs-choice-dot{border:4px solid var(--dsw-alias-state-business-primary,var(--dsw-alias-link))}
1618
+ .ghs-field{display:flex;flex-direction:column;gap:6px}
1619
+ .ghs-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
1620
+ .ghs-about{display:flex;flex-direction:column;gap:6px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
1621
+ .ghs-about p{margin:0}
1622
+ .ghs-page-head{padding-bottom:0}
1623
+ `.trim();
1624
+ var CARDS_STYLE = { display: "flex", flexDirection: "column" };
1625
+ function GitHubSettings({ snapshot, actions, t }) {
1626
+ const status = snapshot.status;
1627
+ const prefs = snapshot.prefs;
1628
+ const [template, setTemplate] = (0, import_react3.useState)(prefs.promptTemplate);
1629
+ (0, import_react3.useEffect)(() => {
1630
+ setTemplate(prefs.promptTemplate);
1631
+ }, [prefs.promptTemplate]);
1632
+ const authTone = status === void 0 ? "neutral" : status.ghInstalled === false ? "error" : status.signedIn ? "success" : "warn";
1633
+ const authLabel = status === void 0 ? t("settings.loading") : status.ghInstalled === false ? t("settings.ghMissing") : status.signedIn ? t("settings.signedIn", { login: status.login ?? status.host }) : t("settings.signedOut");
1634
+ const subtitle = status === void 0 ? t("settings.loading") : status.signedIn ? t("settings.signedIn", { login: status.login ?? status.host }) : t("settings.signedOut");
1635
+ const resetTemplate = () => {
1636
+ setTemplate(DEFAULT_PROMPT_TEMPLATE);
1637
+ actions.savePrefs({ promptTemplate: DEFAULT_PROMPT_TEMPLATE });
1638
+ };
1639
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "ghp-page", style: PAGE_ROOT_STYLE, "data-github-settings": true, "aria-label": t("settings.title"), children: [
1640
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, PAGE_CSS, SETTINGS_CSS] }),
1641
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghp-content", style: PAGE_CONTENT_STYLE, children: [
1642
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "ghp-head", style: PAGE_HEAD_STYLE, "data-window-drag": true, children: [
1643
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghp-title-block", children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "ghp-h1", style: PAGE_H1_STYLE, children: t("settings.title") }),
1645
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ghp-subtitle", style: PAGE_SUBTITLE_STYLE, children: subtitle })
1646
+ ] }),
1647
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ghp-head-actions", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Button, { variant: "outline", onClick: () => actions.refresh(), disabled: snapshot.loading, children: [
1648
+ snapshot.loading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Spinner, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RefreshGlyph, { size: 13 }),
1649
+ snapshot.loading ? t("settings.loading") : t("settings.refresh")
1650
+ ] }) })
1651
+ ] }),
1652
+ snapshot.error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1653
+ ErrorBanner,
1654
+ {
1655
+ message: t("settings.error", { message: snapshot.error.message }),
1656
+ retryLabel: t("settings.refresh"),
1657
+ onRetry: () => actions.refresh()
1658
+ }
1659
+ ),
1660
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-cards", style: CARDS_STYLE, children: [
1661
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "ghs-card", "aria-labelledby": "gh-settings-auth", children: [
1662
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ghs-card-head", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "ghs-card-title", id: "gh-settings-auth", children: t("settings.auth") }) }),
1663
+ status === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: t("settings.loading") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1664
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-row", children: [
1665
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Pill, { tone: authTone, dot: true, children: authLabel }),
1666
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: t("settings.authModeGh") })
1667
+ ] }),
1668
+ status.error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ErrorBanner, { message: t("settings.error", { message: status.error }) }),
1669
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "ghs-kv", children: [
1670
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-kv-row", children: [
1671
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("settings.login") }),
1672
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: status.login ?? "\u2014" })
1673
+ ] }),
1674
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-kv-row", children: [
1675
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("settings.host") }),
1676
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: status.host })
1677
+ ] }),
1678
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-kv-row", children: [
1679
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("settings.tokenSource") }),
1680
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: status.tokenSource ?? "\u2014" })
1681
+ ] })
1682
+ ] }),
1683
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-scopes", children: [
1684
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "gh-field-label", children: t("settings.scopes") }),
1685
+ status.scopes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: "\u2014" }) : status.scopes.map((scope) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Badge, { tone: "neutral", children: scope }, scope))
1686
+ ] }),
1687
+ status.missingProjectScope && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-warn", role: "note", children: [
1688
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: t("settings.missingProject") }),
1689
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: t("settings.command") }),
1690
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1691
+ CommandBlock,
1692
+ {
1693
+ command: PROJECT_SCOPE_COMMAND,
1694
+ copyLabel: t("settings.copy"),
1695
+ onCopy: () => actions.copyText(PROJECT_SCOPE_COMMAND)
1696
+ }
1697
+ )
1698
+ ] })
1699
+ ] })
1700
+ ] }),
1701
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "ghs-card", "aria-labelledby": "gh-settings-handoff", children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "ghs-card-title", id: "gh-settings-handoff", children: t("settings.handoff") }),
1703
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ghs-choices", role: "radiogroup", "aria-label": t("settings.handoff"), children: ["draft", "send"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1704
+ "button",
1705
+ {
1706
+ type: "button",
1707
+ role: "radio",
1708
+ "aria-checked": prefs.handoffMode === mode,
1709
+ className: "ghs-choice",
1710
+ onClick: () => actions.savePrefs({ handoffMode: mode }),
1711
+ children: [
1712
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghs-choice-dot", "aria-hidden": "true" }),
1713
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: mode === "draft" ? t("settings.handoff.draft") : t("settings.handoff.send") })
1714
+ ]
1715
+ },
1716
+ mode
1717
+ )) })
1718
+ ] }),
1719
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "ghs-card", "aria-labelledby": "gh-settings-template", children: [
1720
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "ghs-card-title", id: "gh-settings-template", children: t("settings.template") }),
1721
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-field", children: [
1722
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1723
+ TextArea,
1724
+ {
1725
+ value: template,
1726
+ onChange: setTemplate,
1727
+ ariaLabel: t("settings.template"),
1728
+ rows: 9,
1729
+ mono: true
1730
+ }
1731
+ ),
1732
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ghp-muted", children: t("settings.template.help") })
1733
+ ] }),
1734
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-actions", children: [
1735
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1736
+ Button,
1737
+ {
1738
+ variant: "primary",
1739
+ size: "sm",
1740
+ onClick: () => actions.savePrefs({ promptTemplate: template }),
1741
+ disabled: template === prefs.promptTemplate,
1742
+ children: t("settings.save")
1743
+ }
1744
+ ),
1745
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { variant: "ghost", size: "sm", onClick: resetTemplate, children: t("settings.reset") })
1746
+ ] })
1747
+ ] }),
1748
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "ghs-card", "aria-labelledby": "gh-settings-about", children: [
1749
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "ghs-card-title", id: "gh-settings-about", children: t("settings.about") }),
1750
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ghs-about", children: [
1751
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("settings.aboutText") }),
1752
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("settings.credentialHint") })
1753
+ ] })
1754
+ ] })
1755
+ ] })
1756
+ ] }),
1757
+ snapshot.toast !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Toast, { text: t(snapshot.toast), onDismiss: () => actions.clearToast(), dismissLabel: t("panel.close") })
1758
+ ] });
1759
+ }
1760
+
1761
+ // src/client/views/Sidebar.tsx
1762
+ var import_react4 = require("react");
1763
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1764
+ var SIDEBAR_CSS = `
1765
+ .ghs-wrap{display:flex;flex-direction:column;height:100%;min-height:0;box-sizing:border-box;color:var(--dsw-alias-label-primary);font-size:13px}
1766
+ .ghs-head{display:flex;align-items:center;gap:8px;padding:10px 12px 6px;flex:none}
1767
+ .ghs-scope{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--dsw-alias-label-tertiary)}
1768
+ .ghs-search{padding:0 12px 8px;flex:none}
1769
+ .ghs-list{flex:1;min-height:0;overflow:auto;padding:2px 6px 6px}
1770
+ .ghs-row{display:flex;gap:8px;align-items:flex-start;box-sizing:border-box;padding:7px 8px;border-radius:8px;cursor:grab;user-select:none}
1771
+ .ghs-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
1772
+ .ghs-row:active{cursor:grabbing}
1773
+ .ghs-row:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px}
1774
+ .ghs-dot{width:7px;height:7px;border-radius:50%;flex:none;margin-top:6px}
1775
+ .ghs-row-main{flex:1;min-width:0}
1776
+ .ghs-row-head{display:flex;align-items:center;gap:6px;min-width:0}
1777
+ .ghs-ref{font-family:var(--dsh-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
1778
+ .ghs-state{font-size:10px;line-height:14px;padding:0 5px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);flex:none}
1779
+ .ghs-title{margin-top:2px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-primary);display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden}
1780
+ .ghs-empty{padding:24px 12px}
1781
+ .ghs-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:28px 12px;color:var(--dsw-alias-label-tertiary);font-size:12px}
1782
+ .ghs-hint{padding:8px 12px 10px;border-top:0.5px solid var(--dsw-alias-border-l2);flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
1783
+ `.trim();
1784
+ function GitHubSidebar({ snapshot, actions, t }) {
1785
+ const [query, setQuery] = (0, import_react4.useState)("");
1786
+ const items = snapshot.list?.items;
1787
+ const filtered = (0, import_react4.useMemo)(() => {
1788
+ const all = items ?? [];
1789
+ const needle = query.trim().toLowerCase();
1790
+ if (needle === "") return all;
1791
+ return all.filter((card) => `${card.repo}#${String(card.number)} ${card.title}`.toLowerCase().includes(needle));
1792
+ }, [items, query]);
1793
+ const scope = snapshot.prefs.projectId === void 0 ? snapshot.prefs.org ?? t("panel.scopeGlobal") : t("panel.project");
1794
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "ghs-wrap", "data-github-sidebar": true, children: [
1795
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StyleSheet, { chunks: [CONTROLS_CSS, SIDEBAR_CSS] }),
1796
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "ghs-head", children: [
1797
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "ghs-scope", title: scope, children: `${scope} \xB7 ${String(snapshot.list?.totalCount ?? 0)}` }),
1798
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Button, { size: "sm", variant: "ghost", onClick: () => actions.refresh(), disabled: snapshot.loading, children: t("panel.refresh") })
1799
+ ] }),
1800
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ghs-search", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1801
+ TextInput,
1802
+ {
1803
+ value: query,
1804
+ onChange: setQuery,
1805
+ ariaLabel: t("sidebar.search"),
1806
+ placeholder: t("sidebar.search")
1807
+ }
1808
+ ) }),
1809
+ snapshot.list === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "ghs-loading", children: [
1810
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Spinner, {}),
1811
+ t("panel.loading")
1812
+ ] }) : filtered.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ghs-empty", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(EmptyState, { title: t("sidebar.empty"), hint: t("sidebar.emptyHint"), icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(GitHubIcon, { size: 18 }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ghs-list", role: "list", children: filtered.map((card) => {
1813
+ const tone = stateTone(card.state, card.stateReason);
1814
+ const ref = `${card.repo}#${String(card.number)}`;
1815
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1816
+ "div",
1817
+ {
1818
+ className: "ghs-row",
1819
+ role: "listitem",
1820
+ draggable: true,
1821
+ tabIndex: 0,
1822
+ title: `${ref}
1823
+ ${card.title}`,
1824
+ onDragStart: (event) => {
1825
+ actions.dragIssue(card);
1826
+ event.dataTransfer.effectAllowed = "copy";
1827
+ event.dataTransfer.setData("text/plain", ref);
1828
+ },
1829
+ onDragEnd: () => actions.endDrag(),
1830
+ onClick: () => actions.openInPanel(card),
1831
+ onKeyDown: (event) => {
1832
+ if (event.key === "Enter" || event.key === " ") {
1833
+ event.preventDefault();
1834
+ actions.openInPanel(card);
1835
+ }
1836
+ },
1837
+ children: [
1838
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "ghs-dot", style: { background: TONE[tone].dot }, "aria-hidden": "true" }),
1839
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "ghs-row-main", children: [
1840
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "ghs-row-head", children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "ghs-ref", children: ref }),
1842
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "ghs-state", children: t(stateLabelKey(card.state)) })
1843
+ ] }),
1844
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ghs-title", children: card.title })
1845
+ ] })
1846
+ ]
1847
+ },
1848
+ `${ref}`
1849
+ );
1850
+ }) }),
1851
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "ghs-hint", children: t("sidebar.dragHint") })
1852
+ ] });
1853
+ }
1854
+
1855
+ // src/client/containers.tsx
1856
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1857
+ var EMPTY_SESSIONS = { byId: {} };
1858
+ var EMPTY_WORKSPACES = { items: [] };
1859
+ function usePanel(store) {
1860
+ return (0, import_react5.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
1861
+ }
1862
+ function useCatalog(source, empty) {
1863
+ const subscribe = (0, import_react5.useCallback)(
1864
+ (listener) => source?.subscribe(listener) ?? (() => {
1865
+ }),
1866
+ [source]
1867
+ );
1868
+ const snapshot = (0, import_react5.useCallback)(() => source?.getSnapshot() ?? empty, [source, empty]);
1869
+ return (0, import_react5.useSyncExternalStore)(subscribe, snapshot, snapshot);
1870
+ }
1871
+ function resolveSessionLink(sessions, workspaces, sessionId) {
1872
+ const workspace = workspaces.items?.find((item) => item.sessionIds?.includes(sessionId));
1873
+ const title = sessions.byId?.[sessionId]?.title;
1874
+ const archived = workspaces.archivedSessionIds?.includes(sessionId) ?? false;
1875
+ const known = sessions.byId?.[sessionId] !== void 0 || workspace !== void 0;
1876
+ return {
1877
+ sessionId,
1878
+ title: typeof title === "string" && title.trim() !== "" ? title : sessionId,
1879
+ ...typeof workspace?.title === "string" && workspace.title !== "" ? { workspaceTitle: workspace.title } : {},
1880
+ available: known && !archived
1881
+ };
1882
+ }
1883
+ function PageHost({ store, t, runtime }) {
1884
+ const snapshot = usePanel(store);
1885
+ const sessionCatalog = runtime.getService("sessions")?.list;
1886
+ const workspaceCatalog = runtime.getService("workspaces")?.list;
1887
+ const sessions = useCatalog(sessionCatalog, EMPTY_SESSIONS);
1888
+ const workspaces = useCatalog(workspaceCatalog, EMPTY_WORKSPACES);
1889
+ const resolveSession = (0, import_react5.useCallback)(
1890
+ (sessionId) => resolveSessionLink(sessions, workspaces, sessionId),
1891
+ [sessions, workspaces]
1892
+ );
1893
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GitHubPage, { snapshot, actions: store, t, resolveSession });
1894
+ }
1895
+ function placeholderCard(repo, number) {
1896
+ return {
1897
+ id: `${repo}#${String(number)}`,
1898
+ repo,
1899
+ number,
1900
+ title: "",
1901
+ url: `https://github.com/${repo}/issues/${String(number)}`,
1902
+ state: "OPEN",
1903
+ stateReason: null,
1904
+ isPrivate: false,
1905
+ labels: [],
1906
+ assignees: [],
1907
+ updatedAt: "",
1908
+ commentCount: 0,
1909
+ linkedPRs: [],
1910
+ sessionLinks: []
1911
+ };
1912
+ }
1913
+ function DockHost({ store, t, runtime, sessionId }) {
1914
+ const snapshot = usePanel(store);
1915
+ const sessionCatalog = runtime.getService("sessions")?.list;
1916
+ const workspaceCatalog = runtime.getService("workspaces")?.list;
1917
+ const sessions = useCatalog(sessionCatalog, EMPTY_SESSIONS);
1918
+ const workspaces = useCatalog(workspaceCatalog, EMPTY_WORKSPACES);
1919
+ const resolveSession = (0, import_react5.useCallback)(
1920
+ (id) => resolveSessionLink(sessions, workspaces, id),
1921
+ [sessions, workspaces]
1922
+ );
1923
+ const sessionLinks = snapshot.links.filter((link) => link.sessionId === sessionId);
1924
+ (0, import_react5.useEffect)(() => {
1925
+ if (sessionLinks.length !== 0) void store.ensureCards(sessionLinks);
1926
+ }, [snapshot.links, store]);
1927
+ const chips = [];
1928
+ const seen = /* @__PURE__ */ new Set();
1929
+ for (const link of sessionLinks) {
1930
+ const key = `${link.repo}#${String(link.number)}`;
1931
+ if (seen.has(key)) continue;
1932
+ seen.add(key);
1933
+ const live = snapshot.linkCards[key];
1934
+ chips.push({
1935
+ card: live ?? placeholderCard(link.repo, link.number),
1936
+ state: live === void 0 ? "degraded" : "linked",
1937
+ sessions: [resolveSession(link.sessionId)]
1938
+ });
1939
+ }
1940
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1941
+ GitHubDock,
1942
+ {
1943
+ chips,
1944
+ t,
1945
+ onRemoveChip: (chip) => {
1946
+ if (sessionId !== void 0) void store.unlinkSession(chip.card, sessionId);
1947
+ },
1948
+ onOpenChip: (chip) => store.openInPanel(chip.card)
1949
+ }
1950
+ );
1951
+ }
1952
+ function PendingOverlayHost({ store, t, sessionId, useInput, inputActions }) {
1953
+ const snapshot = usePanel(store);
1954
+ const [pending, setPending] = (0, import_react5.useState)(void 0);
1955
+ const markerSeen = (0, import_react5.useRef)(false);
1956
+ const submitSeen = (0, import_react5.useRef)(false);
1957
+ const sending = (0, import_react5.useRef)(false);
1958
+ const marker = pending === void 0 ? "" : `${pending.repo}#${String(pending.number)}`;
1959
+ const input = useInput === void 0 ? void 0 : useInput((state) => state);
1960
+ const latestInput = (0, import_react5.useRef)(input);
1961
+ latestInput.current = input;
1962
+ (0, import_react5.useEffect)(() => {
1963
+ const card = store.consumeHandoff(sessionId);
1964
+ if (card === void 0) return;
1965
+ markerSeen.current = false;
1966
+ submitSeen.current = false;
1967
+ sending.current = false;
1968
+ setPending(card);
1969
+ if (inputActions !== void 0) inputActions.setDraft(EMPTY_DRAFT_HOLD);
1970
+ }, [snapshot.pendingHandoff, snapshot.pendingHandoffSession, inputActions, sessionId, store]);
1971
+ (0, import_react5.useEffect)(() => {
1972
+ if (pending === void 0 || input === void 0 || sessionId === void 0) return;
1973
+ const text = input.draft;
1974
+ if (text.includes(marker)) {
1975
+ markerSeen.current = true;
1976
+ if (input.phase !== "plain") submitSeen.current = true;
1977
+ }
1978
+ if (markerSeen.current && submitSeen.current) {
1979
+ void store.linkIssue(pending, sessionId);
1980
+ setPending(void 0);
1981
+ markerSeen.current = false;
1982
+ submitSeen.current = false;
1983
+ sending.current = false;
1984
+ return;
1985
+ }
1986
+ if (text === "") {
1987
+ setPending(void 0);
1988
+ markerSeen.current = false;
1989
+ submitSeen.current = false;
1990
+ sending.current = false;
1991
+ return;
1992
+ }
1993
+ if (markerSeen.current && !text.includes(marker)) {
1994
+ setPending(void 0);
1995
+ markerSeen.current = false;
1996
+ submitSeen.current = false;
1997
+ sending.current = false;
1998
+ }
1999
+ }, [input, pending, marker, sessionId, store]);
2000
+ (0, import_react5.useEffect)(() => {
2001
+ if (pending === void 0 || inputActions === void 0) return;
2002
+ const composerCard = () => {
2003
+ const chip = document.querySelector("[data-github-pending]");
2004
+ const anchor = chip?.closest("[data-composer-overlay]");
2005
+ return anchor?.parentElement ?? null;
2006
+ };
2007
+ const submitButton = (card) => {
2008
+ const buttons = [...card.querySelectorAll("button")];
2009
+ return buttons.find((button) => /_primary(\s|$)/.test(String(button.className))) ?? buttons[buttons.length - 1];
2010
+ };
2011
+ const send = () => {
2012
+ if (sending.current) return;
2013
+ sending.current = true;
2014
+ const card = pending;
2015
+ const composed = composeHandoffPrompt(store.promptFor(card), latestInput.current?.draft ?? "");
2016
+ inputActions.setDraft(composed);
2017
+ window.setTimeout(() => {
2018
+ inputActions.submit();
2019
+ window.setTimeout(() => {
2020
+ const after = latestInput.current?.draft ?? "";
2021
+ const cleared = !after.includes(`${card.repo}#${String(card.number)}`);
2022
+ if (!cleared) {
2023
+ sending.current = false;
2024
+ return;
2025
+ }
2026
+ if (sessionId !== void 0) void store.linkIssue(card, sessionId);
2027
+ setPending(void 0);
2028
+ markerSeen.current = false;
2029
+ submitSeen.current = false;
2030
+ sending.current = false;
2031
+ }, 700);
2032
+ }, 16);
2033
+ };
2034
+ const onClick = (event) => {
2035
+ const card = composerCard();
2036
+ if (card === null) return;
2037
+ const button = event.target?.closest("button");
2038
+ if (button === null || button === void 0 || button.closest("[data-github-pending]") !== null) return;
2039
+ if (button !== submitButton(card)) return;
2040
+ event.preventDefault();
2041
+ event.stopImmediatePropagation();
2042
+ send();
2043
+ };
2044
+ const onKeyDown = (event) => {
2045
+ if (event.key !== "Enter" || event.shiftKey || event.isComposing) return;
2046
+ const card = composerCard();
2047
+ if (card === null) return;
2048
+ const target = event.target;
2049
+ if (target === null || !card.contains(target) || target.closest("[data-github-pending]") !== null) return;
2050
+ event.preventDefault();
2051
+ event.stopImmediatePropagation();
2052
+ send();
2053
+ };
2054
+ document.addEventListener("click", onClick, true);
2055
+ document.addEventListener("keydown", onKeyDown, true);
2056
+ return () => {
2057
+ document.removeEventListener("click", onClick, true);
2058
+ document.removeEventListener("keydown", onKeyDown, true);
2059
+ };
2060
+ }, [pending, inputActions, store]);
2061
+ if (pending === void 0) return null;
2062
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2063
+ GitHubPendingChip,
2064
+ {
2065
+ card: pending,
2066
+ t,
2067
+ onOpenPanel: () => store.openInPanel(pending),
2068
+ onRemove: () => {
2069
+ setPending(void 0);
2070
+ markerSeen.current = false;
2071
+ submitSeen.current = false;
2072
+ sending.current = false;
2073
+ inputActions?.setDraft("");
2074
+ }
2075
+ }
2076
+ );
2077
+ }
2078
+ function DropZoneHost({ store, t, sessionId }) {
2079
+ const snapshot = usePanel(store);
2080
+ const dragging = snapshot.dragging;
2081
+ (0, import_react5.useEffect)(() => {
2082
+ if (dragging === void 0) return;
2083
+ const onDragOver = (event) => {
2084
+ event.preventDefault();
2085
+ if (event.dataTransfer !== null) event.dataTransfer.dropEffect = "copy";
2086
+ };
2087
+ const onDrop = (event) => {
2088
+ const target = event.target;
2089
+ if (target?.closest("[data-github-sidebar]") !== null && target !== null) {
2090
+ event.preventDefault();
2091
+ store.endDrag();
2092
+ return;
2093
+ }
2094
+ event.preventDefault();
2095
+ store.dropHandoff(sessionId);
2096
+ };
2097
+ const onDragEnd = () => {
2098
+ store.endDrag();
2099
+ };
2100
+ window.addEventListener("dragover", onDragOver);
2101
+ window.addEventListener("drop", onDrop);
2102
+ window.addEventListener("dragend", onDragEnd);
2103
+ return () => {
2104
+ window.removeEventListener("dragover", onDragOver);
2105
+ window.removeEventListener("drop", onDrop);
2106
+ window.removeEventListener("dragend", onDragEnd);
2107
+ };
2108
+ }, [dragging, sessionId, store]);
2109
+ if (dragging === void 0) return null;
2110
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2111
+ GitHubDropZone,
2112
+ {
2113
+ dragging,
2114
+ t,
2115
+ onDrop: () => store.dropHandoff(sessionId),
2116
+ onCancel: () => store.endDrag()
2117
+ }
2118
+ );
2119
+ }
2120
+ function SidebarHost({ store, t }) {
2121
+ const snapshot = usePanel(store);
2122
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GitHubSidebar, { snapshot, actions: store, t });
2123
+ }
2124
+ function SettingsHost({ store, t }) {
2125
+ const snapshot = usePanel(store);
2126
+ const resolveSession = (sessionId) => ({
2127
+ sessionId,
2128
+ title: sessionId,
2129
+ available: false
2130
+ });
2131
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GitHubSettings, { snapshot, actions: store, t, resolveSession });
2132
+ }
2133
+ function GitHubRailIcon(props) {
2134
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(GitHubIcon, { ...props });
2135
+ }
2136
+
2137
+ // src/client/locale.ts
2138
+ var NS = "github-issues";
2139
+ var en = {
2140
+ panel: "GitHub",
2141
+ "panel.assigned": "Assigned to me",
2142
+ "panel.created": "Created by me",
2143
+ "panel.open": "All open",
2144
+ "panel.repo": "Repository",
2145
+ "panel.project": "Project",
2146
+ "panel.allRepos": "All repositories",
2147
+ "panel.selectRepo": "Select a repository\u2026",
2148
+ "panel.selectProject": "Select a project\u2026",
2149
+ "panel.state.open": "Open",
2150
+ "panel.state.closed": "Closed",
2151
+ "panel.state.all": "All",
2152
+ "panel.search": "Filter this list\u2026",
2153
+ "panel.refresh": "Refresh",
2154
+ "panel.openSidebar": "Right column",
2155
+ "panel.loadMore": "Load more",
2156
+ "panel.loading": "Loading\u2026",
2157
+ "panel.empty": "No issues match these filters.",
2158
+ "panel.emptyAuth": "GitHub is not authorized yet. Open Settings \u2192 GitHub.",
2159
+ "panel.error": "Could not load: {message}",
2160
+ "panel.total": "{count} issues",
2161
+ "panel.openOnGitHub": "Open on GitHub",
2162
+ "panel.handoff": "Hand to agent",
2163
+ "panel.pin": "Pin to handoff strip",
2164
+ "panel.close": "Close",
2165
+ "panel.detail": "Details",
2166
+ "panel.closeDetail": "Close detail",
2167
+ "panel.milestone": "Milestone",
2168
+ "panel.priority": "Priority",
2169
+ "panel.labels": "Labels",
2170
+ "panel.assignees": "Assignees",
2171
+ "panel.linkedPRs": "Linked pull requests",
2172
+ "panel.mentionedPRs": "Mentioned in",
2173
+ "panel.noPRs": "No linked pull requests",
2174
+ "panel.comments": "{count} comments",
2175
+ "panel.updated": "updated {time}",
2176
+ "panel.due": "due {date}",
2177
+ "panel.progress": "{percent}%",
2178
+ "panel.priority.project": "project field",
2179
+ "panel.priority.issueField": "issue field",
2180
+ "panel.priority.label": "label",
2181
+ "panel.projectsBlocked": "Projects v2 needs the read:project scope.",
2182
+ "panel.scopeHint": "Run in a terminal: {command}",
2183
+ "panel.copyCommand": "Copy command",
2184
+ "panel.allOrgs": "All organizations",
2185
+ "panel.org": "Organization",
2186
+ "panel.allProjects": "All projects",
2187
+ "panel.repoFilter": "Repository",
2188
+ "panel.milestoneFilter": "Milestone",
2189
+ "panel.allMilestones": "All milestones",
2190
+ "panel.comboHint": "{count} in list",
2191
+ "panel.fork": "fork",
2192
+ "panel.assignee": "Assignee",
2193
+ "panel.assignee.me": "Assigned to me",
2194
+ "panel.assignee.all": "Everyone",
2195
+ "panel.pickOrgHint": "Pick an organization to browse its projects and repositories; without one, the list spans every organization.",
2196
+ "panel.loadingScope": "Loading the organization\u2026",
2197
+ "panel.scopeGlobal": "all organizations",
2198
+ "panel.emptyProjectMe": "No items on this project are assigned to you (project has {count} items). Switch the assignee filter to Everyone.",
2199
+ "panel.emptyProjectOpen": "No open items on this project. Switch the state filter to All or Closed.",
2200
+ "panel.toast.copied": "Copied",
2201
+ "panel.toast.promptCopied": "Prompt copied",
2202
+ "panel.toast.pinned": "Pinned to the handoff strip",
2203
+ "panel.filter.milestone": "Milestone",
2204
+ "panel.filter.label": "Label",
2205
+ "panel.filter.all": "All",
2206
+ "panel.private": "Private",
2207
+ "panel.type": "Type",
2208
+ "panel.view": "View",
2209
+ "panel.settings": "Settings",
2210
+ "panel.noAssignees": "Unassigned",
2211
+ "panel.noMilestone": "No milestone",
2212
+ "panel.noPriority": "No priority",
2213
+ "panel.noType": "No type",
2214
+ "panel.draft": "Draft",
2215
+ "panel.merged": "Merged",
2216
+ "panel.closedPR": "Closed",
2217
+ "panel.openPR": "Open",
2218
+ "panel.checks.failure": "{count} failing checks",
2219
+ "panel.review.approved": "approved",
2220
+ "panel.review.changes": "changes requested",
2221
+ "panel.review.required": "review required",
2222
+ "dock.pending": "pending",
2223
+ "sidebar.tab": "Issues",
2224
+ "sidebar.search": "Filter the sidebar list\u2026",
2225
+ "sidebar.dragHint": "Drag a row into the composer to hand it to this Session.",
2226
+ "sidebar.empty": "No issues in this filter",
2227
+ "sidebar.emptyHint": "Adjust the cascade in the main GitHub panel.",
2228
+ "drop.release": "Release to hand off",
2229
+ "drop.hint": "fills the composer draft as an issue chip",
2230
+ "drop.cancel": "Cancel",
2231
+ "pending.hint": "Sent with the prompt; it becomes the linked issue chip below.",
2232
+ "pending.tip": "On send this card becomes the issue prompt; anything you type is appended.",
2233
+ "dock.loading": "Loading issue details\u2026",
2234
+ "dock.removeDraft": "Clear draft",
2235
+ "dock.unlink": "Unlink this session",
2236
+ "dock.linked": "handed to",
2237
+ "dock.remove": "Remove from this conversation",
2238
+ "panel.noSession": "Not handed to a session yet.",
2239
+ "panel.openSession": "Open session",
2240
+ "panel.enterSession": "Open",
2241
+ "panel.newSession": "New session",
2242
+ "panel.sessions": "Linked Sessions",
2243
+ "panel.sessionsHint": "Open a Session to continue, or unlink it. Unlinking never deletes the Session.",
2244
+ "panel.unlinkSession": "Unlink",
2245
+ "panel.unlinkSessionHint": "Remove the issue \u2194 session link only; the Session stays.",
2246
+ "panel.sessionUnavailable": "unavailable (deleted or archived)",
2247
+ "panel.copyPrompt": "Copy prompt",
2248
+ "panel.openSessionNamed": "Open {title}",
2249
+ "panel.sessionMissing": "Session not available",
2250
+ "panel.linkedBadge": "{count} session(s)",
2251
+ "panel.handToAgent": "Hand to agent",
2252
+ "panel.handoffNewSession": "opens a new Session in the matching workspace",
2253
+ "panel.openInPanel": "Open in GitHub panel",
2254
+ "dock.title": "GitHub Issues",
2255
+ "dock.pinned": "Current issue",
2256
+ "dock.empty": "Pin an issue in the GitHub panel, or drop one here.",
2257
+ "dock.insert": "Fill draft",
2258
+ "dock.send": "Send now",
2259
+ "dock.clear": "Unpin",
2260
+ "dock.drop": "Drop to put this issue in the composer",
2261
+ "dock.drag": "Drag this issue onto the composer to write the prompt",
2262
+ "dock.disabled": "The composer is not ready yet.",
2263
+ "dock.open": "Open on GitHub",
2264
+ "settings.title": "GitHub",
2265
+ "settings.auth": "Authorization",
2266
+ "settings.signedIn": "Signed in as {login}",
2267
+ "settings.signedOut": "Not signed in",
2268
+ "settings.ghMissing": "The gh CLI was not found.",
2269
+ "settings.scopes": "Token scopes",
2270
+ "settings.missingProject": "Missing the read:project scope (Projects v2).",
2271
+ "settings.command": "Run this once in a terminal, then refresh:",
2272
+ "settings.copy": "Copy",
2273
+ "settings.handoff": "Handoff behavior",
2274
+ "settings.handoff.draft": "Fill the draft (recommended)",
2275
+ "settings.handoff.send": "Send immediately",
2276
+ "settings.template": "Prompt template",
2277
+ "settings.template.help": "Placeholders: {{repo}} {{number}} {{title}} {{url}} {{state}} {{milestone}} {{priority}} {{assignees}} {{labels}} {{prs}}",
2278
+ "settings.save": "Save",
2279
+ "settings.saved": "Saved",
2280
+ "settings.reset": "Reset to default",
2281
+ "settings.refresh": "Refresh status",
2282
+ "settings.about": "About",
2283
+ "settings.aboutText": "Everything stays on this machine: the token is read from the gh CLI and never written to configuration or to the page; issue data is fetched from GitHub by the local Host process.",
2284
+ "settings.error": "Error: {message}",
2285
+ "settings.authModeGh": "Reuse the gh CLI token",
2286
+ "settings.loading": "Checking\u2026",
2287
+ "settings.credentialHint": "The token stays in the system keychain: this plugin only asks gh for it.",
2288
+ "settings.login": "Login",
2289
+ "settings.host": "Host",
2290
+ "settings.tokenSource": "Token source",
2291
+ "panel.stateFilter": "State",
2292
+ "panel.clearSearch": "Clear filter",
2293
+ "panel.more": "+{count}",
2294
+ "panel.showing": "Showing {count}",
2295
+ "panel.retry": "Retry",
2296
+ "panel.detail.empty": "Select an issue to see its details.",
2297
+ "panel.noBody": "No description provided.",
2298
+ "panel.noRepos": "No repositories found for this token.",
2299
+ "panel.noProjects": "No Projects v2 projects found.",
2300
+ "panel.checks.success": "checks passed",
2301
+ "panel.checks.pending": "checks running",
2302
+ "panel.checks.none": "no checks"
2303
+ };
2304
+ var zh = {
2305
+ panel: "GitHub",
2306
+ "panel.assigned": "\u5206\u914D\u7ED9\u6211",
2307
+ "panel.created": "\u6211\u521B\u5EFA\u7684",
2308
+ "panel.open": "\u5168\u90E8 Open",
2309
+ "panel.repo": "\u4ED3\u5E93",
2310
+ "panel.project": "\u9879\u76EE",
2311
+ "panel.allRepos": "\u5168\u90E8\u4ED3\u5E93",
2312
+ "panel.selectRepo": "\u9009\u62E9\u4ED3\u5E93\u2026",
2313
+ "panel.selectProject": "\u9009\u62E9\u9879\u76EE\u2026",
2314
+ "panel.state.open": "\u6253\u5F00",
2315
+ "panel.state.closed": "\u5DF2\u5173\u95ED",
2316
+ "panel.state.all": "\u5168\u90E8",
2317
+ "panel.search": "\u7B5B\u9009\u5F53\u524D\u5217\u8868\u2026",
2318
+ "panel.refresh": "\u5237\u65B0",
2319
+ "panel.openSidebar": "\u53F3\u680F",
2320
+ "panel.loadMore": "\u52A0\u8F7D\u66F4\u591A",
2321
+ "panel.loading": "\u52A0\u8F7D\u4E2D\u2026",
2322
+ "panel.empty": "\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684 Issue\u3002",
2323
+ "panel.emptyAuth": "GitHub \u5C1A\u672A\u6388\u6743\u3002\u6253\u5F00 \u8BBE\u7F6E \u2192 GitHub\u3002",
2324
+ "panel.error": "\u52A0\u8F7D\u5931\u8D25\uFF1A{message}",
2325
+ "panel.total": "{count} \u4E2A Issue",
2326
+ "panel.openOnGitHub": "\u5728 GitHub \u6253\u5F00",
2327
+ "panel.handoff": "\u4EA4\u7ED9 Agent",
2328
+ "panel.pin": "\u56FA\u5B9A\u5230\u4EA4\u529E\u6761",
2329
+ "panel.close": "\u5173\u95ED",
2330
+ "panel.detail": "\u8BE6\u60C5",
2331
+ "panel.closeDetail": "\u5173\u95ED\u8BE6\u60C5\u9762\u677F",
2332
+ "panel.milestone": "\u91CC\u7A0B\u7891",
2333
+ "panel.priority": "\u4F18\u5148\u7EA7",
2334
+ "panel.labels": "\u6807\u7B7E",
2335
+ "panel.assignees": "\u6307\u6D3E",
2336
+ "panel.linkedPRs": "\u5173\u8054 PR",
2337
+ "panel.mentionedPRs": "\u63D0\u53CA\u7684 PR",
2338
+ "panel.noPRs": "\u65E0\u5173\u8054 PR",
2339
+ "panel.comments": "{count} \u6761\u8BC4\u8BBA",
2340
+ "panel.updated": "\u66F4\u65B0\u4E8E {time}",
2341
+ "panel.due": "{date} \u5230\u671F",
2342
+ "panel.progress": "{percent}%",
2343
+ "panel.priority.project": "\u9879\u76EE\u5B57\u6BB5",
2344
+ "panel.priority.issueField": "Issue \u5B57\u6BB5",
2345
+ "panel.priority.label": "\u6807\u7B7E",
2346
+ "panel.projectsBlocked": "Projects v2 \u9700\u8981 read:project \u6743\u9650\u3002",
2347
+ "panel.scopeHint": "\u5728\u7EC8\u7AEF\u8FD0\u884C\uFF1A{command}",
2348
+ "panel.copyCommand": "\u590D\u5236\u547D\u4EE4",
2349
+ "panel.allOrgs": "\u5168\u90E8\u7EC4\u7EC7",
2350
+ "panel.org": "\u7EC4\u7EC7",
2351
+ "panel.allProjects": "\u5168\u90E8\u9879\u76EE",
2352
+ "panel.repoFilter": "\u4ED3\u5E93",
2353
+ "panel.milestoneFilter": "\u91CC\u7A0B\u7891",
2354
+ "panel.allMilestones": "\u5168\u90E8\u91CC\u7A0B\u7891",
2355
+ "panel.comboHint": "\u5171 {count} \u4E2A",
2356
+ "panel.fork": "fork",
2357
+ "panel.assignee": "\u6307\u6D3E",
2358
+ "panel.assignee.me": "\u5206\u914D\u7ED9\u6211",
2359
+ "panel.assignee.all": "\u6240\u6709\u4EBA",
2360
+ "panel.pickOrgHint": "\u9009\u62E9\u7EC4\u7EC7\u540E\u53EF\u6D4F\u89C8\u8BE5\u7EC4\u7EC7\u4E0B\u7684\u9879\u76EE\u4E0E\u4ED3\u5E93\uFF1B\u4E0D\u9009\u7EC4\u7EC7\u5219\u8DE8\u6240\u6709\u7EC4\u7EC7\u67E5\u8BE2\u3002",
2361
+ "panel.loadingScope": "\u6B63\u5728\u52A0\u8F7D\u7EC4\u7EC7\u2026",
2362
+ "panel.scopeGlobal": "\u5168\u90E8\u7EC4\u7EC7",
2363
+ "panel.emptyProjectMe": "\u8BE5\u9879\u76EE\u91CC\u6CA1\u6709\u6307\u6D3E\u7ED9\u4F60\u7684\u6761\u76EE\uFF08\u9879\u76EE\u5171 {count} \u9879\uFF09\u3002\u53EF\u628A\u6307\u6D3E\u7B5B\u9009\u5207\u5230\u300C\u6240\u6709\u4EBA\u300D\u3002",
2364
+ "panel.emptyProjectOpen": "\u8BE5\u9879\u76EE\u6CA1\u6709\u6253\u5F00\u72B6\u6001\u7684\u6761\u76EE\u3002\u53EF\u628A\u72B6\u6001\u7B5B\u9009\u5207\u5230\u300C\u5168\u90E8\u300D\u6216\u300C\u5DF2\u5173\u95ED\u300D\u3002",
2365
+ "panel.toast.copied": "\u5DF2\u590D\u5236",
2366
+ "panel.toast.promptCopied": "Prompt \u5DF2\u590D\u5236",
2367
+ "panel.toast.pinned": "\u5DF2\u56FA\u5B9A\u5230\u4EA4\u529E\u6761",
2368
+ "panel.filter.milestone": "\u91CC\u7A0B\u7891",
2369
+ "panel.filter.label": "\u6807\u7B7E",
2370
+ "panel.filter.all": "\u5168\u90E8",
2371
+ "panel.private": "\u79C1\u6709",
2372
+ "panel.type": "\u7C7B\u578B",
2373
+ "panel.view": "\u89C6\u56FE",
2374
+ "panel.settings": "\u8BBE\u7F6E",
2375
+ "panel.noAssignees": "\u672A\u6307\u6D3E",
2376
+ "panel.noMilestone": "\u65E0\u91CC\u7A0B\u7891",
2377
+ "panel.noPriority": "\u65E0\u4F18\u5148\u7EA7",
2378
+ "panel.noType": "\u65E0\u7C7B\u578B",
2379
+ "panel.draft": "\u8349\u7A3F",
2380
+ "panel.merged": "\u5DF2\u5408\u5E76",
2381
+ "panel.closedPR": "\u5DF2\u5173\u95ED",
2382
+ "panel.openPR": "\u6253\u5F00",
2383
+ "panel.checks.failure": "{count} \u4E2A\u68C0\u67E5\u5931\u8D25",
2384
+ "panel.review.approved": "\u5DF2\u901A\u8FC7",
2385
+ "panel.review.changes": "\u8981\u6C42\u4FEE\u6539",
2386
+ "panel.review.required": "\u7B49\u5F85\u5BA1\u67E5",
2387
+ "dock.title": "GitHub Issues",
2388
+ "dock.pending": "\u5F85\u53D1\u9001",
2389
+ "sidebar.tab": "Issues",
2390
+ "sidebar.search": "\u7B5B\u9009\u53F3\u680F\u5217\u8868\u2026",
2391
+ "sidebar.dragHint": "\u628A\u4E00\u884C\u62D6\u8FDB\u8F93\u5165\u6846\uFF0C\u5373\u53EF\u4EA4\u7ED9\u5F53\u524D Session\u3002",
2392
+ "sidebar.empty": "\u5F53\u524D\u7B5B\u9009\u4E0B\u6CA1\u6709 Issue",
2393
+ "sidebar.emptyHint": "\u5728\u4E3B GitHub \u9762\u677F\u91CC\u8C03\u6574\u7EA7\u8054\u7B5B\u9009\u3002",
2394
+ "drop.release": "\u677E\u5F00\u4EE5\u4EA4\u7ED9 Agent",
2395
+ "drop.hint": "\u4F1A\u586B\u5165\u8349\u7A3F\u5E76\u4F5C\u4E3A Issue chip \u663E\u793A",
2396
+ "drop.cancel": "\u53D6\u6D88",
2397
+ "pending.hint": "\u968F\u63D0\u793A\u8BCD\u4E00\u8D77\u53D1\u9001\uFF0C\u53D1\u9001\u540E\u53D8\u6210\u4E0B\u65B9\u5DF2\u5173\u8054 chip\u3002",
2398
+ "pending.tip": "\u53D1\u9001\u65F6\u8FD9\u5F20\u5361\u7247\u4F1A\u81EA\u52A8\u8F6C\u6210 Issue \u63D0\u793A\u8BCD\uFF0C\u4F60\u8F93\u5165\u7684\u5185\u5BB9\u4F1A\u9644\u5728\u540E\u9762\u3002",
2399
+ "dock.loading": "\u6B63\u5728\u52A0\u8F7D Issue\u2026",
2400
+ "dock.removeDraft": "\u6E05\u7A7A\u8349\u7A3F",
2401
+ "dock.unlink": "\u89E3\u9664\u672C Session \u5173\u8054",
2402
+ "dock.linked": "\u4EA4\u529E\u7ED9",
2403
+ "dock.remove": "\u4ECE\u5F53\u524D\u5BF9\u8BDD\u79FB\u9664",
2404
+ "panel.noSession": "\u8FD8\u6CA1\u6709\u4EA4\u529E\u7ED9\u4EFB\u4F55 Session\u3002",
2405
+ "panel.openSession": "\u8FDB\u5165 Session",
2406
+ "panel.enterSession": "\u8FDB\u5165",
2407
+ "panel.newSession": "\u518D\u5F00\u4E00\u4E2A Session",
2408
+ "panel.sessions": "\u5173\u8054\u7684 Session",
2409
+ "panel.sessionsHint": "\u8FDB\u5165\u67D0\u4E2A Session \u7EE7\u7EED\u5904\u7406\uFF1B\u89E3\u9664\u53EA\u79FB\u9664\u5173\u8054\uFF0C\u4E0D\u4F1A\u5220\u9664 Session\u3002",
2410
+ "panel.unlinkSession": "\u89E3\u9664",
2411
+ "panel.unlinkSessionHint": "\u53EA\u79FB\u9664 Issue \u4E0E Session \u7684\u5173\u8054\uFF0C\u4E0D\u4F1A\u5220\u9664 Session\u3002",
2412
+ "panel.sessionUnavailable": "\u5DF2\u4E0D\u53EF\u7528\uFF08\u5DF2\u5220\u9664\u6216\u5F52\u6863\uFF09",
2413
+ "panel.copyPrompt": "\u590D\u5236\u63D0\u793A\u8BCD",
2414
+ "panel.openSessionNamed": "\u8FDB\u5165 {title}",
2415
+ "panel.sessionMissing": "Session \u4E0D\u53EF\u7528",
2416
+ "panel.linkedBadge": "{count} \u4E2A Session",
2417
+ "panel.handToAgent": "\u4EA4\u7ED9 Agent",
2418
+ "panel.handoffNewSession": "\u4F1A\u5728\u5339\u914D\u7684\u5DE5\u4F5C\u533A\u65B0\u5F00\u4E00\u4E2A Session \u5904\u7406",
2419
+ "panel.openInPanel": "\u5728 GitHub \u9762\u677F\u6253\u5F00",
2420
+ "dock.pinned": "\u5F53\u524D Issue",
2421
+ "dock.empty": "\u5728 GitHub \u9762\u677F\u91CC\u56FA\u5B9A\u4E00\u4E2A Issue\uFF0C\u6216\u628A Issue \u62D6\u5230\u8FD9\u91CC\u3002",
2422
+ "dock.insert": "\u586B\u5165\u8349\u7A3F",
2423
+ "dock.send": "\u76F4\u63A5\u53D1\u9001",
2424
+ "dock.clear": "\u53D6\u6D88\u56FA\u5B9A",
2425
+ "dock.drop": "\u677E\u624B\u5373\u628A\u8BE5 Issue \u586B\u5165\u8F93\u5165\u6846",
2426
+ "dock.drag": "\u628A\u8FD9\u4E2A Issue \u62D6\u5230\u8F93\u5165\u6846\uFF0C\u5373\u53EF\u5199\u5165 prompt",
2427
+ "dock.disabled": "\u8F93\u5165\u6846\u5C1A\u672A\u5C31\u7EEA\u3002",
2428
+ "dock.open": "\u5728 GitHub \u6253\u5F00",
2429
+ "settings.title": "GitHub",
2430
+ "settings.auth": "\u6388\u6743",
2431
+ "settings.signedIn": "\u5DF2\u767B\u5F55 {login}",
2432
+ "settings.signedOut": "\u672A\u767B\u5F55",
2433
+ "settings.ghMissing": "\u672A\u627E\u5230 gh CLI\u3002",
2434
+ "settings.scopes": "Token \u6743\u9650",
2435
+ "settings.missingProject": "\u7F3A\u5C11 read:project \u6743\u9650\uFF08Projects v2\uFF09\u3002",
2436
+ "settings.command": "\u5728\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21\uFF0C\u7136\u540E\u5237\u65B0\uFF1A",
2437
+ "settings.copy": "\u590D\u5236",
2438
+ "settings.handoff": "\u4EA4\u529E\u884C\u4E3A",
2439
+ "settings.handoff.draft": "\u53EA\u586B\u5165\u8349\u7A3F\uFF08\u63A8\u8350\uFF09",
2440
+ "settings.handoff.send": "\u76F4\u63A5\u53D1\u9001",
2441
+ "settings.template": "Prompt \u6A21\u677F",
2442
+ "settings.template.help": "\u53EF\u7528\u53D8\u91CF\uFF1A{{repo}} {{number}} {{title}} {{url}} {{state}} {{milestone}} {{priority}} {{assignees}} {{labels}} {{prs}}",
2443
+ "settings.save": "\u4FDD\u5B58",
2444
+ "settings.saved": "\u5DF2\u4FDD\u5B58",
2445
+ "settings.reset": "\u6062\u590D\u9ED8\u8BA4",
2446
+ "settings.refresh": "\u5237\u65B0\u72B6\u6001",
2447
+ "settings.about": "\u8BF4\u660E",
2448
+ "settings.aboutText": "\u6240\u6709\u6570\u636E\u53EA\u5728\u672C\u673A\u6D41\u8F6C\uFF1Atoken \u4ECE gh CLI \u8BFB\u53D6\uFF0C\u4E0D\u5199\u5165\u914D\u7F6E\u6216\u9875\u9762\uFF1BIssue \u6570\u636E\u7531\u672C\u673A Host \u8FDB\u7A0B\u8BF7\u6C42 GitHub\u3002",
2449
+ "settings.error": "\u9519\u8BEF\uFF1A{message}",
2450
+ "settings.authModeGh": "\u590D\u7528 gh CLI token",
2451
+ "settings.loading": "\u68C0\u67E5\u4E2D\u2026",
2452
+ "settings.credentialHint": "token \u7559\u5728\u7CFB\u7EDF\u94A5\u5319\u4E32\uFF1A\u672C\u63D2\u4EF6\u53EA\u662F\u5411 gh \u8BFB\u53D6\u5B83\u3002",
2453
+ "settings.login": "\u8D26\u53F7",
2454
+ "settings.host": "\u4E3B\u673A",
2455
+ "settings.tokenSource": "Token \u6765\u6E90",
2456
+ "panel.stateFilter": "\u72B6\u6001",
2457
+ "panel.clearSearch": "\u6E05\u9664\u7B5B\u9009",
2458
+ "panel.more": "+{count}",
2459
+ "panel.showing": "\u663E\u793A {count} \u6761",
2460
+ "panel.retry": "\u91CD\u8BD5",
2461
+ "panel.detail.empty": "\u9009\u62E9\u4E00\u4E2A Issue \u67E5\u770B\u8BE6\u60C5\u3002",
2462
+ "panel.noBody": "\u672A\u63D0\u4F9B\u6B63\u6587\u3002",
2463
+ "panel.noRepos": "\u6B64 token \u4E0B\u672A\u627E\u5230\u4ED3\u5E93\u3002",
2464
+ "panel.noProjects": "\u672A\u627E\u5230 Projects v2 \u9879\u76EE\u3002",
2465
+ "panel.checks.success": "\u68C0\u67E5\u901A\u8FC7",
2466
+ "panel.checks.pending": "\u68C0\u67E5\u8FD0\u884C\u4E2D",
2467
+ "panel.checks.none": "\u65E0\u68C0\u67E5"
2468
+ };
2469
+ var DICTS = { en, zh };
2470
+
2471
+ // src/remote-methods.ts
2472
+ var REMOTE_METHODS = [
2473
+ { method: "status", parameters: [] },
2474
+ { method: "catalog", parameters: [] },
2475
+ { method: "orgProjects", parameters: [{ wire: "org" }] },
2476
+ { method: "orgRepos", parameters: [{ wire: "org" }] },
2477
+ { method: "listIssues", parameters: [{ wire: "request" }] },
2478
+ { method: "repoMilestones", parameters: [{ wire: "repo" }] },
2479
+ { method: "issueDetail", parameters: [{ wire: "repo" }, { wire: "number" }] },
2480
+ { method: "issueMentionedPRs", parameters: [{ wire: "repo" }, { wire: "number" }] },
2481
+ { method: "loadPrefs", parameters: [] },
2482
+ { method: "savePrefs", parameters: [{ wire: "patch" }] },
2483
+ { method: "refresh", parameters: [] },
2484
+ { method: "links", parameters: [] },
2485
+ { method: "linkIssue", parameters: [{ wire: "repo" }, { wire: "number" }, { wire: "sessionId" }] },
2486
+ { method: "unlinkIssue", parameters: [{ wire: "repo" }, { wire: "number" }, { wire: "sessionId", optional: true }] }
2487
+ ];
2488
+ var REMOTE_SERVICE_KEY = "githubIssuesController";
2489
+ var REMOTE_NAMESPACE = "githubIssues";
2490
+
2491
+ // src/client/remote.ts
2492
+ var PACKAGE = "dsh-plugin-github-issues";
2493
+ var RESULT_CODEC = { mode: "src-json" };
2494
+ function parameterCodec(typeSymbol) {
2495
+ return {
2496
+ mode: "strict",
2497
+ typeSymbol,
2498
+ create: () => ({ parse: (value) => value })
2499
+ };
2500
+ }
2501
+ function remoteContribution() {
2502
+ return {
2503
+ package: PACKAGE,
2504
+ descriptors: REMOTE_METHODS.map(({ method, parameters }) => ({
2505
+ id: `${PACKAGE}#${REMOTE_NAMESPACE}/${method}`,
2506
+ service: REMOTE_SERVICE_KEY,
2507
+ namespace: REMOTE_NAMESPACE,
2508
+ method,
2509
+ invocation: { kind: "direct" },
2510
+ parameters: parameters.map(({ wire, optional }) => ({
2511
+ name: wire,
2512
+ wire,
2513
+ source: "json",
2514
+ codec: parameterCodec(`${PACKAGE}#${REMOTE_NAMESPACE}/${method}:${wire}`),
2515
+ ...optional === true ? { acceptsUndefined: true } : {}
2516
+ })),
2517
+ result: RESULT_CODEC,
2518
+ // Point the descriptor at the declaration it mirrors so a Gateway diagnostic
2519
+ // leads to the method it is really about.
2520
+ sourceLocation: { file: "src/controller.ts", line: 1, column: 1 }
2521
+ }))
2522
+ };
2523
+ }
2524
+
2525
+ // src/client/result.ts
2526
+ var RemoteRefusal = class extends Error {
2527
+ code;
2528
+ /**
2529
+ * @param message - human text for the panel.
2530
+ * @param code - the Host's machine code, when it sent one.
2531
+ */
2532
+ constructor(message, code) {
2533
+ super(message);
2534
+ this.name = "RemoteRefusal";
2535
+ this.code = code;
2536
+ }
2537
+ };
2538
+ function unwrap(result) {
2539
+ if (result.ok) return result.value;
2540
+ const code = result.error?.code;
2541
+ const message = result.error?.message;
2542
+ if (message === void 0 || message.length === 0) {
2543
+ throw new RemoteRefusal(code === void 0 ? "the GitHub service refused the request" : `GitHub request failed (${code})`, code);
2544
+ }
2545
+ throw new RemoteRefusal(message, code);
2546
+ }
2547
+
2548
+ // src/workspace.ts
2549
+ function basename(path) {
2550
+ const trimmed = path.replace(/[/\\]+$/, "");
2551
+ const index = Math.max(trimmed.lastIndexOf("/"), trimmed.lastIndexOf("\\"));
2552
+ return (index === -1 ? trimmed : trimmed.slice(index + 1)).toLowerCase();
2553
+ }
2554
+ function resolveHandoffWorkspace(input) {
2555
+ const workspaces = input.workspaces;
2556
+ if (workspaces.length === 0) return void 0;
2557
+ const bySession = (sessionIds) => {
2558
+ for (const sessionId of sessionIds) {
2559
+ const hit = workspaces.find((workspace) => workspace.sessionIds.includes(sessionId));
2560
+ if (hit !== void 0) return hit.workspaceId;
2561
+ }
2562
+ return void 0;
2563
+ };
2564
+ if (input.currentSessionId !== void 0) {
2565
+ const source = bySession([input.currentSessionId]);
2566
+ if (source !== void 0) return source;
2567
+ }
2568
+ if (input.linkedSessionIds !== void 0 && input.linkedSessionIds.length !== 0) {
2569
+ const linked = bySession(input.linkedSessionIds);
2570
+ if (linked !== void 0) return linked;
2571
+ }
2572
+ const repoName = basename(input.repo);
2573
+ const directory = workspaces.find((workspace) => workspace.path !== void 0 && basename(workspace.path) === repoName || workspace.title !== void 0 && workspace.title.toLowerCase() === repoName);
2574
+ if (directory !== void 0) return directory.workspaceId;
2575
+ return void 0;
2576
+ }
2577
+
2578
+ // src/client/store.ts
2579
+ var REMOTE_WAIT_MS = 15e3;
2580
+ var REMOTE_POLL_MS = 250;
2581
+ var REMOTE_KEY = `remote.${REMOTE_NAMESPACE}`;
2582
+ var SIDEBAR_KIND = "github-issues";
2583
+ var TOAST_MS = 2500;
2584
+ function asPanelError(error) {
2585
+ if (error instanceof RemoteRefusal) {
2586
+ return { message: error.message, ...error.code === void 0 ? {} : { code: error.code } };
2587
+ }
2588
+ return { message: error instanceof Error ? error.message : String(error) };
2589
+ }
2590
+ async function waitForRemote(ctx) {
2591
+ const deadline = Date.now() + REMOTE_WAIT_MS;
2592
+ for (; ; ) {
2593
+ const namespace = ctx.get(REMOTE_KEY);
2594
+ if (typeof namespace?.listIssues === "function") return namespace;
2595
+ if (Date.now() >= deadline) {
2596
+ throw new Error("the GitHub service is not reachable from this window; reload the window and try again");
2597
+ }
2598
+ await new Promise((resolve) => {
2599
+ setTimeout(resolve, REMOTE_POLL_MS);
2600
+ });
2601
+ }
2602
+ }
2603
+ var GitHubStore = class {
2604
+ /**
2605
+ * @param ctx - the browser plugin context.
2606
+ * @param mounting - settles when the hand-written Remote namespace is mounted.
2607
+ */
2608
+ constructor(ctx, runtime, mounting) {
2609
+ this.ctx = ctx;
2610
+ this.runtime = runtime;
2611
+ this.mounting = mounting;
2612
+ void mounting.then(() => void 0);
2613
+ }
2614
+ snapshot = {
2615
+ loading: false,
2616
+ loadingMore: false,
2617
+ scopeLoading: false,
2618
+ detailLoading: false,
2619
+ prefs: DEFAULT_PREFS,
2620
+ projectsBlocked: false,
2621
+ milestoneOptions: [],
2622
+ links: [],
2623
+ linkCards: {}
2624
+ };
2625
+ listeners = /* @__PURE__ */ new Set();
2626
+ orgScopes = /* @__PURE__ */ new Map();
2627
+ remote;
2628
+ started = false;
2629
+ pollTimer;
2630
+ toastTimer;
2631
+ listSeq = 0;
2632
+ /** Subscribe one renderer to state changes. */
2633
+ subscribe = (listener) => {
2634
+ this.listeners.add(listener);
2635
+ return () => {
2636
+ this.listeners.delete(listener);
2637
+ };
2638
+ };
2639
+ /** The current immutable snapshot. */
2640
+ getSnapshot = () => this.snapshot;
2641
+ /** Start loading and polling. Idempotent. */
2642
+ start() {
2643
+ if (this.started) return;
2644
+ this.started = true;
2645
+ void this.bootstrap();
2646
+ }
2647
+ /** Stop every timer this store owns. */
2648
+ stop() {
2649
+ this.started = false;
2650
+ if (this.pollTimer !== void 0) clearInterval(this.pollTimer);
2651
+ if (this.toastTimer !== void 0) clearTimeout(this.toastTimer);
2652
+ this.pollTimer = void 0;
2653
+ this.toastTimer = void 0;
2654
+ }
2655
+ /** Load prefs, auth facts, the catalog, the saved scope, and the first page. */
2656
+ async bootstrap() {
2657
+ this.update({ loading: true, error: void 0 });
2658
+ try {
2659
+ const remote = await this.api();
2660
+ const [status, prefs] = await Promise.all([
2661
+ remote.status().then((result) => unwrap(result)),
2662
+ remote.loadPrefs().then((result) => unwrap(result))
2663
+ ]);
2664
+ let sanePrefs = prefs.projectId !== void 0 && prefs.org === void 0 ? { ...prefs, projectId: void 0, repo: prefs.repo } : prefs;
2665
+ if (sanePrefs.projectId !== void 0 && sanePrefs.milestone !== void 0) {
2666
+ sanePrefs = { ...sanePrefs, milestone: void 0 };
2667
+ void this.savePrefs({ milestone: null });
2668
+ }
2669
+ this.update({
2670
+ status,
2671
+ prefs: sanePrefs,
2672
+ projectsBlocked: status.missingProjectScope,
2673
+ loading: false
2674
+ });
2675
+ if (sanePrefs.projectId === void 0 && prefs.projectId !== void 0) {
2676
+ void this.savePrefs({ projectId: null });
2677
+ }
2678
+ if (sanePrefs.repo !== void 0) void this.loadRepoMilestones(sanePrefs.repo);
2679
+ void this.loadCatalog();
2680
+ void this.loadLinks();
2681
+ if (prefs.org !== void 0) void this.loadOrgScope(prefs.org);
2682
+ await this.reloadList();
2683
+ this.schedulePolling(status.config.pollSeconds);
2684
+ void this.hydratePinned();
2685
+ } catch (error) {
2686
+ this.update({ loading: false, error: asPanelError(error) });
2687
+ }
2688
+ }
2689
+ /** Poll only while the page is visible, at the configured cadence. */
2690
+ schedulePolling(configuredSeconds) {
2691
+ const seconds = Number.isFinite(configuredSeconds) ? Math.min(Math.max(configuredSeconds, 30), 600) : 90;
2692
+ if (this.pollTimer !== void 0) clearInterval(this.pollTimer);
2693
+ this.pollTimer = setInterval(() => {
2694
+ if (typeof document !== "undefined" && document.visibilityState !== "visible") return;
2695
+ if (this.snapshot.loading || this.snapshot.loadingMore) return;
2696
+ void this.reloadList(true);
2697
+ }, seconds * 1e3);
2698
+ }
2699
+ /** Resolve the Remote namespace, or throw the mount's own refusal. */
2700
+ async api() {
2701
+ if (this.remote !== void 0) return this.remote;
2702
+ const refused = await this.mounting;
2703
+ if (refused !== void 0) throw new Error(`the GitHub service could not be mounted: ${refused}`);
2704
+ this.remote = await waitForRemote(this.ctx);
2705
+ return this.remote;
2706
+ }
2707
+ /** Merge one snapshot patch and notify renderers. */
2708
+ update(patch) {
2709
+ this.snapshot = { ...this.snapshot, ...patch };
2710
+ for (const listener of this.listeners) listener();
2711
+ }
2712
+ /** Show one transient confirmation. */
2713
+ toast(text) {
2714
+ this.update({ toast: text });
2715
+ if (this.toastTimer !== void 0) clearTimeout(this.toastTimer);
2716
+ this.toastTimer = setTimeout(() => {
2717
+ this.update({ toast: void 0 });
2718
+ }, TOAST_MS);
2719
+ }
2720
+ /** Build the list request the current cascade describes. */
2721
+ request(after) {
2722
+ const prefs = this.snapshot.prefs;
2723
+ const request = {
2724
+ state: prefs.state,
2725
+ assignee: prefs.assignee,
2726
+ first: 30,
2727
+ after
2728
+ };
2729
+ if (prefs.org !== void 0) request.org = prefs.org;
2730
+ if (prefs.org !== void 0 && prefs.projectId !== void 0) request.projectId = prefs.projectId;
2731
+ if (prefs.repo !== void 0) request.repos = [prefs.repo];
2732
+ if (prefs.projectId === void 0 && prefs.milestone !== void 0) request.milestone = prefs.milestone;
2733
+ return request;
2734
+ }
2735
+ /** Fetch the first page of the current cascade. */
2736
+ async reloadList(quiet = false) {
2737
+ const seq = ++this.listSeq;
2738
+ if (!quiet) this.update({ loading: true, error: void 0 });
2739
+ try {
2740
+ const remote = await this.api();
2741
+ const page = await remote.listIssues(this.request(null)).then((result) => unwrap(result));
2742
+ if (seq !== this.listSeq) return;
2743
+ this.update({
2744
+ list: page,
2745
+ loading: false,
2746
+ loadingMore: false,
2747
+ error: void 0
2748
+ });
2749
+ this.rememberMilestones(page.items);
2750
+ this.refreshPinnedCard();
2751
+ } catch (error) {
2752
+ if (seq !== this.listSeq) return;
2753
+ this.update({ loading: false, loadingMore: false, error: asPanelError(error) });
2754
+ }
2755
+ }
2756
+ /** Load the viewer/organization catalog once. */
2757
+ async loadCatalog() {
2758
+ if (this.snapshot.catalog !== void 0) return;
2759
+ try {
2760
+ const remote = await this.api();
2761
+ const catalog = await remote.catalog().then((result) => unwrap(result));
2762
+ this.update({
2763
+ catalog,
2764
+ projectsBlocked: this.snapshot.status?.missingProjectScope === true || catalog.projectsBlocked
2765
+ });
2766
+ } catch (error) {
2767
+ this.update({ error: asPanelError(error) });
2768
+ }
2769
+ }
2770
+ /**
2771
+ * Load the projects and repositories of one organization, once per session.
2772
+ * A Projects v2 permission failure degrades to `projectsBlocked` while the
2773
+ * repository list still works.
2774
+ */
2775
+ async loadOrgScope(org) {
2776
+ const cached = this.orgScopes.get(org);
2777
+ if (cached !== void 0) {
2778
+ this.update({
2779
+ orgProjects: cached.projects,
2780
+ orgRepos: cached.repos,
2781
+ projectsBlocked: cached.blocked || this.snapshot.status?.missingProjectScope === true,
2782
+ ...cached.error === void 0 ? { projectsError: void 0 } : { projectsError: cached.error }
2783
+ });
2784
+ return;
2785
+ }
2786
+ this.update({ scopeLoading: true });
2787
+ try {
2788
+ const remote = await this.api();
2789
+ const [projects, repos] = await Promise.all([
2790
+ remote.orgProjects(org).then((result) => unwrap(result)),
2791
+ remote.orgRepos(org).then((result) => unwrap(result))
2792
+ ]);
2793
+ const scope = {
2794
+ projects: projects.projects,
2795
+ repos,
2796
+ blocked: projects.blocked || this.snapshot.status?.missingProjectScope === true,
2797
+ ...projects.error === void 0 ? {} : { error: projects.error }
2798
+ };
2799
+ this.orgScopes.set(org, scope);
2800
+ this.update({
2801
+ orgProjects: scope.projects,
2802
+ orgRepos: scope.repos,
2803
+ projectsBlocked: scope.blocked,
2804
+ ...scope.error === void 0 ? { projectsError: void 0 } : { projectsError: scope.error },
2805
+ scopeLoading: false
2806
+ });
2807
+ } catch (error) {
2808
+ this.update({ scopeLoading: false, error: asPanelError(error) });
2809
+ }
2810
+ }
2811
+ /** Keep the dock's copy of the pinned issue in sync with the loaded list. */
2812
+ refreshPinnedCard() {
2813
+ const pinned = this.snapshot.prefs.pinned;
2814
+ if (pinned === void 0) {
2815
+ if (this.snapshot.pinnedCard !== void 0) this.update({ pinnedCard: void 0 });
2816
+ return;
2817
+ }
2818
+ const found = this.snapshot.list?.items.find((item) => item.repo === pinned.repo && item.number === pinned.number);
2819
+ if (found !== void 0 && this.snapshot.pinnedCard?.id !== found.id) this.update({ pinnedCard: found });
2820
+ }
2821
+ /** A card for one issue from the loaded list, or a minimal placeholder. */
2822
+ cardFor(repo, number) {
2823
+ const found = this.snapshot.list?.items.find((item) => item.repo === repo && item.number === number);
2824
+ if (found !== void 0) return found;
2825
+ return {
2826
+ id: `${repo}#${String(number)}`,
2827
+ repo,
2828
+ number,
2829
+ title: "",
2830
+ url: `https://github.com/${repo}/issues/${String(number)}`,
2831
+ state: "OPEN",
2832
+ stateReason: null,
2833
+ isPrivate: false,
2834
+ labels: [],
2835
+ assignees: [],
2836
+ updatedAt: "",
2837
+ commentCount: 0,
2838
+ linkedPRs: [],
2839
+ sessionLinks: []
2840
+ };
2841
+ }
2842
+ /** The pinned issue's card, when the loaded list carries it. */
2843
+ async hydratePinned() {
2844
+ const pinned = this.snapshot.prefs.pinned;
2845
+ if (pinned === void 0 || this.snapshot.pinnedCard !== void 0) return;
2846
+ const found = this.snapshot.list?.items.find((item) => item.repo === pinned.repo && item.number === pinned.number);
2847
+ if (found !== void 0) this.update({ pinnedCard: found });
2848
+ }
2849
+ // ── PanelActions ────────────────────────────────────────────────────────────
2850
+ refresh() {
2851
+ void (async () => {
2852
+ try {
2853
+ const remote = await this.api();
2854
+ await remote.refresh();
2855
+ const status = await remote.status().then((result) => unwrap(result));
2856
+ this.orgScopes.clear();
2857
+ this.update({
2858
+ status,
2859
+ catalog: void 0,
2860
+ orgProjects: void 0,
2861
+ orgRepos: void 0,
2862
+ projectsBlocked: status.missingProjectScope,
2863
+ projectsError: void 0
2864
+ });
2865
+ } catch (error) {
2866
+ this.update({ error: asPanelError(error) });
2867
+ return;
2868
+ }
2869
+ const org = this.snapshot.prefs.org;
2870
+ if (org !== void 0) void this.loadOrgScope(org);
2871
+ await this.reloadList();
2872
+ void this.loadCatalog();
2873
+ })();
2874
+ }
2875
+ loadMore() {
2876
+ const page = this.snapshot.list;
2877
+ if (page === void 0 || !page.pageInfo.hasNextPage || this.snapshot.loadingMore) return;
2878
+ this.update({ loadingMore: true });
2879
+ void (async () => {
2880
+ try {
2881
+ const remote = await this.api();
2882
+ const next = await remote.listIssues(this.request(page.pageInfo.endCursor)).then((result) => unwrap(result));
2883
+ this.rememberMilestones(next.items);
2884
+ this.update({
2885
+ loadingMore: false,
2886
+ list: {
2887
+ ...page,
2888
+ items: [...page.items, ...next.items.filter((item) => !page.items.some((existing) => existing.id === item.id))],
2889
+ pageInfo: next.pageInfo,
2890
+ ...next.totalCount === void 0 ? {} : { totalCount: next.totalCount }
2891
+ }
2892
+ });
2893
+ } catch (error) {
2894
+ this.update({ loadingMore: false, error: asPanelError(error) });
2895
+ }
2896
+ })();
2897
+ }
2898
+ setOrg(org) {
2899
+ this.resetMilestoneOptions();
2900
+ void this.savePrefs({ org: org ?? null, projectId: null, repo: null, milestone: null }, async (saved) => {
2901
+ this.update({ orgProjects: void 0, orgRepos: void 0 });
2902
+ if (saved.org !== void 0) await this.loadOrgScope(saved.org);
2903
+ });
2904
+ }
2905
+ setProject(projectId) {
2906
+ if (projectId !== void 0) this.resetMilestoneOptions();
2907
+ void this.savePrefs({
2908
+ projectId: projectId ?? null,
2909
+ ...projectId === void 0 ? {} : { milestone: null }
2910
+ });
2911
+ }
2912
+ setRepo(repo) {
2913
+ this.resetMilestoneOptions();
2914
+ void this.savePrefs({ repo: repo ?? null, milestone: null }, async (saved) => {
2915
+ if (saved.repo !== void 0) await this.loadRepoMilestones(saved.repo);
2916
+ });
2917
+ }
2918
+ setMilestone(milestone) {
2919
+ void this.savePrefs({ milestone: milestone ?? null });
2920
+ }
2921
+ /** Clear the milestone picker's options for a new scope. */
2922
+ resetMilestoneOptions() {
2923
+ if (this.snapshot.milestoneOptions.length !== 0) this.update({ milestoneOptions: [] });
2924
+ }
2925
+ /** Merge milestones seen in one list page into the picker's options. */
2926
+ rememberMilestones(items) {
2927
+ const options = [...this.snapshot.milestoneOptions];
2928
+ const seen = new Set(options);
2929
+ const selected = this.snapshot.prefs.milestone;
2930
+ let changed = false;
2931
+ for (const card of items) {
2932
+ const title = card.milestone?.title;
2933
+ if (title === void 0 || title === "" || seen.has(title)) continue;
2934
+ seen.add(title);
2935
+ options.push(title);
2936
+ changed = true;
2937
+ }
2938
+ if (selected !== void 0 && !seen.has(selected)) {
2939
+ options.unshift(selected);
2940
+ changed = true;
2941
+ }
2942
+ if (changed) this.update({ milestoneOptions: options });
2943
+ }
2944
+ /** Seed the picker from the selected repository's full milestone list. */
2945
+ async loadRepoMilestones(repo) {
2946
+ try {
2947
+ const remote = await this.api();
2948
+ const result = await remote.repoMilestones(repo).then((response) => unwrap(response));
2949
+ if (this.snapshot.prefs.repo !== repo) return;
2950
+ const options = [...this.snapshot.milestoneOptions];
2951
+ const seen = new Set(options);
2952
+ for (const title of result.milestones) {
2953
+ if (title === "" || seen.has(title)) continue;
2954
+ seen.add(title);
2955
+ options.push(title);
2956
+ }
2957
+ this.update({ milestoneOptions: options });
2958
+ } catch {
2959
+ }
2960
+ }
2961
+ setAssignee(assignee) {
2962
+ void this.savePrefs({ assignee });
2963
+ }
2964
+ setStateFilter(state) {
2965
+ void this.savePrefs({ state });
2966
+ }
2967
+ selectIssue(card) {
2968
+ this.update({ selected: card, detail: void 0, detailLoading: true, mentionedLoading: false });
2969
+ void (async () => {
2970
+ try {
2971
+ const remote = await this.api();
2972
+ const body = await remote.issueDetail(card.repo, card.number).then((result) => unwrap(result));
2973
+ this.update({
2974
+ detail: { ...card, body: body.body, mentionedPRs: [] },
2975
+ detailLoading: false,
2976
+ mentionedLoading: true
2977
+ });
2978
+ const mentioned = await remote.issueMentionedPRs(card.repo, card.number).then((result) => unwrap(result));
2979
+ const current = this.snapshot.detail;
2980
+ if (current === void 0 || current.repo !== card.repo || current.number !== card.number) return;
2981
+ const closing = new Set(current.linkedPRs.map((pr) => pr.number));
2982
+ this.update({
2983
+ detail: { ...current, mentionedPRs: mentioned.mentionedPRs.filter((pr) => !closing.has(pr.number)) },
2984
+ mentionedLoading: false
2985
+ });
2986
+ } catch (error) {
2987
+ this.update({ detailLoading: false, mentionedLoading: false, error: asPanelError(error) });
2988
+ }
2989
+ })();
2990
+ }
2991
+ closeDetail() {
2992
+ this.update({ selected: void 0, detail: void 0, detailLoading: false, mentionedLoading: false });
2993
+ }
2994
+ async savePrefs(patch, after) {
2995
+ try {
2996
+ const remote = await this.api();
2997
+ const saved = await remote.savePrefs(patch).then((result) => unwrap(result));
2998
+ const affectsList = ["org", "projectId", "repo", "assignee", "state", "milestone"].some((key) => key in patch);
2999
+ this.update({ prefs: saved });
3000
+ if (affectsList) {
3001
+ await this.reloadList();
3002
+ this.refreshPinnedCard();
3003
+ } else if ("handoffMode" in patch || "promptTemplate" in patch) {
3004
+ this.toast("settings.saved");
3005
+ }
3006
+ if (after !== void 0) await after(saved);
3007
+ } catch (error) {
3008
+ this.update({ error: asPanelError(error) });
3009
+ }
3010
+ }
3011
+ pin(card) {
3012
+ this.update({ pinnedCard: card });
3013
+ this.toast("panel.toast.pinned");
3014
+ void this.savePrefs({ pinned: { repo: card.repo, number: card.number } });
3015
+ }
3016
+ unpin() {
3017
+ this.update({ pinnedCard: void 0, pendingHandoff: void 0 });
3018
+ void this.savePrefs({ pinned: null });
3019
+ }
3020
+ /** Start a drag from the right-sidebar list; the composer shows the target. */
3021
+ dragIssue(card) {
3022
+ this.update({ dragging: card });
3023
+ }
3024
+ /** End a drag without a handoff. */
3025
+ endDrag() {
3026
+ if (this.snapshot.dragging !== void 0) this.update({ dragging: void 0 });
3027
+ }
3028
+ /**
3029
+ * Drop the dragged issue on the composer of the Session it was dragged into:
3030
+ * the dock that mounts with this Session consumes the pending handoff and
3031
+ * writes the prompt. No new Session is created for a drag.
3032
+ */
3033
+ dropHandoff(sessionId) {
3034
+ const card = this.snapshot.dragging;
3035
+ this.update({
3036
+ dragging: void 0,
3037
+ ...card === void 0 ? {} : {
3038
+ pendingHandoff: card,
3039
+ ...sessionId === void 0 ? {} : { pendingHandoffSession: sessionId }
3040
+ }
3041
+ });
3042
+ }
3043
+ /** Open the co-visible right-sidebar tab for the on-screen Session. */
3044
+ openInSidebar() {
3045
+ this.service("layout")?.selectPanel(null);
3046
+ setTimeout(() => {
3047
+ this.service("sidebarRight")?.openTab(SIDEBAR_KIND);
3048
+ }, 80);
3049
+ }
3050
+ /** The Workspace a new handoff Session should open in, per the agreed priority. */
3051
+ workspaceForHandoff(repo) {
3052
+ const workspaces = this.runtime.getService("workspaces")?.list?.getSnapshot();
3053
+ const items = [];
3054
+ for (const item of workspaces?.items ?? []) {
3055
+ const entry = item;
3056
+ if (entry.workspaceId === void 0) continue;
3057
+ items.push({
3058
+ workspaceId: entry.workspaceId,
3059
+ ...entry.path === void 0 ? {} : { path: entry.path },
3060
+ ...entry.title === void 0 || entry.title === null ? {} : { title: entry.title },
3061
+ sessionIds: item.sessionIds ?? []
3062
+ });
3063
+ }
3064
+ const currentSessionId = this.runtime.getService("uiSession")?.adapter?.current?.getSnapshot()?.key;
3065
+ const linkedSessionIds = this.snapshot.links.filter((link) => link.repo === repo).map((link) => link.sessionId);
3066
+ return resolveHandoffWorkspace({
3067
+ repo,
3068
+ ...currentSessionId === void 0 ? {} : { currentSessionId },
3069
+ linkedSessionIds,
3070
+ workspaces: items
3071
+ });
3072
+ }
3073
+ handoff(card) {
3074
+ this.pin(card);
3075
+ const uiWorkspace = this.service("uiWorkspace");
3076
+ if (uiWorkspace === void 0) {
3077
+ this.update({ pendingHandoff: card, pendingHandoffSession: void 0 });
3078
+ this.service("layout")?.selectPanel(null);
3079
+ return;
3080
+ }
3081
+ const workspaceId = this.workspaceForHandoff(card.repo);
3082
+ const prompt = this.promptFor(card);
3083
+ void (async () => {
3084
+ try {
3085
+ const sessionId = await uiWorkspace.connectWorkspace(workspaceId);
3086
+ this.update({ pendingHandoff: card, pendingHandoffSession: sessionId });
3087
+ uiWorkspace.startSession(workspaceId, { prompt, whenDraftExists: "replace" });
3088
+ } catch (error) {
3089
+ this.update({ error: asPanelError(error) });
3090
+ }
3091
+ })();
3092
+ }
3093
+ copyPrompt(card) {
3094
+ this.copyText(renderPrompt(card, this.snapshot.prefs.promptTemplate));
3095
+ this.toast("panel.toast.promptCopied");
3096
+ }
3097
+ /** The prompt text this profile hands to the agent for one issue. */
3098
+ promptText(card) {
3099
+ return renderPrompt(card, this.snapshot.prefs.promptTemplate);
3100
+ }
3101
+ copyText(text) {
3102
+ try {
3103
+ void navigator.clipboard?.writeText(text);
3104
+ } catch {
3105
+ }
3106
+ this.toast("panel.toast.copied");
3107
+ }
3108
+ clearToast() {
3109
+ if (this.toastTimer !== void 0) clearTimeout(this.toastTimer);
3110
+ this.toastTimer = void 0;
3111
+ this.update({ toast: void 0 });
3112
+ }
3113
+ /** The issue key used by the link map. */
3114
+ keyOf(repo, number) {
3115
+ return `${repo}#${String(number)}`;
3116
+ }
3117
+ /** Load every recorded link and resolve the linked issues to cards. */
3118
+ async loadLinks() {
3119
+ try {
3120
+ const remote = await this.api();
3121
+ const links = await remote.links().then((result) => unwrap(result));
3122
+ this.update({ links });
3123
+ this.decorateLoadedCards(links);
3124
+ void this.ensureCards(links);
3125
+ } catch {
3126
+ }
3127
+ }
3128
+ /** Fetch the cards of linked issues that are not in the current list yet. */
3129
+ async ensureCards(links) {
3130
+ const missing = /* @__PURE__ */ new Map();
3131
+ for (const link of links) {
3132
+ const key = this.keyOf(link.repo, link.number);
3133
+ if (this.snapshot.linkCards[key] !== void 0) continue;
3134
+ missing.set(key, { repo: link.repo, number: link.number });
3135
+ }
3136
+ if (missing.size === 0) return;
3137
+ const cards = {};
3138
+ for (const [key, target] of missing.entries()) cards[key] = this.cardFor(target.repo, target.number);
3139
+ if (Object.keys(cards).length === 0) return;
3140
+ this.update({ linkCards: { ...this.snapshot.linkCards, ...cards } });
3141
+ }
3142
+ /** Attach resolved session links to every card the snapshot currently holds. */
3143
+ decorateLoadedCards(links) {
3144
+ const byKey = /* @__PURE__ */ new Map();
3145
+ for (const link of links) {
3146
+ const key = this.keyOf(link.repo, link.number);
3147
+ byKey.set(key, [...byKey.get(key) ?? [], link]);
3148
+ }
3149
+ const decorate = (card) => {
3150
+ const records = byKey.get(this.keyOf(card.repo, card.number));
3151
+ if (records === void 0) return card;
3152
+ return {
3153
+ ...card,
3154
+ sessionLinks: records.map((record) => ({ sessionId: record.sessionId, at: record.at }))
3155
+ };
3156
+ };
3157
+ const list = this.snapshot.list;
3158
+ this.update({
3159
+ ...list === void 0 ? {} : {
3160
+ list: { ...list, items: list.items.map((card) => decorate(card)) }
3161
+ },
3162
+ ...this.snapshot.selected === void 0 ? {} : { selected: decorate(this.snapshot.selected) },
3163
+ ...this.snapshot.detail === void 0 ? {} : { detail: decorate(this.snapshot.detail) },
3164
+ ...this.snapshot.pinnedCard === void 0 ? {} : { pinnedCard: decorate(this.snapshot.pinnedCard) }
3165
+ });
3166
+ }
3167
+ /** Record that a session received this issue (send confirmed). */
3168
+ async linkIssue(card, sessionId) {
3169
+ try {
3170
+ const remote = await this.api();
3171
+ const links = await remote.linkIssue(card.repo, card.number, sessionId).then((result) => unwrap(result));
3172
+ this.update({
3173
+ links,
3174
+ linkCards: { ...this.snapshot.linkCards, [this.keyOf(card.repo, card.number)]: card }
3175
+ });
3176
+ this.decorateLoadedCards(links);
3177
+ } catch {
3178
+ }
3179
+ }
3180
+ /** Remove one issue → session link (or every link of the issue). */
3181
+ async unlinkSession(card, sessionId) {
3182
+ try {
3183
+ const remote = await this.api();
3184
+ const links = await remote.unlinkIssue(card.repo, card.number, sessionId).then((result) => unwrap(result));
3185
+ this.update({ links });
3186
+ const without = (target) => {
3187
+ const remaining = (target.sessionLinks ?? []).filter((link) => sessionId === void 0 || link.sessionId !== sessionId);
3188
+ return { ...target, sessionLinks: remaining };
3189
+ };
3190
+ const list = this.snapshot.list;
3191
+ this.update({
3192
+ ...list === void 0 ? {} : { list: { ...list, items: list.items.map((card2) => without(card2)) } },
3193
+ ...this.snapshot.selected === void 0 ? {} : { selected: without(this.snapshot.selected) },
3194
+ ...this.snapshot.detail === void 0 ? {} : { detail: without(this.snapshot.detail) },
3195
+ ...this.snapshot.pinnedCard === void 0 ? {} : { pinnedCard: without(this.snapshot.pinnedCard) }
3196
+ });
3197
+ } catch (error) {
3198
+ this.update({ error: asPanelError(error) });
3199
+ }
3200
+ }
3201
+ /** Read one optional client service without tripping the context proxy. */
3202
+ service(name) {
3203
+ return this.runtime.getService(name);
3204
+ }
3205
+ /** Open (navigate to) one Session. */
3206
+ openSession(sessionId) {
3207
+ this.service("uiWorkspace")?.openSession(sessionId);
3208
+ }
3209
+ /** Open the GitHub panel focused on one issue. */
3210
+ openInPanel(card) {
3211
+ this.update({ selected: card, detail: void 0, detailLoading: true });
3212
+ this.service("layout")?.selectPanel("github");
3213
+ void (async () => {
3214
+ try {
3215
+ const remote = await this.api();
3216
+ const body = await remote.issueDetail(card.repo, card.number).then((result) => unwrap(result));
3217
+ this.update({
3218
+ detail: { ...card, body: body.body, mentionedPRs: [] },
3219
+ detailLoading: false,
3220
+ mentionedLoading: true
3221
+ });
3222
+ const mentioned = await remote.issueMentionedPRs(card.repo, card.number).then((result) => unwrap(result));
3223
+ const current = this.snapshot.detail;
3224
+ if (current === void 0 || current.repo !== card.repo || current.number !== card.number) return;
3225
+ const closing = new Set(current.linkedPRs.map((pr) => pr.number));
3226
+ this.update({
3227
+ detail: { ...current, mentionedPRs: mentioned.mentionedPRs.filter((pr) => !closing.has(pr.number)) },
3228
+ mentionedLoading: false
3229
+ });
3230
+ } catch (error) {
3231
+ this.update({ detailLoading: false, error: asPanelError(error) });
3232
+ }
3233
+ })();
3234
+ }
3235
+ /**
3236
+ * Take the pending handoff when it belongs to this Session.
3237
+ * @param sessionId - the Session whose dock asks; a handoff stamped for a
3238
+ * different Session is left for that one.
3239
+ * @returns the issue to stage, or `undefined`.
3240
+ */
3241
+ consumeHandoff(sessionId) {
3242
+ const card = this.snapshot.pendingHandoff;
3243
+ if (card === void 0) return void 0;
3244
+ const target = this.snapshot.pendingHandoffSession;
3245
+ if (target !== void 0 && sessionId !== void 0 && target !== sessionId) return void 0;
3246
+ this.update({ pendingHandoff: void 0, pendingHandoffSession: void 0 });
3247
+ return card;
3248
+ }
3249
+ /** Render the profile's handoff prompt for one issue. */
3250
+ promptFor(card) {
3251
+ return renderPrompt(card, this.snapshot.prefs.promptTemplate);
3252
+ }
3253
+ /** Insert one issue into the composer, per the configured handoff behavior. */
3254
+ async insertIntoComposer(card, inputActions) {
3255
+ if (inputActions === void 0) return;
3256
+ const text = this.promptFor(card);
3257
+ if (text === "") return;
3258
+ inputActions.setDraft(text);
3259
+ if (this.snapshot.prefs.handoffMode === "send") inputActions.submit();
3260
+ }
3261
+ };
3262
+
3263
+ // src/client/index.tsx
3264
+ var PANEL_ID = "github";
3265
+ var SETTINGS_ID = "github-issues";
3266
+ var SIDEBAR_KIND2 = "github-issues";
3267
+ var inject = ["slots", "locale", "remote"];
3268
+ function apply(ctx) {
3269
+ ctx.effect(() => ctx.locale.register(NS, DICTS), "github-issues: dictionaries");
3270
+ const t = ctx.locale.bind(NS);
3271
+ const mounting = ctx.remote.$mount(remoteContribution()).then(
3272
+ () => void 0,
3273
+ (error) => error instanceof Error ? error.message : String(error)
3274
+ );
3275
+ const runtime = {
3276
+ getService: (name) => ctx.get(name)
3277
+ };
3278
+ const store = new GitHubStore(ctx, runtime, mounting);
3279
+ ctx.effect(() => {
3280
+ store.start();
3281
+ return () => {
3282
+ store.stop();
3283
+ };
3284
+ }, "github-issues: store");
3285
+ ctx.slots.inject("main", () => ctx.slots.register({
3286
+ name: "main",
3287
+ key: PANEL_ID,
3288
+ locale: NS,
3289
+ inject: () => ({ store, t, runtime })
3290
+ }, PageHost));
3291
+ ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
3292
+ name: "sidebar.panellist",
3293
+ id: PANEL_ID,
3294
+ order: 20,
3295
+ locale: NS,
3296
+ label: () => t("panel")
3297
+ }, GitHubRailIcon));
3298
+ ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
3299
+ name: "conversation.composer.dock",
3300
+ id: "github-issues-handoff",
3301
+ order: -10,
3302
+ locale: NS,
3303
+ inject: () => ({ store, t, runtime })
3304
+ }, DockHost));
3305
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
3306
+ name: "settings.section",
3307
+ id: SETTINGS_ID,
3308
+ order: 30,
3309
+ locale: NS,
3310
+ label: () => t("settings.title"),
3311
+ inject: () => ({ store, t })
3312
+ }, SettingsHost));
3313
+ ctx.slots.inject("conversation.input.overlay", () => ctx.slots.register({
3314
+ name: "conversation.input.overlay",
3315
+ id: "github-issues-pending",
3316
+ order: 20,
3317
+ locale: NS,
3318
+ inject: () => ({ store, t })
3319
+ }, PendingOverlayHost));
3320
+ ctx.slots.inject("conversation.input.dock", () => ctx.slots.register({
3321
+ name: "conversation.input.dock",
3322
+ id: "github-issues-drop",
3323
+ order: 25,
3324
+ locale: NS,
3325
+ inject: () => ({ store, t })
3326
+ }, DropZoneHost));
3327
+ ctx.inject(["sidebarRightTabs"], (scoped) => {
3328
+ const tabs = scoped.sidebarRightTabs;
3329
+ scoped.effect(() => tabs.register({
3330
+ id: SIDEBAR_KIND2,
3331
+ kind: SIDEBAR_KIND2,
3332
+ priority: "extension",
3333
+ title: () => t("sidebar.tab"),
3334
+ guide: [{ id: SIDEBAR_KIND2, title: () => t("sidebar.tab"), order: 45 }]
3335
+ }), "github-issues: right-sidebar type");
3336
+ scoped.slots.inject("sidebar.right.pane.tab", () => scoped.slots.register({
3337
+ name: "sidebar.right.pane.tab",
3338
+ key: SIDEBAR_KIND2,
3339
+ locale: NS,
3340
+ inject: () => ({ store, t })
3341
+ }, SidebarHost));
3342
+ });
3343
+ }
3344
+
3345
+ })(module, exports, require);
3346
+ return module.exports;
3347
+ },
3348
+ });