dsh-deepseek-chat 0.1.9 → 0.1.11

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  CHAT模式 加载真实的 [DeepSeek Chat 官网](https://chat.deepseek.com/),使用官网的聊天功能和账号历史;HARNESS模式 为原 DSH 工作区。
6
6
 
7
- 当前版本 **0.1.9** · 适配 **DSH 0.2.0-rc.2 桌面版** · 默认语言为简体中文。
7
+ 当前版本 **0.1.11** · 适配 **DSH 0.2.0-rc.2 桌面版** · 默认语言为简体中文。
8
8
 
9
9
  ## 功能预览
10
10
 
@@ -76,7 +76,7 @@ dsh plugin --profile desktop add https://github.com/xingxingbk-git/dsh-deepseek-
76
76
  将构建生成的 `.tgz` 文件交给 DSH 官方插件管理器安装,或使用 CLI:
77
77
 
78
78
  ```bash
79
- dsh plugin --profile desktop add /absolute/path/dsh-deepseek-chat-0.1.9.tgz
79
+ dsh plugin --profile desktop add /absolute/path/dsh-deepseek-chat-0.1.11.tgz
80
80
  ```
81
81
 
82
82
  将路径替换成你的实际安装包;使用其他 profile 时替换 `desktop`。**安装或更新后,完整退出并重新打开 DSH**,让新插件生效。
@@ -88,7 +88,7 @@ dsh plugin --profile desktop add /absolute/path/dsh-deepseek-chat-0.1.9.tgz
88
88
  ## 开始使用
89
89
 
90
90
  1. 选择 **CHAT**。未登录时点击 **登录 DeepSeek**;也可在 **设置 → CHAT设置** 点击同一个登录入口。
91
- 2. 在插件内的真实官网页面正常登录。两个入口使用同一网页,登录后自动同步账号和对话,不需要重新打开设置刷新。
91
+ 2. 登录统一在 CHAT 主页面的真实官网中完成。CHAT 设置只显示账号、登录状态和语言;点击其中的登录按钮会关闭设置并进入 CHAT,登录后自动同步,无需刷新。
92
92
  3. 打开 **设置 → CHAT设置**,确认出现“已记住网页登录”,按需选择语言。退出登录会清除本插件的登录记忆并正常退出官网;模式切换器继续可用。
93
93
 
94
94
  当前登录在插件网页中完成。外部浏览器登录后自动授权回跳需要官网提供面向 Chat 的授权交换接口,目前未确认可用;直接在其他浏览器登录不会自动登录本插件。
@@ -98,7 +98,7 @@ dsh plugin --profile desktop add /absolute/path/dsh-deepseek-chat-0.1.9.tgz
98
98
  ## 使用限制
99
99
 
100
100
  - **兼容范围:**目前针对 DSH 0.2.0-rc.2 桌面版适配,其他版本和平台待验证;DSH Web版暂不支持本插件的 CHAT 模式。
101
- - **官网导航:**左侧列表依赖官网页面结构,只镜像已加载的导航,不是官方历史 API。结构不匹配时恢复官网原导航并提示。
101
+ - **官网导航:**左侧列表依赖官网页面结构,只镜像已加载的导航,不是官方历史 API。结构不匹配时恢复官网原导航并自动重新识别;恢复后同步左侧列表和 CHAT设置。
102
102
  - **新建快捷键:**本版适配顶部“新会话”的鼠标/Enter 点击;原 Harness 快捷键和菜单仍执行 Harness 行为,可能创建 Harness 会话并退出 CHAT。
103
103
  - **登录记忆:**不共享 Safari/Chrome 登录,独立于 DSH 平台账号。授权过期、撤销或官网实现变化时需要重新登录;新版独立登录、退出重登、完整卸载和其他平台仍需扩大实机验证。
104
104
  - **网页状态:**手动模式切换保留网页;插件停用、卸载或 DSH 完全退出会销毁容器,插件不备份未发送草稿,也不能代替官网停止生成。
@@ -123,7 +123,7 @@ pnpm install --frozen-lockfile
123
123
  pnpm package:plugin
124
124
  ```
125
125
 
126
- 生成 `artifacts/dsh-deepseek-chat-0.1.9.tgz`,包含 Host、Client、类型声明、图标和 bundle patch。插件管理列表的图标位于 `assets/icon.svg`,替换后重新打包安装即可;SVG 须自包含且不超过 256 KiB。
126
+ 生成 `artifacts/dsh-deepseek-chat-0.1.11.tgz`,包含 Host、Client、类型声明、图标和 bundle patch。插件管理列表的图标位于 `assets/icon.svg`,替换后重新打包安装即可;SVG 须自包含且不超过 256 KiB。
127
127
 
128
128
  修改源码后执行 `pnpm release:prepare`,并将源码与整个 `lib/` 一起提交。`pnpm check:distribution` 会检查编译产物与源码、版本及安装入口是否一致;旧产物或缺失文件会使检查失败。安装用户不需要执行这些开发命令。
129
129
 
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "format": 1,
3
3
  "name": "dsh-deepseek-chat",
4
- "version": "0.1.9",
4
+ "version": "0.1.11",
5
5
  "inputs": {
6
6
  "assets/icon.svg": "ad1b0fda90c1c1f2a0b9208bc86f5fe8c21d505a1208576be4e3110b26b4f79c",
7
7
  "cordis.patch.yml": "05edb71cd276de1251ae67644ec68b54efc26258814956fa0e932d36da741bdc",
8
- "package.json": "3f920d646887ad948f748740e5be0686dd3911fd38c481b3a80fc88e4b314f74",
8
+ "package.json": "a89d7b4f4b2dd1a2068e1e716644af0ae96df7a1d6a63e6676fa0a8b63d2e279",
9
9
  "pnpm-lock.yaml": "c4f600b0d599b85f6181d295cd5f9f06f1eb0435eeeb2e7cf1a376b3c6a4ca15",
10
10
  "scripts/build.mjs": "a9a2961e09fb16b99e206c4d191c9e970a4a3999979df9a626fa310c0fdee5b1",
11
11
  "scripts/check-artifact.mjs": "6fec38fb74e41dfeacef7147280c69854087d0665747d7d65137cc98f9dc673b",
@@ -13,17 +13,17 @@
13
13
  "scripts/client-contract.mjs": "1e212575218fc985f4405e2eac98b33a969494ff6b2144b1204a6d66963ba894",
14
14
  "scripts/distribution-manifest.mjs": "e746c447b03b0e9a86efce7827bbd5d9184c6ccd1f1f0f1c9eb12abfe1b2f3b7",
15
15
  "src/authorization.ts": "5f0c1b69e43541ce606349047788df72e442e9cbb3267c8c0caf2c0f556a5589",
16
- "src/client.ts": "5295e47fcd2f786de5a262b072fd7742bf927a1c5261a33e4c506eda20e247a9",
16
+ "src/client.ts": "6800337488d5f811dd29c226f3122719469ae9412418e54cc9e2b7cd5e16a2d2",
17
17
  "src/core/mode.ts": "2fe56c319706d86746010bd5551f4ee47e31e12a0ee28effffb719b0696ad70c",
18
18
  "src/index.ts": "59edf0d6af2feec3e08da322cabc07a2dc83868312c4daa1074b2a5b12892f57",
19
19
  "src/protocol.ts": "5194007a0c06f7b293cc34579ccdc150c23c35b825091667f37a7293594bd29f",
20
20
  "src/server.ts": "295c52235fa399967a594b76b1f4c869adccc978ee3c0f3f8f3a12894b81ef9b",
21
21
  "src/sidebar-adapter.ts": "edcc051bbcaabb2d09055b231f57253a50a6d9e75acf18adafbf262001b18a48",
22
- "src/styles.ts": "64a477da5da605f424df58d96bf953f6c5fe0d52eec7dc9d8574495c9792ac74",
23
- "src/ui.tsx": "c39b1804477fca1369501a603aaf6fbf6dd0a4832cc001c707b9b51ca8f9082f",
24
- "src/web-surface.tsx": "12a466b05e8419c3c69585d77cb5aab12e3cb3794df157aaf7fffeef7fbe9ee1",
22
+ "src/styles.ts": "f3088f1142cf2b9521f14dc73ee9e33f079bfe48230c58787dbf0a3c81014700",
23
+ "src/ui.tsx": "cc35c70c0aa003012aee067470fd380928e87baaa8bb72e4255b96c17998f64a",
24
+ "src/web-surface.tsx": "3e2487fa6d99762d59e7f94ac738384c811c1a3b0cfeb4e35a8230aba81a5468",
25
25
  "src/website-header.ts": "ac4972a28a5f0968de4d5f98d54fbac853f901c7eda00c0849984a2e66f291f3",
26
- "src/website-navigation.ts": "aee412c82cf8af204dbd719e4411166777d497b32746d6c9674d15aa82faf30f",
26
+ "src/website-navigation.ts": "743a6599af09c200b9bbe16dcdc10adf5007374b9982036f5b9e602f36b620c7",
27
27
  "src/website-notice.ts": "65c781bec41e6c2e541d9512cc0051864d64fc3204b3ba5f2e005bdc955f39c9",
28
28
  "src/website-session-store.ts": "8ef6d49465e0034f12b763a666b4a90c8c9819fb8baea06dcaba340fd97d72f1",
29
29
  "src/website-session.ts": "f2434fafc40adb15b5f16fc8b6152bd8df7e85f5210330a1337502c9a08136d8",
@@ -31,7 +31,7 @@
31
31
  "tsconfig.json": "1ad0b3b39537564a180dc7f4084ceb3098b567f509320c77d71bc37aaf4f1879"
32
32
  },
33
33
  "artifacts": {
34
- "lib/client.js": "6da7d7cef93b263bdc86496fcdb87c151f99c78a3c5f28555c20ec9cc118f02b",
34
+ "lib/client.js": "00c9df0385a2b53eb7aa16f2d2ebd167710f533346ceb8beab096ebe63cf88d4",
35
35
  "lib/index.js": "e9c50cc544f24c60d086538ab1283ae0ed2811f23c9bb469916a2e89c3ffb38d",
36
36
  "lib/types/authorization.d.ts": "130649eed3635e75c3f50c13de93c52440a27f1b88136ab2297552570c013d49",
37
37
  "lib/types/client.d.ts": "a79702d5d86c75e81f1e954b3e9f4a562a6b3082d68d798d6a1b37bd41b908a7",
@@ -41,7 +41,7 @@
41
41
  "lib/types/server.d.ts": "62b23f8f9fe9bb16a20274929876c1a34b3ab1e94179567e2e3a56cd67638288",
42
42
  "lib/types/sidebar-adapter.d.ts": "9296987e7ecbd76e42d75bbf65d06f3e368dc036501baf931d7eaa9fb923252d",
43
43
  "lib/types/styles.d.ts": "305836b3ce5cb256ffb033038b7df2919759976f3ca29395a7cd41bbd5811536",
44
- "lib/types/ui.d.ts": "ecd307b91dec65724fe331081c00c6aea5e286051a9f79cda0f9ab476398d8f4",
44
+ "lib/types/ui.d.ts": "5e42f24c522d2bef8758279167a289e0205b30e40e7504ed9bc4e4f527c08c42",
45
45
  "lib/types/web-surface.d.ts": "71686d72b4a5d6c619ee4ec916bbf7b853a87a7cc4d506fbfd0359191434984f",
46
46
  "lib/types/website-header.d.ts": "6379a35e7d35af3fb969802ee2cae969a104dbad937f7b9e371463a0bd7dea9d",
47
47
  "lib/types/website-navigation.d.ts": "6ffd226ded2fc9971bf982e41ee8d8b15d89d113943bbd7cea18f9d4c1ccc973",
package/lib/client.js CHANGED
@@ -14747,9 +14747,9 @@ window.__ModuleLoader__.load({
14747
14747
  var chatStyles = String.raw`
14748
14748
  .dsh-chat-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
14749
14749
  .dsh-chat-navigation,.dsh-chat-brand-control,.dsh-chat-brand-name,.dsh-chat-main-anchor,.dsh-chat-web-surface{font-family:var(--dsw-font-family,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif);color:var(--dsw-alias-label-primary,#22242a);box-sizing:border-box;font-size:14px}
14750
- .dsh-chat-navigation *,.dsh-chat-brand-control *,.dsh-chat-brand-name *,.dsh-chat-main-anchor *,.dsh-chat-web-surface *{box-sizing:border-box}
14751
- .dsh-chat-navigation button,.dsh-chat-brand-control button,.dsh-chat-main-anchor button,.dsh-chat-web-surface button{font:inherit;-webkit-app-region:no-drag}
14752
- .dsh-chat-navigation button:focus-visible,.dsh-chat-brand-control button:focus-visible,.dsh-chat-main-anchor button:focus-visible,.dsh-chat-web-surface button:focus-visible{outline:2px solid #4d6bfe;outline-offset:3px}
14750
+ .dsh-chat-navigation *,.dsh-chat-brand-control *,.dsh-chat-brand-name *,.dsh-chat-main-anchor *,.dsh-chat-web-surface *,.dsh-chat-settings *{box-sizing:border-box}
14751
+ .dsh-chat-navigation button,.dsh-chat-brand-control button,.dsh-chat-main-anchor button,.dsh-chat-web-surface button,.dsh-chat-settings button{font:inherit;-webkit-app-region:no-drag}
14752
+ .dsh-chat-navigation button:focus-visible,.dsh-chat-brand-control button:focus-visible,.dsh-chat-main-anchor button:focus-visible,.dsh-chat-web-surface button:focus-visible,.dsh-chat-settings button:focus-visible{outline:2px solid #4d6bfe;outline-offset:3px}
14753
14753
  .dsh-chat-modes{display:flex;align-items:center;gap:2px;border:0;padding:3px;margin:0;border-radius:9px;background:var(--dsw-alias-interactive-bg-hover,#e7e9ed);min-width:0;width:max-content}
14754
14754
  .dsh-chat-modes button{padding:6px 9px;border:0;background:transparent;border-radius:6px;color:inherit;font-size:10px;font-weight:650;letter-spacing:.35px;white-space:nowrap;cursor:pointer;min-height:27px}
14755
14755
  .dsh-chat-modes button[aria-pressed="true"]{background:#fff;color:#242832;box-shadow:0 1px 3px #151e2f15}
@@ -14784,6 +14784,7 @@ window.__ModuleLoader__.load({
14784
14784
  .dsh-chat-navigation-status{font-size:12px;line-height:1.7;color:var(--dsw-alias-label-secondary,#8b8d91);padding:6px 4px}
14785
14785
  .dsh-chat-navigation-rail{align-items:center;padding-top:6px}
14786
14786
  .dsh-chat-text-button{padding:7px 4px;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#8b8d91);font-size:11px!important;cursor:pointer}
14787
+ .dsh-chat-primary-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:144px;min-height:40px;padding:10px 20px;border:1px solid #4d6bfe;border-radius:8px;background:#4d6bfe;color:#fff;font-size:14px!important;font-weight:600!important;line-height:20px;white-space:nowrap;cursor:pointer;pointer-events:auto;-webkit-app-region:no-drag}.dsh-chat-primary-button:hover{background:#617dff;border-color:#617dff}.dsh-chat-primary-button:active{background:#3b58e8;border-color:#3b58e8}.dsh-chat-primary-button:disabled{opacity:.5;cursor:default}
14787
14788
  .dsh-chat-main-anchor{height:100%;min-width:0;width:100%;position:relative;background:var(--dsw-alias-bg-base,#fff)}
14788
14789
  .dsh-chat-web-surface{position:fixed;z-index:20;pointer-events:auto;display:flex;flex-direction:column;background:var(--dsw-alias-bg-base,#fff);overflow:hidden}
14789
14790
  .dsh-chat-web-content{position:relative;flex:1;min-height:0;display:flex}.dsh-chat-webview{display:flex;width:100%;height:100%;flex:1;border:0}
@@ -14795,9 +14796,8 @@ window.__ModuleLoader__.load({
14795
14796
  .dsh-chat-leading button{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;-webkit-app-region:no-drag}
14796
14797
  .dsh-chat-leading button:hover{background:var(--dsw-alias-interactive-bg-hover)}.dsh-chat-leading button:disabled{opacity:.4;cursor:default}
14797
14798
  .dsh-chat-settings{font-family:var(--dsw-font-family,system-ui);color:var(--dsw-alias-label-primary);font-size:14px;min-width:0}.dsh-chat-settings h2{margin:0 0 20px;font-size:20px}
14798
- .dsh-chat-settings-pane-hidden{height:1px!important;min-height:1px!important;background:transparent!important;overflow:hidden!important}.dsh-chat-settings-card{border:1px solid var(--dsw-alias-border-primary,#ffffff15);border-radius:12px;padding:24px;background:var(--dsw-alias-bg-base,#202124)}.dsh-chat-settings-language{display:flex;align-items:center;justify-content:space-between;gap:24px;border-top:1px solid #ffffff15;padding-top:20px}.dsh-chat-settings-select{position:relative;display:inline-flex;flex:none;min-width:140px}.dsh-chat-settings-language select{box-sizing:border-box;width:100%;appearance:none;-webkit-appearance:none;font:inherit;color:inherit;background:var(--dsw-alias-bg-base,#202124);border:1px solid #ffffff25;border-radius:8px;padding:8px 38px 8px 12px;min-width:140px}.dsh-chat-settings-select-arrow{position:absolute;right:12px;top:50%;transform:translateY(-50%);width:12px;height:12px;pointer-events:none}.dsh-chat-settings-language select:disabled+.dsh-chat-settings-select-arrow{opacity:.4}.dsh-chat-settings-account p,.dsh-chat-settings-progress{font-size:12px;color:var(--dsw-alias-label-secondary,#aaa)}
14799
- .dsh-chat-settings-pane{position:relative;height:min(500px,calc(100vh - 340px));min-height:220px;border-radius:12px;overflow:hidden;background:#292a2d}
14800
- .dsh-chat-settings-account{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:12px}.dsh-chat-settings-account button{padding:8px 14px;border:1px solid #ff5f64;border-radius:8px;background:transparent;color:#ff5f64;cursor:pointer;font:inherit}.dsh-chat-settings-account button:disabled{opacity:.4;cursor:default}
14799
+ .dsh-chat-settings-card{border:1px solid var(--dsw-alias-border-primary,#ffffff15);border-radius:12px;padding:24px;background:var(--dsw-alias-bg-base,#202124)}.dsh-chat-settings-status strong{display:block;font-size:16px;font-weight:600}.dsh-chat-settings-status p{margin:10px 0 20px;color:var(--dsw-alias-label-secondary,#aaa);line-height:1.7}.dsh-chat-settings-status .dsh-chat-settings-error{color:#ff8585}.dsh-chat-settings-language{display:flex;align-items:center;justify-content:space-between;gap:24px;border-top:1px solid #ffffff15;padding-top:20px}.dsh-chat-settings-select{position:relative;display:inline-flex;flex:none;min-width:140px}.dsh-chat-settings-language select{box-sizing:border-box;width:100%;appearance:none;-webkit-appearance:none;font:inherit;color:inherit;background:var(--dsw-alias-bg-base,#202124);border:1px solid #ffffff25;border-radius:8px;padding:8px 38px 8px 12px;min-width:140px}.dsh-chat-settings-select-arrow{position:absolute;right:12px;top:50%;transform:translateY(-50%);width:12px;height:12px;pointer-events:none}.dsh-chat-settings-language select:disabled+.dsh-chat-settings-select-arrow{opacity:.4}.dsh-chat-settings-account p,.dsh-chat-settings-progress{font-size:12px;color:var(--dsw-alias-label-secondary,#aaa)}
14800
+ .dsh-chat-settings-account{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:12px;min-width:0}.dsh-chat-settings-account>div{flex:1 1 0%;min-width:0;max-width:100%}.dsh-chat-settings-account strong{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dsh-chat-settings-account button{flex-shrink:0;white-space:nowrap;padding:8px 14px;border:1px solid #ff5f64;border-radius:8px;background:transparent;color:#ff5f64;cursor:pointer;font:inherit}.dsh-chat-settings-account button:disabled{opacity:.4;cursor:default}
14801
14801
  .dsh-chat-settings-error{color:#ff8585;line-height:1.5;font-size:12px}
14802
14802
  `;
14803
14803
 
@@ -14916,7 +14916,7 @@ window.__ModuleLoader__.load({
14916
14916
  ] }),
14917
14917
  searching && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dsh-chat-navigation-search", "aria-label": "\u641C\u7D22\u5DF2\u52A0\u8F7D\u7684\u5B98\u7F51\u5BF9\u8BDD\u6807\u9898", placeholder: "\u641C\u7D22\u5BF9\u8BDD", value: query, onChange: (event) => setQuery(event.target.value), autoFocus: true }),
14918
14918
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-navigation-list", children: [
14919
- navigation.authenticated === true ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
14919
+ navigation.authenticated === true && navigation.status === "ready" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
14920
14920
  [...groups].map(([label, rows]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dsh-chat-conversation-group", "aria-label": label, children: [
14921
14921
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: label }),
14922
14922
  rows.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-chat-conversation-row", title: item.title, "aria-current": navigation.selectedHref === item.href ? "page" : void 0, onClick: () => bridge.commandWebsite({ type: "open", href: item.href }), children: item.title }, item.href))
@@ -14968,56 +14968,45 @@ window.__ModuleLoader__.load({
14968
14968
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tooltip, { label: "\u65B0\u5EFA\u5BF9\u8BDD", delayMs: 500, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": "\u65B0\u5EFA\u5B98\u7F51\u5BF9\u8BDD", disabled: !state.modeEnabled || !state.websiteNavigation.canCreate, onClick: () => bridge.commandWebsite({ type: "new" }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconNewChatOutlineRegular, { size: 16 }) }) })
14969
14969
  ] });
14970
14970
  }
14971
- function DshChatChatSettings({ bridge }) {
14971
+ function DshChatChatSettings({ bridge, close }) {
14972
14972
  const state = useDshChat(bridge);
14973
- const pane = (0, import_react.useRef)(null);
14974
14973
  const enabled = state.desktopAvailable;
14975
14974
  (0, import_react.useLayoutEffect)(() => {
14976
- const element = pane.current;
14977
- if (!element || !enabled) {
14978
- bridge.updateSettingsViewport(null);
14975
+ if (!enabled) {
14976
+ bridge.setSettingsOpen(false);
14979
14977
  return;
14980
14978
  }
14981
- const measure = () => {
14982
- const rect = element.getBoundingClientRect();
14983
- bridge.updateSettingsViewport({ left: rect.left, top: rect.top, width: rect.width, height: rect.height });
14984
- };
14985
- const resize = new ResizeObserver(measure);
14986
- resize.observe(element);
14987
- globalThis.addEventListener("resize", measure);
14988
- globalThis.addEventListener("scroll", measure, true);
14989
- measure();
14979
+ bridge.setSettingsOpen(true);
14990
14980
  return () => {
14991
- resize.disconnect();
14992
- globalThis.removeEventListener("resize", measure);
14993
- globalThis.removeEventListener("scroll", measure, true);
14994
- bridge.updateSettingsViewport(null);
14981
+ bridge.setSettingsOpen(false);
14995
14982
  };
14996
14983
  }, [bridge, enabled]);
14997
- (0, import_react.useLayoutEffect)(() => {
14998
- if (!enabled || !pane.current) return;
14999
- const rect = pane.current.getBoundingClientRect();
15000
- bridge.updateSettingsViewport({ left: rect.left, top: rect.top, width: rect.width, height: rect.height });
15001
- }, [bridge, enabled, state.preferenceError, state.websiteNavigation.accountName, state.websiteNavigation.settings?.error, state.websiteAuthenticationStatus]);
14984
+ const signIn = () => {
14985
+ bridge.setSettingsOpen(false);
14986
+ close();
14987
+ bridge.beginWebsiteSignIn();
14988
+ };
15002
14989
  const navigation = state.websiteNavigation;
15003
14990
  const settings = navigation.settings;
14991
+ const showAccount = enabled && navigation.authenticated === true && !["signed-out", "signing-in", "signing-out"].includes(state.websiteAuthenticationStatus);
15004
14992
  const language = /中文|Chinese/i.test(settings?.language ?? "") ? "zh-CN" : /English|英语/i.test(settings?.language ?? "") ? "en" : /^(System|跟随系统|系统|Follow system)$/i.test(settings?.language ?? "") ? "system" : "";
15005
14993
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dsh-chat-settings", children: [
15006
14994
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DshChatStyles, {}),
15007
14995
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "CHAT\u8BBE\u7F6E" }),
15008
- enabled && navigation.authenticated === true && state.websiteAuthenticationStatus !== "signing-out" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card", children: [
15009
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-account", children: [
14996
+ showAccount && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card", children: [
14997
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-account", role: "group", "aria-label": "DeepSeek \u5B98\u7F51\u8D26\u53F7", children: [
15010
14998
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
15011
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: navigation.accountName || "DeepSeek Chat" }),
14999
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { title: navigation.accountName || "DeepSeek Chat", children: navigation.accountName || "DeepSeek Chat" }),
15012
15000
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u5DF2\u767B\u5F55" })
15013
15001
  ] }),
15014
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => bridge.logoutWebsite(), children: "\u9000\u51FA\u767B\u5F55" })
15002
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: navigation.status !== "ready", onClick: () => bridge.logoutWebsite(), children: "\u9000\u51FA\u767B\u5F55" })
15015
15003
  ] }),
15016
15004
  state.websiteSessionStatus === "saved" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: "\u5DF2\u8BB0\u4F4F\u7F51\u9875\u767B\u5F55\u3002\u4E0B\u6B21\u542F\u52A8\u4F1A\u7531\u5B98\u7F51\u9A8C\u8BC1\u5E76\u6062\u590D\uFF1B\u6388\u6743\u5931\u6548\u65F6\u9700\u91CD\u65B0\u767B\u5F55\u3002" }),
15005
+ navigation.status !== "ready" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-chat-settings-progress", role: "status", children: "\u6B63\u5728\u91CD\u65B0\u8BC6\u522B\u5B98\u7F51\u9875\u9762\uFF0C\u8D26\u53F7\u767B\u5F55\u72B6\u6001\u4FDD\u6301\u4E0D\u53D8\u3002" }),
15017
15006
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dsh-chat-settings-language", children: [
15018
15007
  "\u7CFB\u7EDF\u8BED\u8A00",
15019
15008
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsh-chat-settings-select", children: [
15020
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { "aria-label": "CHAT\u7CFB\u7EDF\u8BED\u8A00", value: language, disabled: settings?.pending || state.websiteAuthenticationStatus === "error", onChange: (event) => bridge.commandWebsite({ type: "setting", key: "language", value: event.target.value }), children: [
15009
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { "aria-label": "CHAT\u7CFB\u7EDF\u8BED\u8A00", value: language, disabled: navigation.status !== "ready" || settings?.pending || state.websiteAuthenticationStatus === "error", onChange: (event) => bridge.commandWebsite({ type: "setting", key: "language", value: event.target.value }), children: [
15021
15010
  !language && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", hidden: true }),
15022
15011
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "system", children: "\u8DDF\u968F\u7CFB\u7EDF" }),
15023
15012
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "zh-CN", children: "\u7B80\u4F53\u4E2D\u6587" }),
@@ -15026,12 +15015,12 @@ window.__ModuleLoader__.load({
15026
15015
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "dsh-chat-settings-select-arrow", viewBox: "0 0 12 12", "aria-hidden": "true", focusable: "false", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m2 4 4 4 4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
15027
15016
  ] })
15028
15017
  ] }),
15029
- !language && !settings?.pending && !settings?.error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-chat-settings-progress", role: "status", children: [
15018
+ !language && navigation.status === "ready" && !settings?.pending && !settings?.error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-chat-settings-progress", role: "status", children: [
15030
15019
  "\u5C1A\u672A\u8BFB\u53D6\u5230\u5B98\u7F51\u8BED\u8A00\u3002",
15031
15020
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => bridge.commandWebsite({ type: "settings-read" }), children: "\u91CD\u8BD5" })
15032
15021
  ] }),
15033
- settings?.pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-chat-settings-progress", role: "status", children: "\u6B63\u5728\u540C\u6B65\u7F51\u9875\u8BBE\u7F6E\u2026" }),
15034
- settings?.error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-chat-settings-error", role: "alert", children: [
15022
+ navigation.status === "ready" && settings?.pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-chat-settings-progress", role: "status", children: "\u6B63\u5728\u540C\u6B65\u7F51\u9875\u8BBE\u7F6E\u2026" }),
15023
+ navigation.status === "ready" && settings?.error && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-chat-settings-error", role: "alert", children: [
15035
15024
  settings.error,
15036
15025
  " ",
15037
15026
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => bridge.commandWebsite({ type: "settings-read" }), children: "\u91CD\u8BD5" })
@@ -15044,23 +15033,30 @@ window.__ModuleLoader__.load({
15044
15033
  ] })
15045
15034
  ] }),
15046
15035
  !enabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: "\u9700\u8981 DSH \u684C\u9762\u7248\u7684\u5B98\u65B9\u7F51\u9875\u5BB9\u5668\u3002" }),
15047
- enabled && state.websiteAuthenticationStatus === "signed-out" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card", children: [
15048
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "CHAT \u5C1A\u672A\u767B\u5F55\u3002\u8FD9\u91CC\u4E0E\u5BF9\u8BDD\u9875\u9762\u4F7F\u7528\u540C\u4E00\u4E2A\u5B98\u7F51\u8D26\u53F7\uFF0C\u767B\u5F55\u540E\u81EA\u52A8\u540C\u6B65\u3002" }),
15049
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => bridge.beginWebsiteSignIn(), children: "\u767B\u5F55 DeepSeek" })
15036
+ enabled && state.websiteAuthenticationStatus === "signed-out" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card dsh-chat-settings-status", children: [
15037
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "CHAT \u5C1A\u672A\u767B\u5F55" }),
15038
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u767B\u5F55\u4F1A\u6253\u5F00 CHAT \u5BF9\u8BDD\u9875\u9762\u3002\u5B8C\u6210\u5B98\u7F51\u767B\u5F55\u540E\uFF0C\u8FD9\u91CC\u7684\u8D26\u53F7\u4E0E\u5B98\u7F51\u5BF9\u8BDD\u4F1A\u81EA\u52A8\u540C\u6B65\u3002" }),
15039
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-chat-primary-button", onClick: signIn, children: "\u767B\u5F55 DeepSeek" })
15040
+ ] }),
15041
+ enabled && state.websiteAuthenticationStatus === "signing-in" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card dsh-chat-settings-status", children: [
15042
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { role: "status", children: "\u6B63\u5728\u767B\u5F55 DeepSeek" }),
15043
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u8BF7\u5728 CHAT \u5BF9\u8BDD\u9875\u9762\u5B8C\u6210\u5B98\u7F51\u767B\u5F55\u3002\u767B\u5F55\u6210\u529F\u540E\uFF0C\u8D26\u53F7\u548C\u767B\u5F55\u8BB0\u5FC6\u4F1A\u81EA\u52A8\u540C\u6B65\u3002" }),
15044
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-chat-primary-button", onClick: signIn, children: "\u7EE7\u7EED\u767B\u5F55" })
15050
15045
  ] }),
15051
- enabled && state.websiteAuthenticationStatus === "signing-in" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: "\u8BF7\u5728\u4E0B\u65B9\u5B98\u7F51\u5B8C\u6210\u767B\u5F55\u3002\u767B\u5F55\u6210\u529F\u540E\u8D26\u53F7\u3001\u5BF9\u8BDD\u5217\u8868\u548C\u767B\u5F55\u8BB0\u5FC6\u4F1A\u81EA\u52A8\u540C\u6B65\u3002" }),
15052
- enabled && state.websiteAuthenticationStatus === "signing-out" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: "\u6B63\u5728\u6E05\u9664\u767B\u5F55\u8BB0\u5FC6\u5E76\u9000\u51FA\u5B98\u7F51\u2026" }),
15053
- enabled && state.websiteAuthenticationStatus === "error" && state.websiteSessionError && navigation.authenticated !== true && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-chat-settings-error", role: "alert", children: [
15054
- state.websiteSessionError,
15055
- " ",
15056
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => bridge.logoutWebsite(), children: "\u91CD\u8BD5\u9000\u51FA\u767B\u5F55" })
15046
+ enabled && state.websiteAuthenticationStatus === "signing-out" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card dsh-chat-settings-status", children: [
15047
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { role: "status", children: "\u6B63\u5728\u9000\u51FA\u767B\u5F55" }),
15048
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u6B63\u5728\u6E05\u9664\u767B\u5F55\u8BB0\u5FC6\u5E76\u9000\u51FA\u5B98\u7F51\u2026" })
15057
15049
  ] }),
15058
- enabled && state.websiteAuthenticationStatus !== "signing-out" && navigation.authenticated !== true && navigation.status !== "sign-in" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { role: "status", children: [
15059
- state.webError || (navigation.status === "unsupported" ? "\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u5B98\u7F51\u3002" : "\u6B63\u5728\u8FDE\u63A5 DeepSeek \u5B98\u7F51\u2026"),
15060
- " ",
15061
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => bridge.reloadWebsite(), children: "\u91CD\u8BD5" })
15050
+ enabled && state.websiteAuthenticationStatus === "error" && !showAccount && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card dsh-chat-settings-status", children: [
15051
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u767B\u5F55\u72B6\u6001\u6682\u65F6\u65E0\u6CD5\u540C\u6B65" }),
15052
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-chat-settings-error", role: "alert", children: state.websiteSessionError || state.webError || "\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u5B98\u7F51\u767B\u5F55\u72B6\u6001\uFF0C\u8BF7\u91CD\u8BD5\u3002" }),
15053
+ /退出/.test(state.websiteSessionError ?? "") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.logoutWebsite(), children: "\u91CD\u8BD5\u9000\u51FA\u767B\u5F55" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.reloadWebsite(), children: "\u91CD\u65B0\u52A0\u8F7D" })
15062
15054
  ] }),
15063
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: pane, className: `dsh-chat-settings-pane${enabled && state.websiteAuthenticationStatus === "signing-in" ? "" : " dsh-chat-settings-pane-hidden"}`, "aria-label": "CHAT\u5B98\u7F51\u767B\u5F55\u533A\u57DF" })
15055
+ enabled && !showAccount && state.websiteAuthenticationStatus === "loading" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-chat-settings-card dsh-chat-settings-status", children: [
15056
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { role: "status", children: "\u6B63\u5728\u540C\u6B65\u5B98\u7F51\u8D26\u53F7" }),
15057
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: state.webError || (navigation.status === "unsupported" ? "\u5B98\u7F51\u9875\u9762\u5DF2\u6253\u5F00\uFF0C\u6B63\u5728\u540C\u6B65\u8D26\u53F7\u548C\u5BF9\u8BDD\u5217\u8868\u2026" : "\u6B63\u5728\u8BC6\u522B DeepSeek \u5B98\u7F51\u767B\u5F55\u72B6\u6001\u2026") }),
15058
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.reloadWebsite(), children: "\u91CD\u65B0\u52A0\u8F7D" })
15059
+ ] })
15064
15060
  ] });
15065
15061
  }
15066
15062
 
@@ -15410,16 +15406,23 @@ window.__ModuleLoader__.load({
15410
15406
  const missingSidebarMarker = "data-dsh-chat-sidebar-missing-at";
15411
15407
  const fallbackMarker = "data-dsh-chat-fallback";
15412
15408
  const fallbackErrorMarker = "data-dsh-chat-fallback-error";
15409
+ const profileMarker = "data-dsh-chat-profile";
15410
+ const profileProofMarker = "data-dsh-chat-profile-confirmed";
15411
+ const profileAvatarMarker = "data-dsh-chat-profile-avatar";
15412
+ const navigationWidthMarker = "data-dsh-chat-navigation-width";
15413
+ const expandingMarker = "data-dsh-chat-expanding";
15414
+ const compactToggleMarker = "data-dsh-chat-compact-toggle";
15413
15415
  const conversationError = "\u8BE5\u5BF9\u8BDD\u4E0D\u5728\u5F53\u524D\u5B98\u7F51\u5217\u8868\uFF0C\u8BF7\u5237\u65B0\u5217\u8868\u3002";
15414
15416
  const styleId = "dsh-chat-website-navigation-style";
15415
15417
  const preparingStyleId = "dsh-chat-website-preparing-style";
15416
- const owned = [marker, presentedMarker, missingSidebarMarker, fallbackMarker, fallbackErrorMarker, "data-dsh-chat-layout", "data-dsh-chat-content", "data-dsh-chat-web-chrome", "data-dsh-chat-profile", "data-dsh-chat-settings-dialog", "data-dsh-chat-settings-host", "data-dsh-chat-settings-tabs", "data-dsh-chat-settings-pane", "data-dsh-chat-settings-layout", "data-dsh-chat-settings-chrome", "data-dsh-chat-settings-appearance", "data-dsh-chat-expanding", "data-dsh-chat-header-row", "data-dsh-chat-header-title", "data-dsh-chat-header-share", "data-dsh-chat-header-title-host", "data-dsh-chat-header-editor", "data-dsh-chat-header-native-depth"];
15417
- const empty = (status) => ({ status, authenticated: false, conversations: [], selectedHref: null, canCreate: false, error: null });
15418
- const clearSettings = () => {
15419
- for (const attr of [...doc.documentElement.attributes]) if (/^data-dsh-chat-(settings-|language$|theme$|dark-complete$)/.test(attr.name)) doc.documentElement.removeAttribute(attr.name);
15420
- };
15421
- const restore = () => {
15422
- clearSettings();
15418
+ const owned = [marker, presentedMarker, missingSidebarMarker, fallbackMarker, fallbackErrorMarker, profileMarker, profileProofMarker, profileAvatarMarker, navigationWidthMarker, expandingMarker, compactToggleMarker, "data-dsh-chat-layout", "data-dsh-chat-content", "data-dsh-chat-web-chrome", "data-dsh-chat-settings-dialog", "data-dsh-chat-settings-host", "data-dsh-chat-settings-tabs", "data-dsh-chat-settings-pane", "data-dsh-chat-settings-layout", "data-dsh-chat-settings-chrome", "data-dsh-chat-settings-appearance", "data-dsh-chat-header-row", "data-dsh-chat-header-title", "data-dsh-chat-header-share", "data-dsh-chat-header-title-host", "data-dsh-chat-header-editor", "data-dsh-chat-header-native-depth"];
15419
+ const empty = (status) => ({ status, ...status === "sign-in" ? { authenticated: false } : {}, conversations: [], selectedHref: null, canCreate: false, error: null });
15420
+ const clearSettings = (preserveConfirmedPreferences = false) => {
15421
+ const confirmed = ["data-dsh-chat-language", "data-dsh-chat-theme", "data-dsh-chat-dark-complete", "data-dsh-chat-settings-restored"];
15422
+ for (const attr of [...doc.documentElement.attributes]) if (/^data-dsh-chat-(settings-|language$|theme$|dark-complete$)/.test(attr.name) && !(preserveConfirmedPreferences && confirmed.includes(attr.name))) doc.documentElement.removeAttribute(attr.name);
15423
+ };
15424
+ const restore = (preserveConfirmedPreferences = false, preserveCompactAttempt = false) => {
15425
+ clearSettings(preserveConfirmedPreferences);
15423
15426
  doc.getElementById(styleId)?.remove();
15424
15427
  doc.getElementById("dsh-chat-header-style")?.remove();
15425
15428
  doc.documentElement.style.removeProperty("--dsh-chat-title-inset");
@@ -15427,10 +15430,14 @@ window.__ModuleLoader__.load({
15427
15430
  doc.getElementById("dsh-chat-settings-view-style")?.remove();
15428
15431
  doc.documentElement.removeAttribute("data-dsh-chat-voice");
15429
15432
  doc.documentElement.removeAttribute("data-dsh-chat-preparing");
15430
- owned.forEach((attr) => doc.querySelectorAll(`[${attr}]`).forEach((node2) => node2.removeAttribute(attr)));
15433
+ owned.forEach((attr) => {
15434
+ if (preserveCompactAttempt && (attr === expandingMarker || attr === compactToggleMarker)) return;
15435
+ doc.querySelectorAll(`[${attr}]`).forEach((node2) => node2.removeAttribute(attr));
15436
+ });
15431
15437
  };
15432
15438
  const fallback = (error51 = null) => {
15433
- restore();
15439
+ const preserveRecovery = page.origin === origin && !/^\/sign_in\/?$/.test(page.pathname) && command.type !== "restore";
15440
+ restore(preserveRecovery, preserveRecovery);
15434
15441
  if (page.origin === origin && /^\/sign_in\/?$/.test(page.pathname)) return empty("sign-in");
15435
15442
  if (!(command.type === "snapshot" && command.showOriginal)) {
15436
15443
  doc.documentElement.setAttribute(fallbackMarker, "");
@@ -15438,6 +15445,8 @@ window.__ModuleLoader__.load({
15438
15445
  }
15439
15446
  return { ...empty("unsupported"), error: error51 === "open" ? conversationError : null };
15440
15447
  };
15448
+ const fallbackNavigation = () => ({ ...empty("unsupported"), error: doc.documentElement.getAttribute(fallbackErrorMarker) === "open" ? conversationError : null });
15449
+ const isOriginalSnapshot = command.type === "snapshot" && command.showOriginal;
15441
15450
  if (page.origin !== origin) return fallback();
15442
15451
  if (command.type !== "restore") dismissWebsiteEnvironmentNotice(doc);
15443
15452
  if (command.type === "restore" || command.type === "snapshot" && command.showOriginal) {
@@ -15445,9 +15454,7 @@ window.__ModuleLoader__.load({
15445
15454
  if (command.type === "restore") return fallback();
15446
15455
  restore();
15447
15456
  }
15448
- if (doc.documentElement.hasAttribute(fallbackMarker) && !/^\/sign_in\/?$/.test(page.pathname)) {
15449
- return { ...empty("unsupported"), error: doc.documentElement.getAttribute(fallbackErrorMarker) === "open" ? conversationError : null };
15450
- }
15457
+ const recovering = doc.documentElement.hasAttribute(fallbackMarker);
15451
15458
  if (!(command.type === "snapshot" && command.showOriginal) && !doc.documentElement.hasAttribute("data-dsh-chat-observing") && doc.defaultView) {
15452
15459
  doc.documentElement.setAttribute("data-dsh-chat-observing", "");
15453
15460
  let queued = false;
@@ -15470,7 +15477,7 @@ window.__ModuleLoader__.load({
15470
15477
  restore();
15471
15478
  return empty("sign-in");
15472
15479
  }
15473
- if (!(command.type === "snapshot" && command.showOriginal) && !doc.documentElement.hasAttribute(presentedMarker) && !doc.documentElement.hasAttribute("data-dsh-chat-dark-complete")) {
15480
+ if (!isOriginalSnapshot && !recovering && !doc.documentElement.hasAttribute(presentedMarker) && !doc.documentElement.hasAttribute("data-dsh-chat-dark-complete")) {
15474
15481
  doc.documentElement.setAttribute("data-dsh-chat-preparing", "");
15475
15482
  if (!doc.getElementById(preparingStyleId)) {
15476
15483
  const style = doc.createElement("style");
@@ -15499,8 +15506,8 @@ window.__ModuleLoader__.load({
15499
15506
  };
15500
15507
  const isNavigationColumn = (candidate) => {
15501
15508
  const rect = candidate.getBoundingClientRect();
15502
- const viewportHeight = doc.defaultView?.innerHeight ?? 600;
15503
- return rect.left >= -1 && rect.left <= 16 && rect.top >= -1 && rect.top <= 32 && rect.width >= 160 && rect.width <= 480 && rect.height >= Math.max(200, viewportHeight * 0.75) && !candidate.querySelector('textarea,[contenteditable="true"]');
15509
+ const viewportHeight2 = doc.defaultView?.innerHeight ?? 600;
15510
+ return rect.left >= -1 && rect.left <= 16 && rect.top >= -1 && rect.top <= 32 && rect.width >= 160 && rect.width <= 480 && rect.height >= Math.max(200, viewportHeight2 * 0.75) && !candidate.querySelector('textarea,[contenteditable="true"]');
15504
15511
  };
15505
15512
  const allLinks = [...doc.querySelectorAll("a[href]")].filter((link) => safeHref(link.getAttribute("href")));
15506
15513
  let sidebar = doc.querySelector(`[${marker}]`);
@@ -15526,39 +15533,65 @@ window.__ModuleLoader__.load({
15526
15533
  }
15527
15534
  }
15528
15535
  const newChat = sidebar ? findNew(sidebar) : null;
15529
- if (!sidebar || !newChat) {
15530
- if (!(command.type === "snapshot" && command.showOriginal) && doc.documentElement.hasAttribute(presentedMarker)) {
15531
- const now = Date.now();
15532
- const previous = Number(doc.documentElement.getAttribute(missingSidebarMarker));
15533
- const started = Number.isFinite(previous) && previous > 0 ? previous : now;
15534
- if (started !== previous) doc.documentElement.setAttribute(missingSidebarMarker, String(started));
15535
- if (now - started < 5e3) return empty("loading");
15536
- return fallback();
15537
- }
15538
- if (!(command.type === "snapshot" && command.showOriginal)) {
15539
- const compact = [...doc.querySelectorAll("div,header")].find((el) => {
15540
- const r = el.getBoundingClientRect();
15541
- const buttons = el.querySelectorAll('button,[role="button"]');
15542
- return r.top >= -1 && r.top < 80 && r.left >= -1 && r.left < 180 && r.width > 30 && r.width < 400 && r.height > 16 && r.height < 80 && buttons.length >= 2 && buttons.length <= 3 && el.querySelector("svg,img") && !el.textContent?.trim();
15543
- });
15544
- const mobileToggle = [...doc.querySelectorAll('button,[role="button"]')].find((el) => {
15545
- const r = el.getBoundingClientRect();
15546
- return r.left >= 0 && r.left < 80 && r.top >= 0 && r.top < 80 && r.width >= 20 && r.width <= 72 && r.height >= 20 && r.height <= 72 && !el.textContent?.trim() && !!el.querySelector("svg") && !el.closest("[data-dsh-chat-settings-dialog]");
15536
+ const structureExpired = () => {
15537
+ const now = Date.now();
15538
+ const previous = Number(doc.documentElement.getAttribute(missingSidebarMarker));
15539
+ const started = Number.isFinite(previous) && previous > 0 ? previous : now;
15540
+ if (started !== previous) doc.documentElement.setAttribute(missingSidebarMarker, String(started));
15541
+ return now - started >= 5e3;
15542
+ };
15543
+ const iconButtonSelector = 'button,[role="button"],.ds-icon-button';
15544
+ const compactNavigation = () => {
15545
+ const toggleLabels = /^(展开侧边栏|打开侧边栏|侧边栏|切换侧边栏|Open sidebar|Expand sidebar|Toggle sidebar|Sidebar)$/i;
15546
+ const openingLabels = /^(展开侧边栏|打开侧边栏|Open sidebar|Expand sidebar)$/i;
15547
+ const searchLabels = /^(搜索|搜索对话|Search|Search chats|Search conversations)$/i;
15548
+ const newLabels = /^(开启新对话|新对话|新建对话|New chat|New Chat)$/i;
15549
+ const namedAs = (button, expected) => {
15550
+ const names = ["aria-label", "title"].map((attr) => (button.getAttribute(attr) ?? "").trim()).filter(Boolean);
15551
+ return names.length === 0 || names.every((name2) => expected.test(name2));
15552
+ };
15553
+ for (const row of doc.querySelectorAll("div,header,nav")) {
15554
+ const bounds = row.getBoundingClientRect();
15555
+ if (bounds.top < -1 || bounds.top > 72 || bounds.left < -1 || bounds.left > 160 || bounds.width < 72 || bounds.width > 360 || bounds.height < 24 || bounds.height > 80 || row.textContent?.trim() || row.closest('[role="dialog"],[role="menu"],[data-dsh-chat-settings-dialog],.ds-modal-content,.ds-dropdown-menu') || row.querySelector('a[href],input,textarea,[contenteditable="true"]')) continue;
15556
+ const rowButtons = [...row.querySelectorAll(iconButtonSelector)].filter((button) => {
15557
+ const parentButton = button.parentElement?.closest(iconButtonSelector);
15558
+ return !parentButton || !row.contains(parentButton);
15547
15559
  });
15548
- const expandable = compact ?? mobileToggle;
15549
- if (expandable) {
15550
- const started = Number(expandable.getAttribute("data-dsh-chat-expanding"));
15551
- if (!started) {
15552
- expandable.setAttribute("data-dsh-chat-expanding", String(Date.now()));
15553
- (compact?.querySelector('button,[role="button"]') ?? mobileToggle)?.click();
15554
- return empty("loading");
15555
- }
15556
- if (Date.now() - started < 5e3) return empty("loading");
15557
- }
15560
+ if (rowButtons.length !== 3) continue;
15561
+ const buttons = rowButtons.filter((button) => {
15562
+ const rect = button.getBoundingClientRect();
15563
+ return rect.width >= 20 && rect.width <= 64 && rect.height >= 20 && rect.height <= 64 && rect.left >= bounds.left - 1 && rect.right <= bounds.right + 1 && rect.top >= bounds.top - 1 && rect.bottom <= bounds.bottom + 1 && !button.textContent?.trim() && !!button.querySelector("svg") && !button.closest('[hidden],[aria-hidden="true"]') && getComputedStyle(button).visibility !== "hidden" && button.getAttribute("aria-disabled") !== "true" && !button.matches(":disabled");
15564
+ }).sort((left, right) => left.getBoundingClientRect().left - right.getBoundingClientRect().left);
15565
+ if (buttons.length !== 3 || buttons[0].getAttribute("aria-expanded") === "true" || !namedAs(buttons[0], toggleLabels) || !namedAs(buttons[1], searchLabels) || !namedAs(buttons[2], newLabels)) continue;
15566
+ const rects = buttons.map((button) => button.getBoundingClientRect());
15567
+ if (rects.some((rect) => Math.abs(rect.top - rects[0].top) > 8) || rects[1].left < rects[0].right - 1 || rects[2].left < rects[1].right - 1) continue;
15568
+ return { row, toggle: buttons[0] };
15569
+ }
15570
+ for (const toggle of doc.querySelectorAll(iconButtonSelector)) {
15571
+ const bounds = toggle.getBoundingClientRect();
15572
+ const name2 = (toggle.getAttribute("aria-label") || toggle.getAttribute("title") || "").trim();
15573
+ const expanded = toggle.getAttribute("aria-expanded");
15574
+ if (!toggleLabels.test(name2) || expanded === "true" || !openingLabels.test(name2) && expanded !== "false" || bounds.left < 0 || bounds.left > 160 || bounds.top < 0 || bounds.top > 72 || bounds.width < 20 || bounds.width > 64 || bounds.height < 20 || bounds.height > 64 || toggle.textContent?.trim() || !toggle.querySelector("svg") || toggle.getAttribute("aria-disabled") === "true" || toggle.matches(":disabled") || getComputedStyle(toggle).visibility === "hidden" || toggle.closest('[hidden],[aria-hidden="true"],a[href],[role="dialog"],[role="menu"],[data-dsh-chat-settings-dialog],.ds-modal-content,.ds-dropdown-menu')) continue;
15575
+ return { row: toggle.parentElement, toggle };
15558
15576
  }
15559
- return fallback();
15577
+ return null;
15578
+ };
15579
+ if (!sidebar || !newChat) {
15580
+ const compact = !isOriginalSnapshot && command.type === "snapshot" ? compactNavigation() : null;
15581
+ if (compact && !doc.documentElement.hasAttribute(expandingMarker)) {
15582
+ const started = String(Date.now());
15583
+ compact.toggle.setAttribute(compactToggleMarker, started);
15584
+ doc.documentElement.setAttribute(expandingMarker, started);
15585
+ doc.documentElement.setAttribute(missingSidebarMarker, started);
15586
+ compact.toggle.click();
15587
+ return empty("loading");
15588
+ }
15589
+ const expandedAt = Number(doc.documentElement.getAttribute(expandingMarker));
15590
+ if (!isOriginalSnapshot && Number.isFinite(expandedAt) && expandedAt > 0 && Date.now() - expandedAt < 5e3) return empty("loading");
15591
+ if (recovering) return fallbackNavigation();
15592
+ if (isOriginalSnapshot || structureExpired()) return fallback();
15593
+ return empty("loading");
15560
15594
  }
15561
- doc.documentElement.removeAttribute(missingSidebarMarker);
15562
15595
  let track = sidebar;
15563
15596
  for (let depth = 0; depth < 5 && track.parentElement && track.parentElement !== doc.body; depth++) {
15564
15597
  const parent = track.parentElement;
@@ -15569,21 +15602,103 @@ window.__ModuleLoader__.load({
15569
15602
  const layout = track.parentElement;
15570
15603
  const siblings = layout ? [...layout.children].filter((el) => el !== track && !el.matches('script,style,[role="dialog"],.ds-modal-content')) : [];
15571
15604
  const content = siblings.find((el) => el.hasAttribute("data-dsh-chat-content")) ?? siblings.find((el) => el.querySelector('textarea,[contenteditable="true"]')) ?? siblings.find((el) => el.querySelector("._2be88ba > .the-header > ._9fcbeda")) ?? (siblings.length === 1 ? siblings[0] : void 0);
15572
- const avatars = [...track.querySelectorAll("img")].filter((img) => !img.closest("a[href]"));
15573
- const avatar = avatars.find((img) => {
15574
- const r = img.getBoundingClientRect();
15575
- return r.top > (doc.defaultView?.innerHeight ?? 600) * 0.75 && r.height <= 80;
15576
- }) ?? (track.hasAttribute(marker) ? avatars.at(-1) : void 0);
15577
- let profile = doc.querySelector("[data-dsh-chat-profile]") ?? avatar?.parentElement ?? null;
15578
- for (let depth = 0; profile?.parentElement && depth < 3; depth++) {
15579
- const p = profile.parentElement;
15580
- if (p === sidebar || p.querySelector("a[href]") || p.getBoundingClientRect().height > 100) break;
15581
- profile = p;
15582
- }
15583
- profile?.setAttribute("data-dsh-chat-profile", "");
15584
- const accountName = profile?.textContent?.trim().slice(0, 100) || null;
15585
- const authenticated = profile !== null && Boolean(accountName || profile.querySelector("img"));
15586
- const settings = adaptWebsiteSettings(doc, profile, command);
15605
+ const trackRect = track.getBoundingClientRect();
15606
+ const contentRect = content?.getBoundingClientRect();
15607
+ const viewportWidth = doc.defaultView?.innerWidth ?? 0;
15608
+ const confirmedBoundary = track.hasAttribute(marker) && layout?.hasAttribute("data-dsh-chat-layout");
15609
+ const boundedContent = layout && content && content !== doc.body && content.isConnected && content.parentElement === layout && contentRect && contentRect.width > 0 && contentRect.height > 0 && contentRect.right <= viewportWidth + 1 && (confirmedBoundary || trackRect.left >= -1 && trackRect.left <= 16 && trackRect.width >= 160 && trackRect.width <= 480 && contentRect.left >= trackRect.right - 16);
15610
+ if (!boundedContent) {
15611
+ if (recovering) return fallbackNavigation();
15612
+ if (isOriginalSnapshot || structureExpired()) return fallback();
15613
+ return empty("loading");
15614
+ }
15615
+ doc.documentElement.removeAttribute(missingSidebarMarker);
15616
+ doc.documentElement.removeAttribute(expandingMarker);
15617
+ doc.querySelectorAll(`[${compactToggleMarker}]`).forEach((button) => button.removeAttribute(compactToggleMarker));
15618
+ if (recovering) {
15619
+ doc.documentElement.removeAttribute(fallbackMarker);
15620
+ doc.documentElement.removeAttribute(fallbackErrorMarker);
15621
+ doc.documentElement.setAttribute(presentedMarker, "");
15622
+ }
15623
+ const viewportHeight = doc.defaultView?.innerHeight ?? 0;
15624
+ const nicknameLeaf = (row) => {
15625
+ const texts = doc.createTreeWalker(row, 4);
15626
+ let found = null;
15627
+ let text;
15628
+ while (text = texts.nextNode()) {
15629
+ const parent = text.parentElement;
15630
+ const excluded = parent?.closest('svg,script,style,[hidden],[aria-hidden="true"]');
15631
+ if (!parent || excluded && row.contains(excluded)) continue;
15632
+ const name2 = (text.textContent ?? "").trim();
15633
+ if (!name2) continue;
15634
+ if (found || parent.childElementCount !== 0 || name2.length > 100 || /[\r\n]/.test(name2)) return null;
15635
+ found = { element: parent, name: name2 };
15636
+ }
15637
+ return found;
15638
+ };
15639
+ const checkProfile = (row, image, geometry) => {
15640
+ if (!row.isConnected || !track.contains(row) || row === sidebar || row === track || row === layout || row.contains(newChat) || row.matches("a[href]") || image.closest("a[href]") || row.querySelector('a[href],textarea,input,[contenteditable="true"],[role="menu"],[role="dialog"],.ds-dropdown-menu,.ds-modal-content') || row.querySelectorAll("img").length !== 1 || !row.contains(image)) return null;
15641
+ if (geometry) {
15642
+ const bounds = row.getBoundingClientRect(), avatarBounds = image.getBoundingClientRect(), column = track.getBoundingClientRect();
15643
+ if (column.width < 160 || column.width > 480 || column.left < -1 || column.left > 16 || bounds.top < viewportHeight * 0.75 || bounds.bottom > viewportHeight + 1 || bounds.height < 24 || bounds.height > 100 || bounds.width < 80 || bounds.width > column.width + 1 || bounds.left < column.left - 1 || bounds.right > column.right + 1 || avatarBounds.width < 8 || avatarBounds.width > 80 || avatarBounds.height < 8 || avatarBounds.height > 80 || avatarBounds.left < bounds.left - 1 || avatarBounds.right > bounds.right + 1 || avatarBounds.top < bounds.top - 1 || avatarBounds.bottom > bounds.bottom + 1) return null;
15644
+ }
15645
+ const nickname = nicknameLeaf(row);
15646
+ return nickname ? { row, image, name: nickname.name } : null;
15647
+ };
15648
+ let identifiedProfile = null;
15649
+ for (const candidate of doc.querySelectorAll(`[${profileMarker}]`)) {
15650
+ const image = candidate.querySelector(`img[${profileAvatarMarker}]`);
15651
+ const valid = candidate.getAttribute(profileProofMarker) === "footer-v1" && image ? checkProfile(candidate, image, false) : null;
15652
+ if (!identifiedProfile && valid) identifiedProfile = valid;
15653
+ else {
15654
+ candidate.removeAttribute(profileMarker);
15655
+ candidate.removeAttribute(profileProofMarker);
15656
+ }
15657
+ }
15658
+ const findVisibleProfile = () => {
15659
+ for (const image of track.querySelectorAll("img")) {
15660
+ if (image.closest("a[href]")) continue;
15661
+ const bounds = image.getBoundingClientRect();
15662
+ if (bounds.top < viewportHeight * 0.75 || bounds.height < 8 || bounds.height > 80 || bounds.width < 8 || bounds.width > 80) continue;
15663
+ for (let row = image.parentElement, depth = 0; row && row !== track && depth < 5; row = row.parentElement, depth++) {
15664
+ const valid = checkProfile(row, image, true);
15665
+ if (valid) return valid;
15666
+ }
15667
+ }
15668
+ return null;
15669
+ };
15670
+ if (!identifiedProfile) identifiedProfile = findVisibleProfile();
15671
+ if (!identifiedProfile && confirmedBoundary && trackRect.width === 0 && viewportHeight > 0) {
15672
+ const sheet = doc.getElementById(styleId)?.sheet;
15673
+ if (sheet) {
15674
+ const inlineStyle = track.getAttribute("style"), disabled = sheet.disabled;
15675
+ const width = Number(track.getAttribute(navigationWidthMarker)) || Number.parseFloat(getComputedStyle(track).width);
15676
+ try {
15677
+ track.style.setProperty("visibility", "hidden", "important");
15678
+ track.style.setProperty("pointer-events", "none", "important");
15679
+ track.style.setProperty("position", "fixed", "important");
15680
+ track.style.setProperty("left", "0px", "important");
15681
+ track.style.setProperty("top", "0px", "important");
15682
+ track.style.setProperty("height", `${viewportHeight}px`, "important");
15683
+ if (Number.isFinite(width) && width >= 160 && width <= 480) track.style.setProperty("width", `${width}px`, "important");
15684
+ sheet.disabled = true;
15685
+ identifiedProfile = findVisibleProfile();
15686
+ } finally {
15687
+ sheet.disabled = disabled;
15688
+ if (inlineStyle === null) track.removeAttribute("style");
15689
+ else track.setAttribute("style", inlineStyle);
15690
+ }
15691
+ }
15692
+ }
15693
+ const profile = identifiedProfile?.row ?? null;
15694
+ if (identifiedProfile) {
15695
+ profile.setAttribute(profileMarker, "");
15696
+ profile.setAttribute(profileProofMarker, "footer-v1");
15697
+ identifiedProfile.image.setAttribute(profileAvatarMarker, "");
15698
+ }
15699
+ const accountName = identifiedProfile?.name ?? null;
15700
+ const authenticated = identifiedProfile ? true : void 0;
15701
+ const settings = authenticated === true ? adaptWebsiteSettings(doc, profile, command) : void 0;
15587
15702
  const settingsRoot = doc.documentElement;
15588
15703
  const conversations = [];
15589
15704
  let group = "\u5BF9\u8BDD";
@@ -15616,6 +15731,7 @@ window.__ModuleLoader__.load({
15616
15731
  }
15617
15732
  if (command.type === "snapshot" && command.showOriginal) restore();
15618
15733
  else {
15734
+ if (trackRect.width >= 160 && trackRect.width <= 480) track.setAttribute(navigationWidthMarker, String(trackRect.width));
15619
15735
  track.setAttribute(marker, "");
15620
15736
  sidebar.setAttribute(marker, "");
15621
15737
  if (content && layout) {
@@ -15623,7 +15739,7 @@ window.__ModuleLoader__.load({
15623
15739
  content.setAttribute("data-dsh-chat-content", "");
15624
15740
  for (const candidate of content.querySelectorAll("div,header")) {
15625
15741
  const r = candidate.getBoundingClientRect();
15626
- if (r.top >= -1 && r.top <= 72 && r.height > 0 && r.height <= 80 && r.width <= 400 && candidate.querySelectorAll('button,[role="button"]').length >= 2 && candidate.querySelectorAll('button,[role="button"]').length <= 3 && candidate.querySelector("svg,img") && !candidate.querySelector('textarea,[contenteditable="true"]') && !candidate.textContent?.trim()) candidate.setAttribute("data-dsh-chat-web-chrome", "");
15742
+ if (r.top >= -1 && r.top <= 72 && r.height > 0 && r.height <= 80 && r.width <= 400 && candidate.querySelectorAll(iconButtonSelector).length >= 2 && candidate.querySelectorAll(iconButtonSelector).length <= 3 && candidate.querySelector("svg,img") && !candidate.querySelector('textarea,[contenteditable="true"]') && !candidate.textContent?.trim()) candidate.setAttribute("data-dsh-chat-web-chrome", "");
15627
15743
  }
15628
15744
  }
15629
15745
  const styleText = `html:not([data-dsh-chat-settings-request]) [${marker}],[data-dsh-chat-web-chrome]{display:none!important}
@@ -15639,12 +15755,12 @@ window.__ModuleLoader__.load({
15639
15755
  }
15640
15756
  const selected = conversations.find((item) => item.href === safeHref(page.pathname));
15641
15757
  if (!(command.type === "snapshot" && command.showOriginal)) adaptWebsiteHeader(doc, content, selected?.title ?? null, command.type === "snapshot" ? command.headerInset ?? (Number.parseInt(settingsRoot.style.getPropertyValue("--dsh-chat-title-inset")) || 24) : Number.parseInt(settingsRoot.style.getPropertyValue("--dsh-chat-title-inset")) || 24);
15642
- const ready = settingsRoot.hasAttribute("data-dsh-chat-dark-complete") || Boolean(settings.error) || command.type === "snapshot" && command.showOriginal;
15758
+ const ready = authenticated !== true || settingsRoot.hasAttribute("data-dsh-chat-dark-complete") || Boolean(settings?.error) || command.type === "snapshot" && command.showOriginal;
15643
15759
  if (ready) {
15644
15760
  settingsRoot.removeAttribute("data-dsh-chat-preparing");
15645
15761
  if (!(command.type === "snapshot" && command.showOriginal)) settingsRoot.setAttribute(presentedMarker, "");
15646
15762
  }
15647
- return { status: ready ? "ready" : "loading", authenticated, conversations, selectedHref: safeHref(page.pathname), canCreate: newChat !== null, error: null, accountName, settings };
15763
+ return { status: ready ? "ready" : "loading", ...authenticated === void 0 ? {} : { authenticated }, conversations, selectedHref: safeHref(page.pathname), canCreate: newChat !== null, error: null, accountName, settings };
15648
15764
  }
15649
15765
  function websiteCommandScript(command) {
15650
15766
  return `(() => { const adaptWebsiteSettings = ${adaptWebsiteSettings.toString()}; const adaptWebsiteHeader = ${adaptWebsiteHeader.toString()}; const dismissWebsiteEnvironmentNotice = ${dismissWebsiteEnvironmentNotice.toString()}; return (${adaptWebsiteNavigation.toString()})(document,location,${JSON.stringify(command)}); })()`;
@@ -15655,15 +15771,15 @@ window.__ModuleLoader__.load({
15655
15771
  if (!["loading", "ready", "sign-in", "unsupported"].includes(source.status) || !Array.isArray(source.conversations)) throw new Error("Invalid navigation response");
15656
15772
  const validHref = (href) => typeof href === "string" && /^https:\/\/chat\.deepseek\.com\/a\/chat\/s\/[a-zA-Z0-9-]+$/.test(href);
15657
15773
  const conversations = source.conversations.slice(0, 1e3).filter((item) => item && validHref(item.href) && typeof item.title === "string" && typeof item.group === "string").map((item) => ({ href: item.href, title: item.title.slice(0, 300), group: item.group.slice(0, 80) }));
15658
- const authenticated = source.status !== "sign-in" && (source.authenticated === true || source.authenticated === void 0 && source.status === "ready");
15774
+ const authenticated = source.status === "sign-in" ? false : source.authenticated === true ? true : source.authenticated === false ? false : void 0;
15659
15775
  return {
15660
15776
  status: source.status,
15661
- authenticated,
15662
- conversations: authenticated ? conversations : [],
15777
+ ...authenticated === void 0 ? {} : { authenticated },
15778
+ conversations: authenticated === true ? conversations : [],
15663
15779
  selectedHref: validHref(source.selectedHref) ? source.selectedHref : null,
15664
- accountName: authenticated && typeof source.accountName === "string" ? source.accountName.slice(0, 100) : null,
15780
+ accountName: authenticated === true && typeof source.accountName === "string" ? source.accountName.slice(0, 100) : null,
15665
15781
  settings: source.settings ? { language: typeof source.settings.language === "string" ? source.settings.language.slice(0, 80) : null, theme: typeof source.settings.theme === "string" ? source.settings.theme.slice(0, 80) : null, error: typeof source.settings.error === "string" ? source.settings.error.slice(0, 200) : null, pending: source.settings.pending === true, restored: source.settings.restored === true } : void 0,
15666
- canCreate: authenticated && source.canCreate === true,
15782
+ canCreate: authenticated === true && source.canCreate === true,
15667
15783
  error: typeof source.error === "string" ? source.error.slice(0, 300) : null
15668
15784
  };
15669
15785
  }
@@ -15788,12 +15904,12 @@ window.__ModuleLoader__.load({
15788
15904
  const retryGuestSession = (0, import_react2.useRef)(null);
15789
15905
  const lastReload = (0, import_react2.useRef)(state.websiteReloadRevision);
15790
15906
  (0, import_react2.useEffect)(() => {
15791
- if ((state.mode === "chat" && state.modeEnabled || state.settingsViewport) && state.authorizationStatus === "authorized") {
15907
+ if ((state.mode === "chat" && state.modeEnabled || state.settingsOpen) && state.authorizationStatus === "authorized") {
15792
15908
  setRequestedGeneration(state.authorizationGeneration);
15793
15909
  if (previousMode.current === "harness" && needsRecovery.current) setRecoveryRevision((value) => value + 1);
15794
15910
  }
15795
15911
  previousMode.current = state.mode;
15796
- }, [state.mode, state.modeEnabled, state.authorizationStatus, state.authorizationGeneration, state.settingsViewport]);
15912
+ }, [state.mode, state.modeEnabled, state.authorizationStatus, state.authorizationGeneration, state.settingsOpen]);
15797
15913
  (0, import_react2.useEffect)(() => {
15798
15914
  let stopped = false;
15799
15915
  let held;
@@ -15982,13 +16098,15 @@ window.__ModuleLoader__.load({
15982
16098
  if (snapshot.websiteAuthenticationStatus !== "signing-out") void bridge.clearWebsiteSession(generation);
15983
16099
  }
15984
16100
  } catch {
15985
- if (currentDocument()) {
16101
+ if (currentProjection()) {
15986
16102
  documentPresented = true;
15987
- bridge.reportWebsiteNavigation(generation, { ...emptyNavigation(), status: "unsupported" });
15988
- setPresentationReady(!snapshot.settingsViewport);
15989
- try {
15990
- await execute({ type: "restore" });
15991
- } catch {
16103
+ bridge.reportWebsiteNavigation(generation, { status: "unsupported", conversations: [], selectedHref: null, canCreate: false, error: null });
16104
+ setPresentationReady(!snapshot.settingsOpen);
16105
+ if (currentProjection()) {
16106
+ try {
16107
+ await execute({ type: "restore" });
16108
+ } catch {
16109
+ }
15992
16110
  }
15993
16111
  }
15994
16112
  }
@@ -16059,7 +16177,7 @@ window.__ModuleLoader__.load({
16059
16177
  }, { signal: events.signal });
16060
16178
  current.addEventListener("render-process-gone", () => {
16061
16179
  needsRecovery.current = true;
16062
- bridge.reportWebsiteNavigation(generation, { ...emptyNavigation(), status: "unsupported" });
16180
+ bridge.reportWebsiteNavigation(generation, { status: "unsupported", conversations: [], selectedHref: null, canCreate: false, error: null });
16063
16181
  report(false, "\u7F51\u9875\u8FDB\u7A0B\u5DF2\u9000\u51FA\uFF0C\u8BF7\u70B9\u51FB\u300C\u91CD\u8BD5\u7F51\u9875\u300D\u3002");
16064
16182
  }, { signal: events.signal });
16065
16183
  const offOpen = nativeBrowser.onOpenRequested(reservation.native.lease, (url2) => {
@@ -16105,14 +16223,14 @@ window.__ModuleLoader__.load({
16105
16223
  (0, import_react2.useEffect)(() => () => {
16106
16224
  guestEvents.current?.abort();
16107
16225
  }, []);
16108
- const inSettings = state.settingsViewport !== null;
16109
- const rect = inSettings && state.websiteNavigation.status !== "sign-in" ? { left: 0, top: 0, width: globalThis.innerWidth, height: globalThis.innerHeight } : state.settingsViewport ?? state.viewport;
16110
- const visible = (inSettings && state.websiteNavigation.status === "sign-in" && presentationReady || !inSettings && state.mode === "chat" && state.modeEnabled) && rect !== null;
16226
+ const inSettings = state.settingsOpen;
16227
+ const rect = inSettings ? state.viewport ?? { left: 0, top: 0, width: globalThis.innerWidth, height: globalThis.innerHeight } : state.viewport;
16228
+ const visible = !inSettings && state.mode === "chat" && state.modeEnabled && rect !== null && rect.width > 0 && rect.height > 0;
16111
16229
  const activeReservation = reservation !== null && reservation.generation === state.authorizationGeneration && reservation.storageKey === state.accountStorageKey ? reservation : null;
16112
16230
  const clearance = 0;
16113
16231
  const logoutError = state.websiteAuthenticationStatus === "error" && /退出/.test(state.websiteSessionError ?? "");
16114
16232
  return (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { id: "dsh-chat-website-surface", className: "dsh-chat-web-surface", "aria-label": "DeepSeek \u5B98\u7F51\u7F51\u9875", "aria-hidden": !visible, style: {
16115
- zIndex: inSettings ? visible ? 1001 : 0 : 14,
16233
+ zIndex: inSettings ? 0 : 14,
16116
16234
  visibility: visible ? "visible" : "hidden",
16117
16235
  display: (inSettings || state.mode === "chat") && rect ? "flex" : "none",
16118
16236
  opacity: visible ? 1 : 0,
@@ -16121,7 +16239,7 @@ window.__ModuleLoader__.load({
16121
16239
  top: (rect?.top ?? 0) + clearance,
16122
16240
  width: rect?.width ?? 0,
16123
16241
  height: Math.max(0, (rect?.height ?? 0) - clearance),
16124
- borderRadius: inSettings ? 12 : 0,
16242
+ borderRadius: 0,
16125
16243
  overflow: "hidden"
16126
16244
  }, children: [
16127
16245
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DshChatStyles, {}),
@@ -16144,7 +16262,7 @@ window.__ModuleLoader__.load({
16144
16262
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: nativeBrowser === void 0 ? "\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u5185\u5D4C\u7F51\u9875" : state.webError !== null ? "\u7F51\u9875\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528" : logoutError ? "\u9000\u51FA\u767B\u5F55\u672A\u5B8C\u6210" : state.websiteAuthenticationStatus === "signed-out" ? "\u767B\u5F55 DeepSeek Chat" : state.websiteAuthenticationStatus === "signing-out" ? "\u6B63\u5728\u9000\u51FA\u767B\u5F55" : "\u6B63\u5728\u6253\u5F00 DeepSeek \u5B98\u7F51" }),
16145
16263
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: state.webError || (logoutError ? state.websiteSessionError : nativeBrowser === void 0 ? "\u9700\u8981\u63D0\u4F9B\u5B98\u65B9\u6D4F\u89C8\u5668\u80FD\u529B\u7684 DSH \u684C\u9762\u7248\u3002" : state.websiteAuthenticationStatus === "signing-out" ? "\u6B63\u5728\u6E05\u9664\u767B\u5F55\u8BB0\u5FC6\u5E76\u9000\u51FA\u5B98\u7F51\u3002" : "CHAT \u4F7F\u7528\u72EC\u7ACB\u7684\u5B98\u7F51\u767B\u5F55\uFF0C\u767B\u5F55\u540E\u81EA\u52A8\u540C\u6B65\u8D26\u53F7\u548C\u5B98\u7F51\u5BF9\u8BDD\u3002") }),
16146
16264
  logoutError && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.logoutWebsite(), children: "\u91CD\u8BD5\u9000\u51FA\u767B\u5F55" }),
16147
- state.websiteAuthenticationStatus === "signed-out" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.beginWebsiteSignIn(), children: "\u767B\u5F55 DeepSeek" }),
16265
+ state.websiteAuthenticationStatus === "signed-out" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-chat-primary-button", onClick: () => bridge.beginWebsiteSignIn(), children: "\u767B\u5F55 DeepSeek" }),
16148
16266
  state.authorizationStatus !== "authorized" && nativeBrowser !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.refreshAuthorization(), children: "\u91CD\u8BD5\u8FDE\u63A5" }),
16149
16267
  state.webError !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-chat-text-button", onClick: () => bridge.reloadWebsite(), disabled: nativeBrowser === void 0 || !state.modeEnabled, children: "\u91CD\u8BD5\u7F51\u9875" })
16150
16268
  ] })
@@ -16262,7 +16380,7 @@ window.__ModuleLoader__.load({
16262
16380
  let webLoading = false;
16263
16381
  let webError = null;
16264
16382
  let connectionError = null;
16265
- let settingsViewport = null;
16383
+ let settingsOpen = false;
16266
16384
  let settingsReadRequested = false;
16267
16385
  let preferenceError = null;
16268
16386
  let preferences = null;
@@ -16337,7 +16455,7 @@ window.__ModuleLoader__.load({
16337
16455
  desktopAvailable: Boolean(nativeBrowser),
16338
16456
  webLoading,
16339
16457
  webError,
16340
- settingsViewport,
16458
+ settingsOpen,
16341
16459
  preferenceError,
16342
16460
  viewport,
16343
16461
  brandAnchor,
@@ -16591,7 +16709,7 @@ window.__ModuleLoader__.load({
16591
16709
  },
16592
16710
  beginWebsiteSignIn: () => {
16593
16711
  if (disposed || !nativeBrowser || logoutRequested) return;
16594
- if (mode.getSnapshot().mode !== "chat" && !settingsViewport) mode.select("chat");
16712
+ if (mode.getSnapshot().mode !== "chat") mode.select("chat");
16595
16713
  restorationBlocked = true;
16596
16714
  if (!websiteSignInRequested) websiteAuthenticationRevision++;
16597
16715
  websiteSignInRequested = true;
@@ -16643,7 +16761,14 @@ window.__ModuleLoader__.load({
16643
16761
  try {
16644
16762
  next = parseWebsiteNavigation(value);
16645
16763
  } catch {
16646
- next = { ...emptyNavigation(), status: "unsupported" };
16764
+ next = { status: "unsupported", conversations: [], selectedHref: null, canCreate: false, error: null };
16765
+ }
16766
+ const previousNavigation = websiteNavigation;
16767
+ if (next.status === "unsupported" && !logoutRequested && !logoutFailed) {
16768
+ if (restoringPreferences || previousNavigation.settings?.pending) preferencesGeneration = -1;
16769
+ restoringPreferences = false;
16770
+ restorationSeen = false;
16771
+ settingsReadRequested = false;
16647
16772
  }
16648
16773
  if (newDocument || next.status === "sign-in") {
16649
16774
  preferencesGeneration = -1;
@@ -16651,6 +16776,9 @@ window.__ModuleLoader__.load({
16651
16776
  restorationSeen = false;
16652
16777
  settingsReadRequested = false;
16653
16778
  }
16779
+ if (newDocument && next.authenticated !== true && next.status !== "sign-in" && !logoutRequested && !logoutFailed) {
16780
+ websiteAuthenticationStatus = websiteSignInRequested ? "signing-in" : "loading";
16781
+ }
16654
16782
  if (next.status === "sign-in") {
16655
16783
  if (websiteHadSession || logoutRequested) restorationBlocked = true;
16656
16784
  if (logoutVaultCleared) {
@@ -16674,7 +16802,7 @@ window.__ModuleLoader__.load({
16674
16802
  publish();
16675
16803
  return;
16676
16804
  } else {
16677
- websiteNavigation = next;
16805
+ websiteNavigation = !newDocument && next.authenticated !== true && previousNavigation.authenticated === true ? { ...next, status: next.status === "ready" ? "loading" : next.status, authenticated: true, accountName: previousNavigation.accountName, settings: next.settings ?? (previousNavigation.settings && { ...previousNavigation.settings, pending: next.status === "unsupported" ? false : previousNavigation.settings.pending }) } : next;
16678
16806
  if (next.authenticated === true) {
16679
16807
  if (!websiteHadSession && !logoutFailed) restorationBlocked = false;
16680
16808
  if (!websiteHadSession) websiteAuthenticationRevision++;
@@ -16684,8 +16812,7 @@ window.__ModuleLoader__.load({
16684
16812
  logoutVaultCleared = false;
16685
16813
  websiteAuthenticationStatus = logoutFailed ? "error" : "signed-in";
16686
16814
  if (!logoutFailed && websiteSessionStatus !== "error") websiteSessionError = null;
16687
- } else if (next.status === "unsupported") websiteAuthenticationStatus = "error";
16688
- else if (!websiteHadSession) websiteAuthenticationStatus = websiteSignInRequested ? "signing-in" : "loading";
16815
+ } else if (!websiteHadSession) websiteAuthenticationStatus = websiteSignInRequested ? "signing-in" : "loading";
16689
16816
  }
16690
16817
  const settings = websiteNavigation.settings;
16691
16818
  if (restoringPreferences && settings?.restored === false) restorationSeen = true;
@@ -16693,7 +16820,7 @@ window.__ModuleLoader__.load({
16693
16820
  if (settings?.error && !settings.pending) restoringPreferences = false;
16694
16821
  restorePreferences();
16695
16822
  readSettingsWhenReady();
16696
- if (!restoringPreferences && settings?.restored && !settings.pending && !settings.error && !logoutFailed) {
16823
+ if (websiteNavigation.status === "ready" && !restoringPreferences && settings?.restored && !settings.pending && !settings.error && !logoutFailed) {
16697
16824
  const language = /中文|Chinese/i.test(settings.language ?? "") ? "zh-CN" : /English|英语/i.test(settings.language ?? "") ? "en" : /^(System|跟随系统|系统|Follow system)$/i.test(settings.language ?? "") ? "system" : "";
16698
16825
  if (language) persistPreference("language", language);
16699
16826
  }
@@ -16712,6 +16839,7 @@ window.__ModuleLoader__.load({
16712
16839
  commandWebsite: (command) => {
16713
16840
  if (disposed || !mode.canEnter() || !navigationHandler) return;
16714
16841
  if ((logoutRequested || logoutFailed) && command.type !== "logout" && command.type !== "snapshot") return;
16842
+ if (websiteNavigation.status !== "ready" && command.type !== "logout" && command.type !== "snapshot" && command.type !== "restore") return;
16715
16843
  if (command.type === "settings-read" && (restoringPreferences || websiteNavigation.settings?.pending)) return;
16716
16844
  if (command.type === "open" && !websiteNavigation.conversations.some((item) => item.href === command.href)) return;
16717
16845
  if (command.type === "settings-read" || command.type === "setting" || command.type === "preferences" || command.type === "logout") {
@@ -16724,17 +16852,18 @@ window.__ModuleLoader__.load({
16724
16852
  showWebsiteNavigation = !showWebsiteNavigation;
16725
16853
  publish();
16726
16854
  },
16727
- updateSettingsViewport: (next) => {
16728
- if (settingsViewport?.left === next?.left && settingsViewport?.top === next?.top && settingsViewport?.width === next?.width && settingsViewport?.height === next?.height) return;
16729
- const opening = !settingsViewport && !!next;
16855
+ setSettingsOpen: (next) => {
16856
+ if (settingsOpen === next) return;
16857
+ const opening = !settingsOpen && next;
16730
16858
  if (opening) settingsReadRequested = false;
16731
- settingsViewport = next;
16859
+ settingsOpen = next;
16732
16860
  publish();
16733
16861
  if (!next && navigationHandler) void navigationHandler({ type: "settings-close" });
16734
16862
  else readSettingsWhenReady();
16735
16863
  },
16736
16864
  logoutWebsite: () => {
16737
16865
  if (logoutRequested || !navigationHandler || !websiteHadSession && !logoutFailed) return;
16866
+ if (!logoutFailed && websiteNavigation.status !== "ready") return;
16738
16867
  const generation = authorizationGeneration;
16739
16868
  const handler = navigationHandler;
16740
16869
  clearTimeout(logoutTimer);
@@ -16864,13 +16993,13 @@ window.__ModuleLoader__.load({
16864
16993
  publish();
16865
16994
  }
16866
16995
  function readSettingsWhenReady() {
16867
- if (!settingsViewport || !navigationHandler || websiteNavigation.authenticated !== true || settingsReadRequested || restoringPreferences || logoutRequested || logoutFailed || websiteNavigation.settings?.pending) return;
16996
+ if (!settingsOpen || !navigationHandler || websiteNavigation.status !== "ready" || websiteNavigation.authenticated !== true || settingsReadRequested || restoringPreferences || logoutRequested || logoutFailed || websiteNavigation.settings?.pending) return;
16868
16997
  settingsReadRequested = true;
16869
16998
  if (websiteNavigation.settings?.language && !websiteNavigation.settings.error) return;
16870
16999
  void navigationHandler({ type: "settings-read" });
16871
17000
  }
16872
17001
  function restorePreferences() {
16873
- if (!preferences || !navigationHandler || websiteNavigation.authenticated !== true || preferencesGeneration === authorizationGeneration || logoutRequested || logoutFailed || websiteNavigation.settings?.pending) return;
17002
+ if (!preferences || !navigationHandler || websiteNavigation.status !== "ready" || websiteNavigation.authenticated !== true || preferencesGeneration === authorizationGeneration || logoutRequested || logoutFailed || websiteNavigation.settings?.pending) return;
16874
17003
  const language = preferences.language || DEFAULT_WEBSITE_LANGUAGE;
16875
17004
  preferencesGeneration = authorizationGeneration;
16876
17005
  restoringPreferences = true;
package/lib/types/ui.d.ts CHANGED
@@ -22,7 +22,7 @@ export interface DshChatViewState {
22
22
  readonly accountStorageKey: string | null;
23
23
  readonly authorizationGeneration: number;
24
24
  readonly websiteReloadRevision: number;
25
- readonly settingsViewport: DshChatViewportRect | null;
25
+ readonly settingsOpen: boolean;
26
26
  readonly preferenceError: string | null;
27
27
  readonly websiteAuthenticationStatus: 'loading' | 'signed-out' | 'signing-in' | 'signed-in' | 'signing-out' | 'error';
28
28
  readonly websiteAuthenticationRevision: number;
@@ -55,7 +55,7 @@ export interface DshChatUIBridge {
55
55
  bindWebsiteNavigation(generation: number, handler: (command: WebsiteCommand) => Promise<void>): () => void;
56
56
  commandWebsite(command: WebsiteCommand): void;
57
57
  toggleWebsiteNavigation(): void;
58
- updateSettingsViewport(rect: DshChatViewportRect | null): void;
58
+ setSettingsOpen(open: boolean): void;
59
59
  logoutWebsite(): void;
60
60
  loadWebsiteSession(generation: number): Promise<WebsiteSession | null>;
61
61
  saveWebsiteSession(generation: number, session: WebsiteSession): Promise<boolean>;
@@ -81,4 +81,4 @@ export declare function DshChatChatNavigation({ bridge, wide, expandSidebar }: P
81
81
  export declare function DshChatChatPanel({ bridge }: PropsRuntime<'main'> & DshChatBridgeProps): import("react/jsx-runtime").JSX.Element;
82
82
  /** Same public primitive icons, geometry and tooltip behavior as native rc.2 chrome. */
83
83
  export declare function DshChatLeadingControls({ bridge }: PropsRuntime<'shell.leading'> & DshChatBridgeProps): import("react/jsx-runtime").JSX.Element;
84
- export declare function DshChatChatSettings({ bridge }: PropsRuntime<'settings.section'> & DshChatBridgeProps): import("react/jsx-runtime").JSX.Element;
84
+ export declare function DshChatChatSettings({ bridge, close }: PropsRuntime<'settings.section'> & DshChatBridgeProps): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-deepseek-chat",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "CHAT / HARNESS mode switcher for DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",