dsh-desktop-enhance 0.6.8 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/client.js +163 -7
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -9,6 +9,7 @@ window.__ModuleLoader__.load({
9
9
  //#endregion
10
10
  //#region src/client/mobile/strings.ts
11
11
  const mobileZh = {
12
+ "mobile.settings.back": "‹ 设置",
12
13
  "mobile.connection.connecting": "正在重连",
13
14
  "mobile.connection.disconnected": "连接已断开",
14
15
  "mobile.connection.connected": "已连接",
@@ -17,6 +18,7 @@ window.__ModuleLoader__.load({
17
18
  "mobile.writeFailed": "无法保存鲸鱼位置,请检查浏览器存储权限后重试。"
18
19
  };
19
20
  const mobileEn = {
21
+ "mobile.settings.back": "‹ Settings",
20
22
  "mobile.connection.connecting": "Reconnecting",
21
23
  "mobile.connection.disconnected": "Disconnected",
22
24
  "mobile.connection.connected": "Connected",
@@ -6945,6 +6947,90 @@ window.__ModuleLoader__.load({
6945
6947
  }, t("remote.revoke"))))), status.devices.length === 0 ? h("p", { className: "de-remote-empty" }, t("remote.noDevices")) : null))) : null));
6946
6948
  }
6947
6949
  //#endregion
6950
+ //#region src/client/mobile/settings.ts
6951
+ const root = "[data-shortcut-modal=\"settings\"][role=\"dialog\"]";
6952
+ const panel = `body.dsh-remote-portrait ${root}`;
6953
+ const MOBILE_SETTINGS_CSS = [
6954
+ `${panel}{width:100%;max-width:100%;height:var(--desktop-enhance-viewport-height,100dvh);max-height:var(--desktop-enhance-viewport-height,100dvh);border-radius:0;box-shadow:none}`,
6955
+ `body.dsh-remote-portrait [role="presentation"]:has(> ${root}){top:var(--desktop-enhance-viewport-top,0px);bottom:auto;height:var(--desktop-enhance-viewport-height,100dvh)}`,
6956
+ `${panel}[data-desktop-enhance-settings-view]{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);box-sizing:border-box}`,
6957
+ `${panel}[data-desktop-enhance-settings-view] > nav,${panel}[data-desktop-enhance-settings-view] > [class$="_content"]{display:contents}`,
6958
+ `${panel}[data-desktop-enhance-settings-view] > nav > [class$="_navTitle"]{display:flex;align-items:center;grid-area:1/1;padding:0 16px;pointer-events:none;font-size:17px;font-weight:600;max-width:40%;min-width:0}`,
6959
+ `${panel}[data-desktop-enhance-settings-view] > nav > [class$="_navList"]{grid-area:2/1;display:flex;flex-direction:column;gap:4px;min-height:0;padding:12px 16px;overflow:auto;overscroll-behavior:contain}`,
6960
+ `${panel}[data-desktop-enhance-settings-view] > nav > [class$="_navList"] > button{height:auto;min-height:52px;width:100%;flex:none;padding:12px 14px;gap:12px;border-radius:10px;font-size:15px}`,
6961
+ `${panel}[data-desktop-enhance-settings-view] > nav > [class$="_navList"] > button > span{font-size:15px;white-space:normal;overflow-wrap:anywhere}`,
6962
+ `${panel}[data-desktop-enhance-settings-view] > nav > [class$="_navList"] > button::after{content:'›';margin-left:auto;font-size:22px;color:var(--dsw-alias-label-secondary)}`,
6963
+ `${panel}[data-desktop-enhance-settings-view] > [class$="_content"] > [class$="_header"]{grid-area:1/1;display:flex;justify-content:flex-end;align-items:center;gap:8px;min-height:56px;padding:6px 12px;box-sizing:border-box;border-bottom:1px solid var(--dsw-alias-border-l2)}`,
6964
+ `${panel}[data-desktop-enhance-settings-view] > [class$="_content"] > [class$="_options"]{grid-area:2/1;min-width:0;min-height:0;padding:16px;overflow:auto;overscroll-behavior:contain}`,
6965
+ `${panel}[data-desktop-enhance-settings-view="list"] > [class$="_content"] > [class$="_options"],${panel}[data-desktop-enhance-settings-view="list"] [data-desktop-enhance-settings-back]{display:none}`,
6966
+ `${panel}[data-desktop-enhance-settings-view="detail"] > nav > :is([class$="_navList"],[class$="_navTitle"]){display:none}`,
6967
+ `${panel} [data-desktop-enhance-settings-back]{border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;min-height:44px;padding:0 12px;margin-right:auto;cursor:pointer;white-space:nowrap}`,
6968
+ `${panel} > [class$="_content"] > [class$="_header"] button{min-height:44px;min-width:44px;flex-shrink:0;white-space:nowrap}`,
6969
+ `${panel} [class$="_rowHead"]{flex-wrap:wrap;gap:10px}`,
6970
+ `${panel} [class$="_rowHead"] > [class$="_rowIdentity"]{flex:1 1 100%;min-width:0;overflow-wrap:anywhere}`,
6971
+ `${panel} [class$="_rowActions"]{flex-wrap:wrap;gap:8px;min-width:0}`,
6972
+ `${panel} [class$="_rowActions"] button{min-height:44px;min-width:44px;padding:8px 12px;flex-shrink:0;white-space:nowrap}`,
6973
+ `${panel} :is(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),select){box-sizing:border-box;min-width:0;max-width:100%;min-height:44px;font-size:16px}`,
6974
+ `${panel} textarea{box-sizing:border-box;max-width:100%;min-height:88px;font-size:16px}`,
6975
+ `${panel} button:is([class$="_primaryButton"],[class$="_secondaryButton"],[class$="_dangerButton"]){min-height:44px;min-width:44px;flex-shrink:0;white-space:nowrap}`,
6976
+ `${panel} [class*="_field_"]{min-width:0}`,
6977
+ `${panel} [class*="_field_"] > [class*="_head_"],${panel} [class*="_form_"] > [class*="_footer_"]{flex-wrap:wrap;gap:8px}`,
6978
+ `${panel} [class*="_field_"] > input{box-sizing:border-box;width:100%;min-width:0;min-height:44px;font-size:16px}`,
6979
+ `${panel} [class*="_field_"] button,${panel} [class*="_form_"] > [class*="_footer_"] button{min-height:44px;min-width:44px;white-space:nowrap}`,
6980
+ `${panel} [data-slot="settings.general.item"] > *{flex-wrap:wrap;gap:12px;min-width:0}`,
6981
+ `${panel} [data-slot="settings.general.item"] > * > :first-child:not(button){min-width:0}`,
6982
+ `${panel} [data-slot="settings.general.item"] > * > button:not([role="switch"]){min-height:44px;max-width:100%;white-space:nowrap}`
6983
+ ];
6984
+ function mountMobileSettings(backLabel) {
6985
+ const mounted = new Map();
6986
+ function sync() {
6987
+ for (const [element, dispose] of mounted) if (!element.isConnected) {
6988
+ dispose();
6989
+ mounted.delete(element);
6990
+ }
6991
+ for (const element of globalThis.document.querySelectorAll(root)) {
6992
+ if (mounted.has(element)) continue;
6993
+ const nav = element.querySelector(":scope > nav > [class$=\"_navList\"]");
6994
+ const header = element.querySelector(":scope > [class$=\"_content\"] > [class$=\"_header\"]");
6995
+ if (!nav || !header) continue;
6996
+ const back = globalThis.document.createElement("button");
6997
+ back.type = "button";
6998
+ back.setAttribute("data-desktop-enhance-settings-back", "");
6999
+ back.textContent = backLabel();
7000
+ const showList = () => {
7001
+ element.setAttribute("data-desktop-enhance-settings-view", "list");
7002
+ nav.querySelector("[aria-current=\"true\"]")?.focus();
7003
+ };
7004
+ const select = (event) => {
7005
+ const target = event.target;
7006
+ if (!(target instanceof globalThis.Element)) return;
7007
+ const button = target.closest("button");
7008
+ if (!button || button.parentElement !== nav || button.disabled) return;
7009
+ element.setAttribute("data-desktop-enhance-settings-view", "detail");
7010
+ back.focus();
7011
+ };
7012
+ back.addEventListener("click", showList);
7013
+ nav.addEventListener("click", select);
7014
+ header.prepend(back);
7015
+ element.setAttribute("data-desktop-enhance-settings-view", "list");
7016
+ mounted.set(element, () => {
7017
+ back.removeEventListener("click", showList);
7018
+ nav.removeEventListener("click", select);
7019
+ back.remove();
7020
+ element.removeAttribute("data-desktop-enhance-settings-view");
7021
+ });
7022
+ }
7023
+ }
7024
+ const observer = new globalThis.MutationObserver(sync);
7025
+ observer.observe(globalThis.document.body, { childList: true });
7026
+ sync();
7027
+ return () => {
7028
+ observer.disconnect();
7029
+ for (const dispose of mounted.values()) dispose();
7030
+ mounted.clear();
7031
+ };
7032
+ }
7033
+ //#endregion
6948
7034
  //#region src/client/mobile/styles.ts
6949
7035
  const ADAPT_CSS = [
6950
7036
  "html:has(body.dsh-remote-portrait){overflow:hidden;overscroll-behavior:none}",
@@ -6989,6 +7075,20 @@ window.__ModuleLoader__.load({
6989
7075
  `body.dsh-remote-portrait [class$="_crumb"]{max-width:none;padding:2px 4px;font-size:13.5px}`,
6990
7076
  `body.dsh-remote-portrait header[class*="_header"] [class$="_headerActions"]{margin-left:auto;gap:4px}`,
6991
7077
  `body.dsh-remote-portrait header[class*="_header"] [class$="_headerActions"] button{height:24px;min-height:24px;font-size:11px;padding:0 6px}`,
7078
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]){padding-top:0 !important}`,
7079
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]) [class$="_titleRow"]{height:40px;min-height:40px;align-items:center;gap:4px}`,
7080
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]) [class$="_titleCluster"]{flex:1;min-width:0;flex-wrap:nowrap;gap:4px;align-items:center}`,
7081
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]) [class$="_crumbs"]{flex:1;min-width:0;max-width:100%}`,
7082
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]) [class$="_headerActions"]{flex:none;margin-left:0;flex-wrap:nowrap;gap:0}`,
7083
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]) [class$="_tabs"]{height:28px;box-sizing:border-box;margin-top:0}`,
7084
+ `body.dsh-remote-portrait header:has([data-slot="conversation.session.header"]) button[data-desktop-enhance-mobile-header-action]{position:relative;height:40px;min-height:40px;padding:0 4px;gap:4px;border:0;background:transparent;font-variant-numeric:tabular-nums}`,
7085
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-count]{font-size:0 !important;margin:0}`,
7086
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-count]::after{content:attr(data-desktop-enhance-mobile-header-count);font-size:12px}`,
7087
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-action] > svg{display:none}`,
7088
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-action]::before{content:"";width:17px;height:17px;flex:none;background:currentColor;mask:var(--desktop-enhance-header-icon) center/contain no-repeat}`,
7089
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-action="subagent"]{--desktop-enhance-header-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.65' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 20v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M16 3a4 4 0 0 1 0 8M22 20v-2a4 4 0 0 0-3-3.87'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3C/svg%3E")}`,
7090
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-action="jobs"]{--desktop-enhance-header-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.65' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='15' rx='3'/%3E%3Cpath d='M9 5V3h6v2M9 10l3 3-3 3M15 16h2'/%3E%3C/svg%3E")}`,
7091
+ `body.dsh-remote-portrait [data-desktop-enhance-mobile-header-action] > [class$="_activitySlot"],body.dsh-remote-portrait [data-desktop-enhance-mobile-header-action] > [class$="_triggerDot"]{position:absolute;left:17px;top:8px;transform:scale(.7);transform-origin:center}`,
6992
7092
  `#dshRemoteWhale{position:fixed;top:calc(4px + env(safe-area-inset-top));left:calc(8px + env(safe-area-inset-left));z-index:2147482999;width:34px;height:34px;min-width:34px;padding:0;border-radius:10px;background:var(--dsw-alias-bg-module-platform);border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 1px 6px rgba(0,0,0,.25);touch-action:none}`,
6993
7093
  `#dshRemoteWhale{translate:0 var(--desktop-enhance-viewport-top,0px)}`,
6994
7094
  `#dshRemoteWhale svg{width:20px;height:15px;display:block}`,
@@ -7047,15 +7147,63 @@ window.__ModuleLoader__.load({
7047
7147
  `body.dsh-remote-portrait [data-dsh-plugin="pet"],`,
7048
7148
  `body.dsh-remote-portrait [data-dsh-plugin="usage"]{display:none !important}`,
7049
7149
  `body.dsh-remote-portrait [class$="_overlayLayer"] [class$="_workbench"]{display:none !important}`,
7050
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"]{flex-direction:column;max-height:calc(100dvh - 32px)}`,
7051
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"] [class$="_nav"]{flex-direction:row;gap:4px;width:100%;padding:12px 12px 0;overflow-x:auto;overflow-y:hidden}`,
7052
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"] [class$="_navTitle"]{display:none}`,
7053
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"] [class$="_navList"]{flex-direction:row;gap:4px}`,
7054
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"] [class$="_navCell"]{height:34px;padding:0 12px;gap:6px;flex:none;border-radius:10px}`,
7055
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"] [class$="_navLabel"]{font-size:13px}`,
7056
- `body.dsh-remote-portrait [class$="_overlay"] [class$="_panel"] [class$="_content"]{flex:1;min-height:0}`
7150
+ ...MOBILE_SETTINGS_CSS
7057
7151
  ];
7058
7152
  //#endregion
7153
+ //#region src/client/mobile/header.ts
7154
+ const HEADER = ":is([data-slot=\"conversation.session.header.actions\"], [data-slot=\"conversation.session.header.lineage\"])";
7155
+ const ACTION = "data-desktop-enhance-mobile-header-action";
7156
+ const COUNT = "data-desktop-enhance-mobile-header-count";
7157
+ const subagentLabel = /^(?:\d+ 个子智能体(?:,正在运行)?|\d+ subagents?(?: running)?)$/;
7158
+ const jobsLabel = /^(?:\d+ 个后台任务(?:运行中)?|\d+ background jobs?(?: running)?)$/;
7159
+ function mountMobileHeader() {
7160
+ const marked = new Map();
7161
+ function clear(button, span) {
7162
+ button.removeAttribute(ACTION);
7163
+ span.removeAttribute(COUNT);
7164
+ }
7165
+ function sync() {
7166
+ const current = new Map();
7167
+ for (const button of globalThis.document.querySelectorAll(`${HEADER} button`)) {
7168
+ const label = button.getAttribute("aria-label") ?? "";
7169
+ const kind = subagentLabel.test(label) ? "subagent" : jobsLabel.test(label) ? "jobs" : null;
7170
+ if (!kind) continue;
7171
+ if (kind === "subagent" && button.getAttribute("aria-haspopup") !== "tree") continue;
7172
+ const span = button.querySelector(kind === "subagent" ? ":scope > span:not([class$=\"_activitySlot\"]):not([class$=\"_switcherTitle\"])" : ":scope > span[class$=\"_count\"]");
7173
+ const text = span?.textContent?.trim() ?? "";
7174
+ if (!span || !(kind === "subagent" ? subagentLabel : jobsLabel).test(text)) continue;
7175
+ const count = Number.parseInt(text, 10);
7176
+ const display = count > 99 ? "99+" : String(count);
7177
+ if (button.getAttribute(ACTION) !== kind) button.setAttribute(ACTION, kind);
7178
+ if (span.getAttribute(COUNT) !== display) span.setAttribute(COUNT, display);
7179
+ current.set(button, span);
7180
+ }
7181
+ for (const [button, span] of marked) if (!current.has(button)) clear(button, span);
7182
+ else if (current.get(button) !== span) span.removeAttribute(COUNT);
7183
+ marked.clear();
7184
+ for (const [button, span] of current) marked.set(button, span);
7185
+ }
7186
+ const observer = new globalThis.MutationObserver((records) => {
7187
+ if (records.some((record) => {
7188
+ if ((record.target instanceof globalThis.Element ? record.target : record.target.parentElement)?.closest(HEADER)) return true;
7189
+ return [...record.addedNodes, ...record.removedNodes].some((node) => node instanceof globalThis.Element && (node.matches(HEADER) || node.querySelector(HEADER)));
7190
+ })) sync();
7191
+ });
7192
+ observer.observe(globalThis.document.body, {
7193
+ childList: true,
7194
+ subtree: true,
7195
+ characterData: true,
7196
+ attributes: true,
7197
+ attributeFilter: ["aria-label"]
7198
+ });
7199
+ sync();
7200
+ return () => {
7201
+ observer.disconnect();
7202
+ for (const [button, span] of marked) clear(button, span);
7203
+ marked.clear();
7204
+ };
7205
+ }
7206
+ //#endregion
7059
7207
  //#region src/client/mobile/index.ts
7060
7208
  function initMobileAdapt(actions) {
7061
7209
  let disposed = false;
@@ -7115,6 +7263,8 @@ window.__ModuleLoader__.load({
7115
7263
  const FISH_PATH = "M22.9168 1.43018C22.6713 1.31018 22.5658 1.53918 22.4223 1.65519C22.3733 1.69269 22.3318 1.74169 22.2903 1.78669C21.9317 2.1697 21.5127 2.42121 20.9657 2.39121C20.1657 2.34621 19.4827 2.59771 18.8787 3.20973C18.7502 2.45521 18.3236 2.0047 17.6746 1.71569C17.3351 1.56568 16.9916 1.41518 16.7536 1.08867C16.5876 0.856163 16.5421 0.597155 16.4591 0.341647C16.4061 0.187643 16.3536 0.0301382 16.1761 0.00363739C15.9836 -0.0263635 15.9081 0.135141 15.8326 0.270145C15.5306 0.822162 15.4136 1.43018 15.4251 2.0462C15.4516 3.43174 16.0366 4.53527 17.1991 5.3203C17.3311 5.4103 17.3651 5.5003 17.3236 5.63181C17.2441 5.90231 17.1501 6.16482 17.0671 6.43533C17.0141 6.60784 16.9351 6.64584 16.7501 6.57033C16.1121 6.30383 15.5611 5.90931 15.074 5.4328C14.2475 4.63328 13.5 3.75075 12.568 3.05973C12.349 2.89822 12.13 2.74822 11.9034 2.60522C10.9524 1.68169 12.028 0.923165 12.277 0.833162C12.5375 0.739159 12.3675 0.41615 11.5259 0.42015C10.6844 0.42365 9.91439 0.705658 8.93286 1.08117C8.78935 1.13767 8.63835 1.17867 8.48384 1.21267C7.59332 1.04367 6.66829 1.00617 5.70226 1.11517C3.88321 1.31768 2.43016 2.1777 1.36213 3.64575C0.0790928 5.4103 -0.222916 7.41536 0.146595 9.50642C0.535106 11.7105 1.66014 13.535 3.38869 14.9616C5.18125 16.4406 7.24581 17.1657 9.60138 17.0266C11.0319 16.9441 12.6245 16.7526 14.421 15.2321C14.874 15.4576 15.3496 15.5476 16.1381 15.6151C16.7456 15.6716 17.3306 15.5851 17.7836 15.4911C18.4931 15.3411 18.4441 14.6841 18.1876 14.5636C16.1081 13.595 16.5646 13.9891 16.1496 13.67C17.2061 12.42 18.8202 10.1979 19.3182 7.17235C19.3672 6.83834 19.4297 6.36783 19.4222 6.09732C19.4182 5.93231 19.4562 5.86831 19.6447 5.84931C20.1657 5.78931 20.6712 5.64681 21.1357 5.3913C22.4833 4.65528 23.0268 3.44624 23.1548 1.9972C23.1738 1.77569 23.1508 1.54668 22.9168 1.43018Z";
7116
7264
  const surfaceText = (key, fallback) => actions.t(key) || fallback;
7117
7265
  let active = false;
7266
+ let disposeSettings = null;
7267
+ let disposeHeader = null;
7118
7268
  let savedViewportContent = null;
7119
7269
  let whaleEl = null;
7120
7270
  let connectionStatus = "unknown";
@@ -7186,6 +7336,8 @@ window.__ModuleLoader__.load({
7186
7336
  forgetAbsentSelectors();
7187
7337
  globalThis.document.body.classList.add(ACTIVE_CLASS);
7188
7338
  ensureAdaptStyle();
7339
+ disposeSettings = mountMobileSettings(() => actions.t("mobile.settings.back"));
7340
+ disposeHeader = mountMobileHeader();
7189
7341
  const meta = globalThis.document.querySelector("meta[name=viewport]");
7190
7342
  if (meta instanceof globalThis.HTMLMetaElement && meta.getAttribute("content") !== null && !(meta.getAttribute("content") ?? "").includes("viewport-fit")) {
7191
7343
  savedViewportContent = meta.getAttribute("content");
@@ -7199,6 +7351,10 @@ window.__ModuleLoader__.load({
7199
7351
  function revert() {
7200
7352
  if (!active) return;
7201
7353
  active = false;
7354
+ disposeSettings?.();
7355
+ disposeSettings = null;
7356
+ disposeHeader?.();
7357
+ disposeHeader = null;
7202
7358
  clearLongPress();
7203
7359
  cancelTimeouts();
7204
7360
  restoreActionStyles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-desktop-enhance",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "DSH Desktop 界面增强:页内查找(Cmd+F)、轮次编号、上下文压缩行常显、建议、每步耗时、折叠文件夹状态计数、会话信息(含上下文注入 C1 视图)、工具管理、Skill 管理、独立远程接入与手机体验。",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",