dsh-client-auto-continue 0.17.1-rc.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1119,6 +1119,9 @@ function foldRequestHeader(events, from) {
1119
1119
  }
1120
1120
 
1121
1121
  // src/shared/core.ts
1122
+ function resolveLocale(locale) {
1123
+ return typeof locale === "string" && /^zh(?:-|$)/i.test(locale) ? "zh" : "en";
1124
+ }
1122
1125
  var isSessionMode = (value) => value === "default" || value === "off" || value === "recover" || value === "loop";
1123
1126
  function sessionMode(modes, sessionId) {
1124
1127
  return Object.prototype.hasOwnProperty.call(modes, sessionId) && isSessionMode(modes[sessionId]) ? modes[sessionId] : "default";
@@ -1146,8 +1149,8 @@ var LOCALIZED_TEXT_DEFAULTS = {
1146
1149
  }
1147
1150
  };
1148
1151
  var DEFAULT_CONFIG = {
1149
- locale: "zh",
1150
- ...LOCALIZED_TEXT_DEFAULTS.zh,
1152
+ locale: "en",
1153
+ ...LOCALIZED_TEXT_DEFAULTS.en,
1151
1154
  resumeSilentTurns: true,
1152
1155
  resumeCompletedTurns: false,
1153
1156
  continueTextLoop: "",
@@ -1182,7 +1185,7 @@ function booleanOr(value, fallback) {
1182
1185
  }
1183
1186
  function resolveConfig(section) {
1184
1187
  const value = section ?? {};
1185
- const locale = value.locale === "en" ? "en" : "zh";
1188
+ const locale = resolveLocale(value.locale);
1186
1189
  const localized = LOCALIZED_TEXT_DEFAULTS[locale];
1187
1190
  const text = typeof value.continueText === "string" && value.continueText.trim() !== "" ? value.continueText : localized.continueText;
1188
1191
  const maxTokensText = typeof value.continueTextMaxTokens === "string" && value.continueTextMaxTokens.trim() !== "" ? value.continueTextMaxTokens : localized.continueTextMaxTokens;
@@ -9267,7 +9270,7 @@ function migrateLegacySettings(ctx, config, fields, validate) {
9267
9270
  var AUTO_CONTINUE_NS = "auto-continue";
9268
9271
  var settingsFields = {
9269
9272
  /** Active browser/UI locale mirrored by the client. */
9270
- locale: z2.string().default("zh"),
9273
+ locale: z2.string().default("en"),
9271
9274
  /** Text automatically sent after an interruption. */
9272
9275
  continueText: z2.string().default(""),
9273
9276
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
@@ -5,8 +5,9 @@
5
5
  * 以及回显识别。引擎迁入 host 后(0.8.0), 浏览器半侧只 re-export 本模块。
6
6
  */
7
7
  import type { SessionEvent } from '@deepseek-ai/dsh-session/types';
8
- /** Supported UI/config locales. Any unknown browser locale falls back to Chinese. */
8
+ /** Supported UI/config locales; missing and unsupported values use English. */
9
9
  export type AutoContinueLocale = 'en' | 'zh';
10
+ export declare function resolveLocale(locale: unknown): AutoContinueLocale;
10
11
  export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
11
12
  export interface SessionPolicy {
12
13
  modes: Record<string, SessionMode>;
@@ -110,7 +111,7 @@ export interface AutoContinueSettings {
110
111
  }
111
112
  /** Fully resolved configuration (built-in defaults + user overrides). */
112
113
  export type AutoContinueConfig = Required<AutoContinueSettings>;
113
- /** Effective built-in defaults; localized text fields use Chinese until a browser locale is mirrored. */
114
+ /** Effective built-in defaults; localized text fields use English until a browser locale is mirrored. */
114
115
  export declare const DEFAULT_CONFIG: AutoContinueConfig;
115
116
  /** Resolve a (possibly partial / not-yet-loaded) settings section to a full config. */
116
117
  export declare function resolveConfig(section: AutoContinueSettings | undefined): AutoContinueConfig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-client-auto-continue",
3
3
  "description": "DSH Web UI plugin: automatically sends a localized continue prompt when a request is interrupted by network errors or other non-human causes",
4
- "version": "0.17.1-rc.1",
4
+ "version": "0.17.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -19,7 +19,7 @@ import type {} from '@deepseek-ai/dsh-client-locale/client';
19
19
  import type {} from '@deepseek-ai/dsh-client-ui-settings/client';
20
20
  // Type-only: pulls the `settings.plugin.item` SlotMap merge.
21
21
  import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client';
22
- import { type AutoContinueSettings } from './engine.ts';
22
+ import { resolveLocale, type AutoContinueSettings } from '../shared/core.ts';
23
23
  import { en, zh, type SettingsCardKey } from './locales.ts';
24
24
  import {
25
25
  AutoContinueSettingsCard,
@@ -125,6 +125,7 @@ function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSett
125
125
  let mirrorAttempts = 0;
126
126
  const syncLocale = (): void => {
127
127
  const active = ctx.locale.getLocale().active;
128
+ const target = resolveLocale(active);
128
129
  const snapshot = scope.getSnapshot();
129
130
  if (!canWriteSettings(snapshot)) return;
130
131
  // A genuine language switch is the only thing that earns a fresh budget: the
@@ -136,10 +137,10 @@ function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSett
136
137
  mirrorAttempts = 0;
137
138
  }
138
139
  // Converged: nothing to write.
139
- if (snapshot.value?.locale === active) return;
140
+ if (snapshot.value?.locale === target) return;
140
141
  if (mirrorAttempts >= MAX_MIRROR_ATTEMPTS) return;
141
142
  mirrorAttempts += 1;
142
- void scope.set('locale', active);
143
+ void scope.set('locale', target);
143
144
  };
144
145
  ctx.effect(() => scope.subscribe(syncLocale), 'auto-continue: locale settings sync');
145
146
  ctx.on('locale/change', syncLocale);
@@ -1,4 +1,5 @@
1
1
  import { en, zh, type SettingsCardKey } from './locales.ts';
2
+ import { resolveLocale } from '../shared/core.ts';
2
3
 
3
4
  type Permission = NotificationPermission | 'unsupported' | 'failed';
4
5
  export type SettingsNotice = 'enabled' | 'disabled' | 'saved';
@@ -30,7 +31,7 @@ export function showSettingsNotification(notice: SettingsNotice, locale: string,
30
31
  : permission === 'failed' ? 'notification.failed' : 'notification.blocked';
31
32
  }
32
33
  try {
33
- const copy = locale.startsWith('en') ? en : zh;
34
+ const copy = resolveLocale(locale) === 'zh' ? zh : en;
34
35
  const notification = new Notification(copy['notification.title'], { body: copy[message] });
35
36
  notification.onclick = () => {
36
37
  try { globalThis.focus?.(); } catch { /* Focusing is best effort. */ }
@@ -148,9 +148,7 @@ const css = `
148
148
  .dshAcFooter { align-items: flex-start; flex-direction: column; gap: 10px; }
149
149
  .dshAcFooter > div { width: 100%; justify-content: flex-end; }
150
150
  }
151
- /* Match the composer's own pickers (permission/mode) instead of the viewport:
152
- the nearest query container is the composer row, so the label collapses at
153
- the same 460px threshold as the native permission picker. */
151
+ /* Match the native picker breakpoints when the composer provides a query container. */
154
152
  @container (width <= 640px) {
155
153
  .dshAcComposerCore { gap: 5px; }
156
154
  .dshAcModeTrigger, .dshAcModeMenu { max-width: 104px; padding: 0 3px 0 6px; }
@@ -160,6 +158,14 @@ const css = `
160
158
  .dshAcModeTrigger, .dshAcModeMenu { max-width: 28px; padding: 0 2px; }
161
159
  .dshAcModeTriggerLabel { display: none; }
162
160
  }
161
+ /* DS-Bot can remove the query container with display: contents. */
162
+ @media (max-width: 460px) {
163
+ .dshAcComposer { flex-direction: column; align-items: flex-start; width: min-content; }
164
+ .dshAcComposer > .dshAcComposerLabel { white-space: normal; }
165
+ .dshAcComposerCore { gap: 5px; }
166
+ .dshAcComposerText, .dshAcModeTriggerLabel { display: none; }
167
+ .dshAcModeTrigger, .dshAcModeMenu { max-width: 28px; padding: 0 2px; }
168
+ }
163
169
 
164
170
  `;
165
171
 
package/src/index.ts CHANGED
@@ -27,7 +27,7 @@ export const AUTO_CONTINUE_NS = 'auto-continue';
27
27
  /** Wire schema; blank localized text fields tell resolveConfig() to select the active locale's defaults. */
28
28
  const settingsFields = {
29
29
  /** Active browser/UI locale mirrored by the client. */
30
- locale: z.string().default('zh'),
30
+ locale: z.string().default('en'),
31
31
  /** Text automatically sent after an interruption. */
32
32
  continueText: z.string().default(''),
33
33
  /** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
@@ -6,9 +6,13 @@
6
6
  */
7
7
  import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session/types';
8
8
 
9
- /** Supported UI/config locales. Any unknown browser locale falls back to Chinese. */
9
+ /** Supported UI/config locales; missing and unsupported values use English. */
10
10
  export type AutoContinueLocale = 'en' | 'zh';
11
11
 
12
+ export function resolveLocale(locale: unknown): AutoContinueLocale {
13
+ return typeof locale === 'string' && /^zh(?:-|$)/i.test(locale) ? 'zh' : 'en';
14
+ }
15
+
12
16
  export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
13
17
 
14
18
  export interface SessionPolicy {
@@ -129,10 +133,10 @@ export interface AutoContinueSettings {
129
133
  /** Fully resolved configuration (built-in defaults + user overrides). */
130
134
  export type AutoContinueConfig = Required<AutoContinueSettings>;
131
135
 
132
- /** Effective built-in defaults; localized text fields use Chinese until a browser locale is mirrored. */
136
+ /** Effective built-in defaults; localized text fields use English until a browser locale is mirrored. */
133
137
  export const DEFAULT_CONFIG: AutoContinueConfig = {
134
- locale: 'zh',
135
- ...LOCALIZED_TEXT_DEFAULTS.zh,
138
+ locale: 'en',
139
+ ...LOCALIZED_TEXT_DEFAULTS.en,
136
140
  resumeSilentTurns: true,
137
141
  resumeCompletedTurns: false,
138
142
  continueTextLoop: '',
@@ -171,7 +175,7 @@ function booleanOr(value: unknown, fallback: boolean): boolean {
171
175
  /** Resolve a (possibly partial / not-yet-loaded) settings section to a full config. */
172
176
  export function resolveConfig(section: AutoContinueSettings | undefined): AutoContinueConfig {
173
177
  const value = section ?? {};
174
- const locale: AutoContinueLocale = value.locale === 'en' ? 'en' : 'zh';
178
+ const locale = resolveLocale(value.locale);
175
179
  const localized = LOCALIZED_TEXT_DEFAULTS[locale];
176
180
  const text =
177
181
  typeof value.continueText === 'string' && value.continueText.trim() !== ''