@vibedev-si/dsh-vibedev 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/client.js CHANGED
@@ -5,7 +5,234 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
5
5
  let react = require("react");
6
6
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
+ //#region src/client/feedback-store.ts
9
+ /**
10
+ * The feedback dialog's state and its two Host routes: the text of the
11
+ * optional "recent errors" attachment (`GET /api/dsh-vibedev/feedback/attachment`)
12
+ * and the submission (`POST /api/dsh-vibedev/feedback`).
13
+ *
14
+ * The attachment is sent only when its box is ticked, and then exactly the
15
+ * text the dialog showed. Free of React and the DOM (fetch is injectable), so
16
+ * the whole flow is tested in node.
17
+ */
18
+ /** The categories DeepSeek Harness files feedback under, in its order. */
19
+ const FEEDBACK_CATEGORIES = [
20
+ "task-result",
21
+ "instruction-following",
22
+ "product-interaction",
23
+ "service-stability",
24
+ "resource-cost",
25
+ "security-privacy-permission",
26
+ "other"
27
+ ];
28
+ const FEEDBACK_ROUTE = "/api/dsh-vibedev/feedback";
29
+ const FEEDBACK_ATTACHMENT_ROUTE = "/api/dsh-vibedev/feedback/attachment";
30
+ /** The gateway's limit on the text, in code points. */
31
+ const FEEDBACK_MAX_TEXT = 4e3;
32
+ const INITIAL = {
33
+ open: false,
34
+ category: void 0,
35
+ text: "",
36
+ attach: false,
37
+ preview: { status: "idle" },
38
+ phase: { kind: "editing" }
39
+ };
40
+ /**
41
+ * Text cut to the gateway's limit, counted in code points as the gateway counts it.
42
+ * @param text - the text.
43
+ * @returns at most 4,000 code points.
44
+ */
45
+ function limitText(text) {
46
+ const characters = [...text];
47
+ return characters.length <= 4e3 ? text : characters.slice(0, FEEDBACK_MAX_TEXT).join("");
48
+ }
49
+ /** The text's length in code points. */
50
+ function textLength(text) {
51
+ let count = 0;
52
+ for (const _ of text) count++;
53
+ return count;
54
+ }
55
+ /**
56
+ * Whether the dialog can send: a category or some text, and, with the box ticked, the attachment already shown.
57
+ * @param state - the dialog state.
58
+ * @returns true when something would be sent.
59
+ */
60
+ function canSend(state) {
61
+ return state.phase.kind === "editing" && (state.category !== void 0 || state.text.trim() !== "") && !(state.attach && state.preview.status === "loading");
62
+ }
63
+ /** The feedback dialog's store. */
64
+ var FeedbackStore = class {
65
+ options;
66
+ state = INITIAL;
67
+ listeners = /* @__PURE__ */ new Set();
68
+ /** Bumped by every opening and closing, so an answer for an earlier opening is ignored. */
69
+ generation = 0;
70
+ /**
71
+ * @param options - fetch (a test seam).
72
+ */
73
+ constructor(options = {}) {
74
+ this.options = options;
75
+ }
76
+ subscribe = (listener) => {
77
+ this.listeners.add(listener);
78
+ return () => {
79
+ this.listeners.delete(listener);
80
+ };
81
+ };
82
+ getSnapshot = () => this.state;
83
+ set(change) {
84
+ this.state = {
85
+ ...this.state,
86
+ ...change
87
+ };
88
+ for (const listener of this.listeners) listener();
89
+ }
90
+ fetch(path, init) {
91
+ return (this.options.fetch ?? globalThis.fetch)(path, init);
92
+ }
93
+ /** Open the dialog with an empty form. */
94
+ open() {
95
+ this.generation++;
96
+ this.state = {
97
+ ...INITIAL,
98
+ open: true
99
+ };
100
+ for (const listener of this.listeners) listener();
101
+ }
102
+ /** Close it; whatever was sent or queued carries on without the dialog. */
103
+ close() {
104
+ this.generation++;
105
+ this.state = INITIAL;
106
+ for (const listener of this.listeners) listener();
107
+ }
108
+ /** Choose a category, or none. */
109
+ setCategory(category) {
110
+ if (this.state.phase.kind !== "editing") return;
111
+ this.set({
112
+ category,
113
+ phase: { kind: "editing" }
114
+ });
115
+ }
116
+ /** Change the text (cut to 4,000 code points). */
117
+ setText(text) {
118
+ if (this.state.phase.kind !== "editing") return;
119
+ this.set({
120
+ text: limitText(text),
121
+ phase: { kind: "editing" }
122
+ });
123
+ }
124
+ /**
125
+ * Tick or untick "attach recent errors". Ticking reads the text that would be sent, every time, so what the dialog
126
+ * shows is what goes.
127
+ * @param attach - the box's new state.
128
+ * @returns once the preview (if any) is read.
129
+ */
130
+ async setAttach(attach) {
131
+ if (this.state.phase.kind !== "editing") return;
132
+ if (!attach) {
133
+ this.set({ attach: false });
134
+ return;
135
+ }
136
+ const generation = ++this.generation;
137
+ this.set({
138
+ attach: true,
139
+ preview: { status: "loading" }
140
+ });
141
+ let preview;
142
+ try {
143
+ const response = await this.fetch(FEEDBACK_ATTACHMENT_ROUTE);
144
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
145
+ const body = await response.json();
146
+ if (typeof body.content !== "string" || typeof body.entries !== "number" || typeof body.bytes !== "number") throw new Error("not a preview");
147
+ preview = {
148
+ status: "ready",
149
+ preview: {
150
+ content: body.content,
151
+ entries: body.entries,
152
+ bytes: body.bytes
153
+ }
154
+ };
155
+ } catch {
156
+ preview = { status: "failed" };
157
+ }
158
+ if (generation === this.generation) this.set({ preview });
159
+ }
160
+ /**
161
+ * Send the feedback: the category and text, and the shown attachment only when its box is ticked.
162
+ * @param locale - the language the dialog is in.
163
+ * @returns once the Host answered.
164
+ */
165
+ async submit(locale) {
166
+ const state = this.state;
167
+ if (!canSend(state)) return;
168
+ const generation = ++this.generation;
169
+ const shown = state.attach && state.preview.status === "ready" && state.preview.preview.content !== "" ? state.preview.preview.content : void 0;
170
+ this.set({ phase: { kind: "sending" } });
171
+ let phase;
172
+ try {
173
+ const response = await this.fetch(FEEDBACK_ROUTE, {
174
+ method: "POST",
175
+ headers: { "content-type": "application/json" },
176
+ body: JSON.stringify({
177
+ ...state.category === void 0 ? {} : { category: state.category },
178
+ ...state.text.trim() === "" ? {} : { text: state.text },
179
+ ...shown === void 0 ? {} : { attachment: { content: shown } },
180
+ ...locale === void 0 ? {} : { locale }
181
+ })
182
+ });
183
+ const body = await response.json().catch(() => void 0);
184
+ if (response.status === 409 && body?.error?.code === "SIGNED_OUT") phase = { kind: "signed-out" };
185
+ else if (response.status === 400) phase = {
186
+ kind: "editing",
187
+ error: "invalid"
188
+ };
189
+ else if (!response.ok) phase = {
190
+ kind: "editing",
191
+ error: "failed"
192
+ };
193
+ else if (body?.status === "sent") phase = { kind: "sent" };
194
+ else if (body?.status === "queued") phase = {
195
+ kind: "queued",
196
+ reason: body.reason === "offline" || body.reason === "signed-out" ? body.reason : "later"
197
+ };
198
+ else phase = {
199
+ kind: "editing",
200
+ error: "rejected",
201
+ ...typeof body?.code === "string" ? { code: body.code } : {}
202
+ };
203
+ } catch {
204
+ phase = {
205
+ kind: "editing",
206
+ error: "failed"
207
+ };
208
+ }
209
+ if (generation === this.generation) this.set({ phase });
210
+ }
211
+ };
212
+ //#endregion
8
213
  //#region src/client/account-store.ts
214
+ /**
215
+ * The VibeDev account as the browser half sees it: one store the Settings
216
+ * section and the sidebar status share. It reads the Host route
217
+ * (`GET /api/dsh-vibedev/account`) on start, every 2 s while a sign-in waits
218
+ * for the browser, and whenever the window regains focus. Otherwise it keeps a
219
+ * long poll open (`?since=<revision>`), which the Host answers as soon as the
220
+ * balance or the person changes — a charge shows within seconds; a Host
221
+ * without long polls is read every minute. The actions call the sign-in,
222
+ * cancel and sign-out routes.
223
+ *
224
+ * The balance card (hovering the sidebar row) and the row's menu ask for a
225
+ * fresh balance when the one shown was read more than 10 s ago, and the card
226
+ * measures the network latency to the gateway (`POST /api/dsh-vibedev/latency`)
227
+ * when it opens and the last measurement is more than a minute old, or when
228
+ * asked to; never on a timer. Each of these runs at most once at a time.
229
+ *
230
+ * The account menus' 意见反馈 dialog has its own small store (`feedback`),
231
+ * on the same Host connection.
232
+ *
233
+ * Kept free of React and of the DOM beyond `fetch` and timers (both
234
+ * injectable) so it can be tested in node.
235
+ */
9
236
  const ACCOUNT_ROUTE = "/api/dsh-vibedev/account";
10
237
  const LATENCY_ROUTE = "/api/dsh-vibedev/latency";
11
238
  const PENDING_POLL_MS = 2e3;
@@ -39,11 +266,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
39
266
  unsubscribeFocus;
40
267
  /** The open long poll, when one is. */
41
268
  watching;
269
+ /** The feedback dialog the account menus open, on the same Host connection. */
270
+ feedback;
42
271
  /**
43
272
  * @param options - fetch, timers, window opening, focus and the clock (test seams).
44
273
  */
45
274
  constructor(options = {}) {
46
275
  this.options = options;
276
+ this.feedback = new FeedbackStore(options.fetch === void 0 ? {} : { fetch: options.fetch });
47
277
  }
48
278
  /** The store's clock (epoch ms), which the card's "N 秒前" reads as well. */
49
279
  now = () => (this.options.now ?? Date.now)();
@@ -607,7 +837,40 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
607
837
  latencyUnreachable: "无法连接",
608
838
  latencyTimeout: "超时",
609
839
  latencyNetwork: "网络错误",
610
- latencyHttp: "HTTP {status}"
840
+ latencyHttp: "HTTP {status}",
841
+ localeTag: "zh-CN",
842
+ close: "关闭",
843
+ feedbackMenu: "意见反馈",
844
+ feedbackTitle: "意见反馈",
845
+ feedbackIntro: "告诉我们哪里好用、哪里需要改进。反馈会随你的 VibeDev 账号发送给 VibeDev 团队。",
846
+ feedbackCategories: "反馈分类",
847
+ categoryTaskResult: "任务结果",
848
+ categoryInstructionFollowing: "指令理解与遵循",
849
+ categoryProductInteraction: "产品功能与交互",
850
+ categoryServiceStability: "稳定性和速度",
851
+ categoryResourceCost: "资源使用与费用",
852
+ categorySecurityPrivacyPermission: "安全隐私与权限",
853
+ categoryOther: "其他",
854
+ feedbackDetail: "反馈详情",
855
+ feedbackPlaceholder: "遇到了什么问题,或者有什么建议?",
856
+ feedbackCount: "{n} / {max}",
857
+ feedbackAttach: "附上最近的报错信息(可能包含文件路径或代码片段)",
858
+ feedbackAttachLoading: "正在读取报错信息…",
859
+ feedbackAttachPreview: "将附上以下内容({entries} 条,{size}):",
860
+ feedbackAttachEmpty: "最近没有报错,不会附带内容。",
861
+ feedbackAttachFailed: "没能读取报错信息,这次不会附带。",
862
+ feedbackSend: "发送",
863
+ feedbackSending: "正在发送…",
864
+ feedbackCancel: "取消",
865
+ feedbackDone: "完成",
866
+ feedbackSent: "已发送,谢谢!",
867
+ feedbackQueuedOffline: "已保存,联网后会自动发送",
868
+ feedbackQueuedLater: "已保存,稍后会自动发送",
869
+ feedbackQueuedSignedOut: "已保存,登录 VibeDev 后会自动发送",
870
+ feedbackErrorFailed: "没能发送,请检查网络后重试。",
871
+ feedbackErrorInvalid: "内容不符合要求,请修改后重试。",
872
+ feedbackErrorRejected: "VibeDev 没有接受这条反馈({code})。",
873
+ feedbackSignedOut: "意见反馈会随你的 VibeDev 账号发送,不会匿名提交。请先登录 VibeDev。"
611
874
  };
612
875
  const en = {
613
876
  spending: "Spending",
@@ -712,7 +975,40 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
712
975
  latencyUnreachable: "Unreachable",
713
976
  latencyTimeout: "timed out",
714
977
  latencyNetwork: "network error",
715
- latencyHttp: "HTTP {status}"
978
+ latencyHttp: "HTTP {status}",
979
+ localeTag: "en",
980
+ close: "Close",
981
+ feedbackMenu: "Feedback",
982
+ feedbackTitle: "Feedback",
983
+ feedbackIntro: "Tell us what works and what needs improving. Feedback is sent to the VibeDev team with your VibeDev account.",
984
+ feedbackCategories: "Category",
985
+ categoryTaskResult: "Task result",
986
+ categoryInstructionFollowing: "Instruction understanding and following",
987
+ categoryProductInteraction: "Product features and interaction",
988
+ categoryServiceStability: "Stability and speed",
989
+ categoryResourceCost: "Resource usage and cost",
990
+ categorySecurityPrivacyPermission: "Security, privacy, and permissions",
991
+ categoryOther: "Other",
992
+ feedbackDetail: "Feedback details",
993
+ feedbackPlaceholder: "What went wrong, or what would you like to see?",
994
+ feedbackCount: "{n} / {max}",
995
+ feedbackAttach: "Attach recent error messages (may include file paths or code snippets)",
996
+ feedbackAttachLoading: "Reading the error messages…",
997
+ feedbackAttachPreview: "This will be attached ({entries} entries, {size}):",
998
+ feedbackAttachEmpty: "No recent errors; nothing will be attached.",
999
+ feedbackAttachFailed: "Could not read the error messages; nothing will be attached.",
1000
+ feedbackSend: "Send",
1001
+ feedbackSending: "Sending…",
1002
+ feedbackCancel: "Cancel",
1003
+ feedbackDone: "Done",
1004
+ feedbackSent: "Sent. Thank you!",
1005
+ feedbackQueuedOffline: "Saved; it will be sent automatically once you are online",
1006
+ feedbackQueuedLater: "Saved; it will be sent automatically later",
1007
+ feedbackQueuedSignedOut: "Saved; it will be sent once you sign in to VibeDev",
1008
+ feedbackErrorFailed: "Could not send it. Check your connection and try again.",
1009
+ feedbackErrorInvalid: "The feedback was not accepted as written. Edit it and try again.",
1010
+ feedbackErrorRejected: "VibeDev did not accept this feedback ({code}).",
1011
+ feedbackSignedOut: "Feedback is sent with your VibeDev account, never anonymously. Sign in to VibeDev first."
716
1012
  };
717
1013
  /**
718
1014
  * Fill `{name}` placeholders.
@@ -1591,6 +1887,286 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1591
1887
  });
1592
1888
  }
1593
1889
  //#endregion
1890
+ //#region src/client/FeedbackDialog.tsx
1891
+ /**
1892
+ * The account menus' 意见反馈 dialog: a category, the text (at most 4,000
1893
+ * characters, counted), and an unticked box that attaches recent error
1894
+ * messages — ticking it shows the exact text that would be sent, and its size,
1895
+ * before anything is sent. Then 已发送,谢谢! when VibeDev took it, 已保存…
1896
+ * when it was kept to send later, or what went wrong. Signed out it explains
1897
+ * that feedback goes with the VibeDev account and offers the sign-in: nothing
1898
+ * is ever sent anonymously.
1899
+ *
1900
+ * DSH primitives (Modal, Button, Checkbox, StateDot) and theme tokens; the
1901
+ * chips and the text field follow DSH's own message-feedback dialog, styled by
1902
+ * a small stylesheet this component inserts once (inline styles cannot carry
1903
+ * hover and focus states).
1904
+ */
1905
+ const CATEGORY_KEYS = {
1906
+ "task-result": "categoryTaskResult",
1907
+ "instruction-following": "categoryInstructionFollowing",
1908
+ "product-interaction": "categoryProductInteraction",
1909
+ "service-stability": "categoryServiceStability",
1910
+ "resource-cost": "categoryResourceCost",
1911
+ "security-privacy-permission": "categorySecurityPrivacyPermission",
1912
+ "other": "categoryOther"
1913
+ };
1914
+ const PREFIX = "dsh-vibedev-fb";
1915
+ /** The dialog's rules: DSH's message-feedback dialog geometry, its chips and text field, on theme tokens only. */
1916
+ const FEEDBACK_STYLES = `
1917
+ .${PREFIX}-dialog.${PREFIX}-dialog { width: min(488px, 100%); }
1918
+ .${PREFIX}-body { display: flex; flex-direction: column; gap: 14px; }
1919
+ .${PREFIX}-chips { display: flex; flex-wrap: wrap; gap: 8px; }
1920
+ .${PREFIX}-chip { height: 28px; padding: 0 12px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-sm);
1921
+ background: transparent; color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 18px; cursor: pointer;
1922
+ transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
1923
+ .${PREFIX}-chip:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
1924
+ .${PREFIX}-chip[aria-pressed='true'], .${PREFIX}-chip[aria-pressed='true']:hover:not(:disabled) {
1925
+ border-color: var(--dsw-alias-button-primary-fill); background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
1926
+ .${PREFIX}-chip:disabled { cursor: default; opacity: 0.4; }
1927
+ .${PREFIX}-chip:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 2px; }
1928
+ .${PREFIX}-field { display: flex; flex-direction: column; gap: 4px; }
1929
+ .${PREFIX}-text { display: block; width: 100%; min-height: 116px; max-height: 240px; box-sizing: border-box; padding: 12px 14px;
1930
+ border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-1);
1931
+ color: var(--dsw-alias-label-primary); font: inherit; font-size: 14px; line-height: 22px; field-sizing: content; resize: none;
1932
+ transition: border-color 120ms ease, box-shadow 120ms ease; }
1933
+ .${PREFIX}-text::placeholder { color: var(--dsw-alias-label-caption); }
1934
+ .${PREFIX}-text:focus { outline: none; border-color: var(--dsw-alias-border-l3); box-shadow: 0 0 0 1px var(--dsw-alias-state-business-primary); }
1935
+ .${PREFIX}-count { align-self: flex-end; font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }
1936
+ .${PREFIX}-note { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }
1937
+ .${PREFIX}-preview { margin: 0; max-height: 156px; overflow: auto; padding: 10px 12px; border-radius: var(--dsw-radius-md);
1938
+ background: var(--dsw-alias-bg-skeleton); color: var(--dsw-alias-label-secondary); font-family: var(--ds-font-family-code);
1939
+ font-size: 11px; line-height: 17px; white-space: pre-wrap; word-break: break-all; }
1940
+ .${PREFIX}-error { margin: 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-state-error-primary); }
1941
+ .${PREFIX}-result { display: flex; align-items: center; gap: 10px; padding: 8px 0 4px; font-size: 15px; line-height: 22px; color: var(--dsw-alias-label-primary); }
1942
+ .${PREFIX}-prompt { margin: 0; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }
1943
+ @media (prefers-reduced-motion: reduce) { .${PREFIX}-chip, .${PREFIX}-text { transition: none; } }
1944
+ `;
1945
+ let styleUsers = 0;
1946
+ let styleElement;
1947
+ /** Insert the stylesheet while any dialog is mounted. */
1948
+ function useFeedbackStyles() {
1949
+ (0, react.useInsertionEffect)(() => {
1950
+ if (styleUsers++ === 0) {
1951
+ styleElement = document.createElement("style");
1952
+ styleElement.dataset.dshVibedevFeedback = "";
1953
+ styleElement.textContent = FEEDBACK_STYLES;
1954
+ document.head.appendChild(styleElement);
1955
+ }
1956
+ return () => {
1957
+ if (--styleUsers === 0) {
1958
+ styleElement?.remove();
1959
+ styleElement = void 0;
1960
+ }
1961
+ };
1962
+ }, []);
1963
+ }
1964
+ /**
1965
+ * A size for people: bytes, else kilobytes with one decimal.
1966
+ * @param bytes - the size.
1967
+ * @returns e.g. `512 B`, `3.4 KB`.
1968
+ */
1969
+ function sizeText(bytes) {
1970
+ return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
1971
+ }
1972
+ /** The line under the form for a failed attempt. */
1973
+ function errorText(t, phase) {
1974
+ if (phase.error === "failed") return t("feedbackErrorFailed");
1975
+ if (phase.error === "invalid") return t("feedbackErrorInvalid");
1976
+ if (phase.error === "rejected") return fill(t("feedbackErrorRejected"), { code: phase.code ?? "—" });
1977
+ }
1978
+ /**
1979
+ * The body and footer for the current state.
1980
+ * @param props - the dictionary, the state and the actions.
1981
+ * @returns the dialog's children and footer.
1982
+ */
1983
+ function feedbackView(props) {
1984
+ const { t, state } = props;
1985
+ const phase = state.phase;
1986
+ if (!props.signedIn || phase.kind === "signed-out") return {
1987
+ body: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1988
+ className: `${PREFIX}-prompt`,
1989
+ role: "status",
1990
+ children: t("feedbackSignedOut")
1991
+ }),
1992
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1993
+ variant: "ghost",
1994
+ onClick: props.onClose,
1995
+ children: t("feedbackCancel")
1996
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1997
+ variant: "primary",
1998
+ disabled: props.signingIn,
1999
+ onClick: props.onSignIn,
2000
+ children: props.signingIn ? t("signingIn") : t("signIn")
2001
+ })] })
2002
+ };
2003
+ if (phase.kind === "sent" || phase.kind === "queued") {
2004
+ const text = phase.kind === "sent" ? t("feedbackSent") : phase.reason === "offline" ? t("feedbackQueuedOffline") : phase.reason === "signed-out" ? t("feedbackQueuedSignedOut") : t("feedbackQueuedLater");
2005
+ return {
2006
+ body: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2007
+ className: `${PREFIX}-result`,
2008
+ role: "status",
2009
+ "data-feedback-result": phase.kind,
2010
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
2011
+ state: phase.kind === "sent" ? "done" : "warning",
2012
+ size: 12
2013
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: text })]
2014
+ }),
2015
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2016
+ variant: "primary",
2017
+ onClick: props.onClose,
2018
+ children: t("feedbackDone")
2019
+ })
2020
+ };
2021
+ }
2022
+ const sending = phase.kind === "sending";
2023
+ const error = phase.kind === "editing" ? errorText(t, phase) : void 0;
2024
+ const preview = state.preview;
2025
+ let attachment = null;
2026
+ if (state.attach) {
2027
+ if (preview.status === "loading" || preview.status === "idle") attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2028
+ className: `${PREFIX}-note`,
2029
+ children: t("feedbackAttachLoading")
2030
+ });
2031
+ else if (preview.status === "failed") attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2032
+ className: `${PREFIX}-note`,
2033
+ children: t("feedbackAttachFailed")
2034
+ });
2035
+ else if (preview.preview.entries === 0 || preview.preview.content === "") attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2036
+ className: `${PREFIX}-note`,
2037
+ children: t("feedbackAttachEmpty")
2038
+ });
2039
+ else attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2040
+ className: `${PREFIX}-note`,
2041
+ children: fill(t("feedbackAttachPreview"), {
2042
+ entries: preview.preview.entries,
2043
+ size: sizeText(preview.preview.bytes)
2044
+ })
2045
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
2046
+ className: `${PREFIX}-preview`,
2047
+ "data-feedback-attachment": true,
2048
+ tabIndex: 0,
2049
+ children: preview.preview.content
2050
+ })] });
2051
+ }
2052
+ return {
2053
+ body: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2054
+ className: `${PREFIX}-body`,
2055
+ children: [
2056
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2057
+ className: `${PREFIX}-chips`,
2058
+ role: "group",
2059
+ "aria-label": t("feedbackCategories"),
2060
+ children: FEEDBACK_CATEGORIES.map((category) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2061
+ type: "button",
2062
+ className: `${PREFIX}-chip`,
2063
+ "aria-pressed": state.category === category,
2064
+ disabled: sending,
2065
+ onClick: () => {
2066
+ props.onCategory(state.category === category ? void 0 : category);
2067
+ },
2068
+ children: t(CATEGORY_KEYS[category])
2069
+ }, category))
2070
+ }),
2071
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2072
+ className: `${PREFIX}-field`,
2073
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
2074
+ className: `${PREFIX}-text`,
2075
+ "data-modal-autofocus": true,
2076
+ "aria-label": t("feedbackDetail"),
2077
+ placeholder: t("feedbackPlaceholder"),
2078
+ value: state.text,
2079
+ readOnly: sending,
2080
+ onChange: (event) => {
2081
+ props.onText(event.target.value);
2082
+ }
2083
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2084
+ className: `${PREFIX}-count`,
2085
+ "aria-live": "polite",
2086
+ children: fill(t("feedbackCount"), {
2087
+ n: textLength(state.text),
2088
+ max: FEEDBACK_MAX_TEXT
2089
+ })
2090
+ })]
2091
+ }),
2092
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2093
+ checked: state.attach,
2094
+ disabled: sending,
2095
+ label: t("feedbackAttach"),
2096
+ onChange: (next) => {
2097
+ props.onAttach(next);
2098
+ }
2099
+ }),
2100
+ attachment,
2101
+ error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2102
+ className: `${PREFIX}-error`,
2103
+ role: "alert",
2104
+ children: error
2105
+ })
2106
+ ]
2107
+ }),
2108
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2109
+ variant: "ghost",
2110
+ disabled: sending,
2111
+ onClick: props.onClose,
2112
+ children: t("feedbackCancel")
2113
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2114
+ variant: "primary",
2115
+ disabled: !canSend(state),
2116
+ onClick: props.onSubmit,
2117
+ "data-feedback-send": true,
2118
+ children: sending ? t("feedbackSending") : t("feedbackSend")
2119
+ })] })
2120
+ };
2121
+ }
2122
+ /**
2123
+ * The dialog, open while the account store's feedback dialog is.
2124
+ * @param props - the dictionary and the shared account store.
2125
+ * @returns the Modal (portaled to the page body), or nothing while closed.
2126
+ */
2127
+ function FeedbackDialog({ t, store }) {
2128
+ useFeedbackStyles();
2129
+ const account = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
2130
+ const state = (0, react.useSyncExternalStore)(store.feedback.subscribe, store.feedback.getSnapshot, store.feedback.getSnapshot);
2131
+ const view = account.view;
2132
+ const signedIn = view !== void 0 && view.source !== "none";
2133
+ const close = () => {
2134
+ store.feedback.close();
2135
+ };
2136
+ const { body, footer } = feedbackView({
2137
+ t,
2138
+ state,
2139
+ signedIn,
2140
+ signingIn: account.busy === "sign-in" || view?.pending !== void 0,
2141
+ onCategory: (category) => {
2142
+ store.feedback.setCategory(category);
2143
+ },
2144
+ onText: (text) => {
2145
+ store.feedback.setText(text);
2146
+ },
2147
+ onAttach: (attach) => {
2148
+ store.feedback.setAttach(attach);
2149
+ },
2150
+ onSubmit: () => {
2151
+ store.feedback.submit(t("localeTag"));
2152
+ },
2153
+ onSignIn: () => {
2154
+ store.signIn();
2155
+ },
2156
+ onClose: close
2157
+ });
2158
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
2159
+ open: state.open,
2160
+ title: t("feedbackTitle"),
2161
+ closeLabel: t("close"),
2162
+ ...signedIn && (state.phase.kind === "editing" || state.phase.kind === "sending") ? { description: t("feedbackIntro") } : {},
2163
+ className: `${PREFIX}-dialog`,
2164
+ onClose: close,
2165
+ footer,
2166
+ children: body
2167
+ });
2168
+ }
2169
+ //#endregion
1594
2170
  //#region src/client/PrimaryLauncher.tsx
1595
2171
  /**
1596
2172
  * The VibeDev account as the app's main account (`settings.launcher`, the row
@@ -1684,6 +2260,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1684
2260
  */
1685
2261
  function PrimaryLauncher({ t, store, owner }) {
1686
2262
  const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
2263
+ const feedbackOpen = (0, react.useSyncExternalStore)(store.feedback.subscribe, () => store.feedback.getSnapshot().open, () => store.feedback.getSnapshot().open);
1687
2264
  const [open, setOpen] = (0, react.useState)(false);
1688
2265
  const wide = owner.wide !== false;
1689
2266
  const settingsWasOpen = (0, react.useRef)(false);
@@ -1728,6 +2305,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1728
2305
  id: "usage",
1729
2306
  label: t("usage")
1730
2307
  },
2308
+ {
2309
+ id: "feedback",
2310
+ label: t("feedbackMenu")
2311
+ },
1731
2312
  ...view.source === "plugin" ? [{
1732
2313
  type: "separator",
1733
2314
  id: "separator-sign-out"
@@ -1777,6 +2358,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1777
2358
  type: "separator",
1778
2359
  id: "separator-settings"
1779
2360
  },
2361
+ {
2362
+ id: "feedback",
2363
+ label: t("feedbackMenu")
2364
+ },
1780
2365
  settings
1781
2366
  ];
1782
2367
  const face = signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -1828,29 +2413,33 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1828
2413
  else if (id === "sign-out") store.signOut();
1829
2414
  else if (id === "cancel") store.cancel();
1830
2415
  else if (id === "open-pending") store.openPending();
2416
+ else if (id === "feedback") store.feedback.open();
1831
2417
  else if (view === void 0) return;
1832
2418
  else if (id === "top-up") store.openLink(view.links.topUp);
1833
2419
  else if (id === "usage") store.openLink(view.links.usage);
1834
2420
  else if (id === "register") store.openLink(view.links.register);
1835
2421
  }
1836
2422
  });
1837
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceHover, {
2423
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceHover, {
1838
2424
  t,
1839
2425
  store,
1840
- disabled: open || !signedIn,
2426
+ disabled: open || !signedIn || feedbackOpen,
1841
2427
  who: wide ? void 0 : title,
1842
2428
  children: menu
1843
- });
2429
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackDialog, {
2430
+ t,
2431
+ store
2432
+ })] });
1844
2433
  }
1845
2434
  //#endregion
1846
2435
  //#region src/client/SidebarAccount.tsx
1847
2436
  /**
1848
2437
  * The sidebar foot's VibeDev status (`sidebar.footer.action`): "登录 VibeDev",
1849
- * "正在登录 VibeDev…" or "VibeDev 已登录", with a menu for the account, and,
1850
- * signed in, the balance card (BalanceCard.tsx) when the pointer rests on it.
1851
- * The Harness's own account entry (the DeepSeek account) stays where it is; in
1852
- * the VibeDev app, whose account entry already is the VibeDev account, this
1853
- * shows nothing.
2438
+ * "正在登录 VibeDev…" or "VibeDev 已登录", with a menu for the account (and its
2439
+ * 意见反馈 dialog), and, signed in, the balance card (BalanceCard.tsx) when the
2440
+ * pointer rests on it. The Harness's own account entry (the DeepSeek account)
2441
+ * stays where it is; in the VibeDev app, whose account entry already is the
2442
+ * VibeDev account, this shows nothing.
1854
2443
  */
1855
2444
  const trigger = {
1856
2445
  display: "flex",
@@ -1887,6 +2476,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1887
2476
  */
1888
2477
  function SidebarAccount({ t, store, wide }) {
1889
2478
  const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
2479
+ const feedbackOpen = (0, react.useSyncExternalStore)(store.feedback.subscribe, () => store.feedback.getSnapshot().open, () => store.feedback.getSnapshot().open);
1890
2480
  const [open, setOpen] = (0, react.useState)(false);
1891
2481
  const view = state.view;
1892
2482
  if (view === void 0 || view.source === "host") return null;
@@ -1918,6 +2508,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1918
2508
  id: "usage",
1919
2509
  label: t("usage")
1920
2510
  },
2511
+ {
2512
+ id: "feedback",
2513
+ label: t("feedbackMenu")
2514
+ },
1921
2515
  ...view.source === "plugin" ? [{
1922
2516
  id: "sign-out",
1923
2517
  label: t("signOut"),
@@ -1953,6 +2547,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1953
2547
  {
1954
2548
  id: "register",
1955
2549
  label: `${t("registerHint")} ${t("registerLink")}`
2550
+ },
2551
+ {
2552
+ type: "separator",
2553
+ id: "separator"
2554
+ },
2555
+ {
2556
+ id: "feedback",
2557
+ label: t("feedbackMenu")
1956
2558
  }
1957
2559
  ];
1958
2560
  const menu = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
@@ -1991,18 +2593,22 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
1991
2593
  else if (id === "sign-out") store.signOut();
1992
2594
  else if (id === "cancel") store.cancel();
1993
2595
  else if (id === "open-pending") store.openPending();
2596
+ else if (id === "feedback") store.feedback.open();
1994
2597
  else if (id === "top-up") store.openLink(view.links.topUp);
1995
2598
  else if (id === "usage") store.openLink(view.links.usage);
1996
2599
  else if (id === "register") store.openLink(view.links.register);
1997
2600
  }
1998
2601
  });
1999
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceHover, {
2602
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceHover, {
2000
2603
  t,
2001
2604
  store,
2002
- disabled: open || !signedIn,
2605
+ disabled: open || !signedIn || feedbackOpen,
2003
2606
  who: wide ? void 0 : who === void 0 ? text : fill(t("signedInAs"), { who }),
2004
2607
  children: menu
2005
- });
2608
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackDialog, {
2609
+ t,
2610
+ store
2611
+ })] });
2006
2612
  }
2007
2613
  //#endregion
2008
2614
  //#region src/client/index.ts