dsh-web-fetch-playwright 0.2.6 → 0.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-web-fetch-playwright",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Playwright/CDP web-fetch provider for DeepSeek Harness: renders pages in a real browser, denoises them (Readability + DOMPurify), and returns markdown.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,6 @@
26
26
  "lib/types/**/*.d.ts",
27
27
  "src",
28
28
  "cordis.patch.yml",
29
- "dsh.plugin.json",
30
29
  "README.md",
31
30
  "README.zh-CN.md",
32
31
  "LICENSE"
@@ -46,7 +45,6 @@
46
45
  "platform": "web",
47
46
  "inject": [
48
47
  "@deepseek-ai/dsh-client-locale",
49
- "@deepseek-ai/dsh-client-runtime",
50
48
  "@deepseek-ai/dsh-client-ui-settings"
51
49
  ]
52
50
  }
@@ -89,7 +87,7 @@
89
87
  "retention": "none (profile mode: site data lands in the remote browser's own persistent user-data-dir, which this plugin never cleans)"
90
88
  },
91
89
  "dependencies": {
92
- "@deepseek-ai/schemastery": ">=3.18.1-rc.1 <4",
90
+ "@deepseek-ai/schemastery": ">=3.18.4 <4",
93
91
  "@joplin/turndown-plugin-gfm": "^1.0.56",
94
92
  "@mozilla/readability": "^0.6.0",
95
93
  "dompurify": "^3.2.4",
@@ -99,7 +97,6 @@
99
97
  },
100
98
  "peerDependencies": {
101
99
  "@deepseek-ai/cordis": ">=4.0.1-rc.1 <5",
102
- "@deepseek-ai/dsh-settings": ">=0.1.0-rc.6 <0.2.0 || >=0.1.1-rc.1 <1",
103
100
  "@deepseek-ai/dsh-web": ">=0.1.0-rc.6 <0.2.0 || >=0.1.1-rc.1 <1"
104
101
  },
105
102
  "peerDependenciesMeta": {
@@ -108,14 +105,15 @@
108
105
  }
109
106
  },
110
107
  "devDependencies": {
111
- "@deepseek-ai/cordis": "4.0.1",
112
- "@deepseek-ai/dsh-client-locale": "0.1.1-rc.1",
113
- "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.1",
114
- "@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.1",
115
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.1-rc.1",
116
- "@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.1",
117
- "@deepseek-ai/dsh-settings": "0.1.1-rc.1",
118
- "@deepseek-ai/dsh-web": "0.1.1-rc.1",
108
+ "@deepseek-ai/cordis": "4.0.4",
109
+ "@deepseek-ai/dsh-api-remotes": "0.1.7-rc.2",
110
+ "@deepseek-ai/dsh-client-locale": "0.1.7-rc.2",
111
+ "@deepseek-ai/dsh-client-store": "0.1.7-rc.2",
112
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "0.1.7-rc.2",
113
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.7-rc.2",
114
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.2",
115
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.2",
116
+ "@deepseek-ai/dsh-web": "0.1.7-rc.2",
119
117
  "@types/jsdom": "^30.0.0",
120
118
  "@types/node": "^24.0.0",
121
119
  "@types/react": "^18.3.1",
package/src/challenge.ts CHANGED
@@ -16,7 +16,10 @@
16
16
  * (`/cdn-cgi/challenge-platform/` scripts, `#challenge-*` elements,
17
17
  * `cf-chl-widget-` Turnstile frames, `window._cf_chl_opt`). Markers are
18
18
  * deliberately structural: a blog post that merely MENTIONS Cloudflare
19
- * must not classify as a challenge.
19
+ * must not classify as a challenge. Bot Management's passive JSD
20
+ * telemetry (`/cdn-cgi/challenge-platform/scripts/jsd/`), which
21
+ * Cloudflare injects into every NORMAL page of a protected zone, is
22
+ * explicitly neutralized — it is not a challenge signal.
20
23
  *
21
24
  * The security stance (issue #2): this module only DETECTS and classifies.
22
25
  * Solving, spoofing, CAPTCHA answering, and cookie lifting live outside the
@@ -85,15 +88,31 @@ export const CHALLENGE_TITLE_RE = new RegExp(
85
88
  'i',
86
89
  )
87
90
 
91
+ /**
92
+ * Cloudflare Bot Management's passive JavaScript-Detections (JSD)
93
+ * telemetry directory. Cloudflare injects this into EVERY normal page of
94
+ * a protected zone — as a direct `<script src>` or as the URL strung
95
+ * inside the hidden-1x1-iframe bootstrap's inline script text — with the
96
+ * page itself a plain 200 of real content. The path therefore proves
97
+ * nothing about a challenge and must be neutralized before the
98
+ * challenge-platform prefix check: real interstitials load orchestrate
99
+ * scripts (`/cdn-cgi/challenge-platform/h/[b|g]/orchestrate/...`), which
100
+ * never live under `scripts/jsd/`.
101
+ */
102
+ const TELEMETRY_JSD_DIR = '/cdn-cgi/challenge-platform/scripts/jsd/'
103
+
88
104
  /**
89
105
  * Structural markers a challenge document carries in its HTML. Kept in
90
106
  * attribute/assignment form (`id="…"`, `window._cf_chl_opt`) rather than bare
91
107
  * substrings so an article that merely QUOTES these strings in prose or code
92
108
  * samples does not classify — the marker must look like the real element.
109
+ * The bare `/cdn-cgi/challenge-platform/` prefix is checked only after
110
+ * {@link TELEMETRY_JSD_DIR} occurrences are stripped (see
111
+ * {@link classifyChallengeHtml}); `scripts/jsd/main.js` in any spelling is
112
+ * passive telemetry and deliberately absent from this list.
93
113
  */
94
114
  const CHALLENGE_HTML_MARKERS = [
95
115
  '/cdn-cgi/challenge-platform/',
96
- '/cdn-cgi/scripts/jsd/main.js',
97
116
  'id="cf-chl-widget-',
98
117
  'window._cf_chl_opt',
99
118
  'id="challenge-form"',
@@ -187,7 +206,14 @@ export function classifyChallengeHtml(html: string): ChallengeVerdict {
187
206
  const lowered = html.toLowerCase()
188
207
  if (lowered.includes(BLOCKED_BODY_PHRASE) && BLOCKED_BODY_MARKERS.some(marker => lowered.includes(marker))) return 'blocked'
189
208
  if (CHALLENGE_TITLE_RE.test(title)) return 'challenge'
190
- if (CHALLENGE_HTML_MARKERS.some(marker => lowered.includes(marker))) return 'challenge'
209
+ // Strip the passive JSD telemetry directory before the marker scan: its
210
+ // URL embeds the `/cdn-cgi/challenge-platform/` prefix, so an unstripped
211
+ // scan misreads every Bot-Management-protected normal page (a plain 200
212
+ // with real content — e.g. openrouter.ai) as an interstitial, the wait
213
+ // can then never confirm a clear, and the fetch dies with
214
+ // WEB_FETCH_CHALLENGE despite the page having loaded fine.
215
+ const withoutTelemetry = lowered.split(TELEMETRY_JSD_DIR).join('')
216
+ if (CHALLENGE_HTML_MARKERS.some(marker => withoutTelemetry.includes(marker))) return 'challenge'
191
217
  // Crawlee's footer marker, as a two-class combo so prose quoting one class
192
218
  // alone stays clean.
193
219
  if (lowered.includes('class="ray-id"') && lowered.includes('class="footer-inner"')) return 'challenge'
@@ -200,7 +226,10 @@ export function classifyChallengeHtml(html: string): ChallengeVerdict {
200
226
  * what makes SPA-style clears visible — the document swaps its content
201
227
  * without any navigation, so only a DOM read can see the change. The title
202
228
  * regex is baked in at build time from the same single source the Node-side
203
- * check uses, so the two can never drift apart.
229
+ * check uses, so the two can never drift apart. Script srcs under
230
+ * `/cdn-cgi/challenge-platform/scripts/jsd/` are Bot Management's passive
231
+ * JSD telemetry — present on every normal page of a protected zone — and are
232
+ * excluded just like in {@link classifyChallengeHtml}.
204
233
  */
205
234
  export const CHALLENGE_DOM_PROBE = `(() => {
206
235
  const re = new RegExp(${JSON.stringify(CHALLENGE_TITLE_RE.source)}, ${JSON.stringify(CHALLENGE_TITLE_RE.flags)})
@@ -209,7 +238,7 @@ export const CHALLENGE_DOM_PROBE = `(() => {
209
238
  if (document.querySelector('[id^="cf-chl-widget-"]')) return true
210
239
  for (const script of Array.from(document.scripts)) {
211
240
  const src = script.getAttribute('src') || ''
212
- if (src.includes('/cdn-cgi/challenge-platform/') || src.includes('/cdn-cgi/scripts/jsd/main.js')) return true
241
+ if (src.includes('/cdn-cgi/challenge-platform/') && !src.includes('/cdn-cgi/challenge-platform/scripts/jsd/')) return true
213
242
  }
214
243
  if (document.querySelector('.footer .footer-inner .ray-id')) return true
215
244
  return false
@@ -1,80 +1,12 @@
1
- /* Plugin card chrome — copied from the shipped ui-settings-plugins styles
2
- (same dsw-alias tokens, same rhythm) so the card is indistinguishable from
3
- the built-in plugin-configuration cards. */
1
+ /* Form chrome — built on the same dsw-alias tokens and rhythm as the
2
+ shipped plugin-configuration forms so the card is indistinguishable from
3
+ the built-in ones. Since dsh 0.1.7 the Plugins page draws the title,
4
+ description, and navigation around a configuration entry; this holds the
5
+ form body and its footer only. */
4
6
 
5
- .card {
6
- list-style: none;
7
- border: 1px solid var(--dsw-alias-border-l2);
8
- border-radius: 12px;
9
- background: var(--dsw-alias-bg-layer-3);
10
- transition: border-color .16s, background .16s;
11
- }
12
-
13
- .card:hover {
14
- border-color: var(--dsw-alias-label-dimmed);
15
- }
16
-
17
- .cardOpen {
18
- background: var(--dsw-alias-bg-layer-2);
19
- border-color: var(--dsw-alias-label-dimmed);
20
- }
21
-
22
- .header {
23
- width: 100%;
24
- appearance: none;
25
- border: 0;
26
- background: none;
27
- font: inherit;
28
- color: inherit;
29
- text-align: left;
30
- cursor: pointer;
31
- display: flex;
32
- align-items: center;
33
- gap: 12px;
34
- padding: 14px 16px;
35
- border-radius: 12px;
36
- }
37
-
38
- .header:focus-visible {
39
- outline: 2px solid var(--dsw-alias-brand-primary);
40
- outline-offset: -2px;
41
- }
42
-
43
- .headText {
44
- flex: 1;
45
- min-width: 0;
7
+ .form {
46
8
  display: flex;
47
9
  flex-direction: column;
48
- gap: 4px;
49
- }
50
-
51
- .name {
52
- font-size: 15px;
53
- font-weight: 600;
54
- line-height: 1.4;
55
- color: var(--dsw-alias-label-primary);
56
- }
57
-
58
- .description {
59
- font-size: 13px;
60
- line-height: 1.5;
61
- color: var(--dsw-alias-label-tertiary);
62
- }
63
-
64
- .chevron {
65
- flex: none;
66
- color: var(--dsw-alias-label-tertiary);
67
- transition: transform .16s;
68
- }
69
-
70
- .chevronOpen {
71
- transform: rotate(180deg);
72
- }
73
-
74
- .body {
75
- border-top: 1px solid var(--dsw-alias-border-l2);
76
- margin: 0 16px;
77
- padding-bottom: 8px;
78
10
  }
79
11
 
80
12
  .readOnly {
@@ -84,18 +16,6 @@
84
16
  color: var(--dsw-alias-label-tertiary);
85
17
  }
86
18
 
87
- .pending {
88
- flex: none;
89
- border-radius: 999px;
90
- padding: 1px 8px;
91
- font-size: 11px;
92
- line-height: 17px;
93
- font-weight: 500;
94
- white-space: nowrap;
95
- background: var(--dsw-alias-bg-module-platform);
96
- color: var(--dsw-alias-label-secondary);
97
- }
98
-
99
19
  .footer {
100
20
  display: flex;
101
21
  align-items: center;
@@ -1,20 +1,20 @@
1
1
  /**
2
- * The card chrome — a faithful local copy of the shipped `ui-settings-plugins`
3
- * PluginCard (disclosure header, unsaved marker, save/discard footer), with
4
- * the chevron inlined so the bundle stays self-contained.
2
+ * The form chrome — a page-level container (read-only notice, the staged
3
+ * controls, and the save/discard footer), in the rhythm of the shipped
4
+ * plugin-configuration forms. Since the Plugins page (dsh ≥ 0.1.7) draws the
5
+ * title, description, and navigation around a configuration entry, this is
6
+ * the body only; the disclosure header of the old settings-list card is
7
+ * gone with that seat.
5
8
  *
6
9
  * @module dsh-web-fetch-playwright/client/PluginCard
7
10
  */
8
11
 
9
- import { useState, type ReactNode } from 'react'
12
+ import type { ReactNode } from 'react'
10
13
  import type { CardShell } from './form.ts'
11
14
  import css from './PluginCard.module.css'
12
15
 
13
16
  /** Copy keys the chrome itself renders (the card's dictionary supplies them). */
14
- export interface CardChromeCopy {
15
- expand: string
16
- collapse: string
17
- unsaved: string
17
+ export interface CardFormCopy {
18
18
  readOnly: string
19
19
  saveFailed: string
20
20
  discard: string
@@ -22,14 +22,10 @@ export interface CardChromeCopy {
22
22
  saving: string
23
23
  }
24
24
 
25
- /** Card chrome props. */
26
- export interface PluginCardProps {
25
+ /** Form chrome props. */
26
+ export interface CardFormProps {
27
27
  /** Chrome copy (a subset of the card's locale keys). */
28
- copy: CardChromeCopy
29
- /** The plugin's display name. */
30
- title: string
31
- /** The line describing what this plugin's settings govern. */
32
- description: string
28
+ copy: CardFormCopy
33
29
  /** The card's form state: availability, writability, and what a save would do. */
34
30
  state: CardShell
35
31
  /** Write every staged edit. */
@@ -40,71 +36,37 @@ export interface PluginCardProps {
40
36
  children: ReactNode
41
37
  }
42
38
 
43
- function cx(...parts: Array<string | false | undefined>): string {
44
- return parts.filter(part => typeof part === 'string').join(' ')
45
- }
46
-
47
- function ChevronDown({ className }: { className?: string }) {
48
- return (
49
- <svg className={className} width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
50
- <path d="M4 6l4 4 4-4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
51
- </svg>
52
- )
53
- }
54
-
55
39
  /**
56
- * Render the Playwright card's chrome.
57
- * @param props - the card's copy, name, form state, and controls.
58
- * @returns the card, or nothing when the namespace is unavailable.
40
+ * Render the Playwright form's chrome.
41
+ * @param props - the form's copy, form state, and controls.
42
+ * @returns the form body with its footer.
59
43
  */
60
- export function PluginCard(props: PluginCardProps) {
61
- const [open, setOpen] = useState(false)
44
+ export function CardForm(props: CardFormProps) {
62
45
  const { state, copy } = props
63
- if (!state.available) return null
64
46
  const blocked = !state.dirty || state.invalid || state.saving
65
47
  return (
66
- <li className={cx(css.card, open && css.cardOpen)}>
67
- <button
68
- type="button"
69
- className={css.header}
70
- aria-expanded={open}
71
- aria-label={`${open ? copy.collapse : copy.expand}: ${props.title}`}
72
- onClick={() => { setOpen(!open) }}
73
- >
74
- <span className={css.headText}>
75
- <span className={css.name}>{props.title}</span>
76
- <span className={css.description}>{props.description}</span>
77
- </span>
78
- {state.dirty ? <span className={css.pending}>{copy.unsaved}</span> : null}
79
- <ChevronDown className={cx(css.chevron, open && css.chevronOpen)} />
80
- </button>
81
- {open
82
- ? (
83
- <div className={css.body}>
84
- {!state.writable ? <p className={css.readOnly} role="status">{copy.readOnly}</p> : null}
85
- {props.children}
86
- <div className={css.footer}>
87
- {state.failed ? <p className={css.failed} role="status">{copy.saveFailed}</p> : null}
88
- <button
89
- type="button"
90
- className={css.discard}
91
- disabled={!state.dirty || state.saving}
92
- onClick={props.onDiscard}
93
- >
94
- {copy.discard}
95
- </button>
96
- <button
97
- type="button"
98
- className={css.save}
99
- disabled={blocked}
100
- onClick={props.onSave}
101
- >
102
- {state.saving ? copy.saving : copy.save}
103
- </button>
104
- </div>
105
- </div>
106
- )
107
- : null}
108
- </li>
48
+ <div className={css.form}>
49
+ {!state.writable ? <p className={css.readOnly} role="status">{copy.readOnly}</p> : null}
50
+ {props.children}
51
+ <div className={css.footer}>
52
+ {state.failed ? <p className={css.failed} role="status">{copy.saveFailed}</p> : null}
53
+ <button
54
+ type="button"
55
+ className={css.discard}
56
+ disabled={!state.dirty || state.saving}
57
+ onClick={props.onDiscard}
58
+ >
59
+ {copy.discard}
60
+ </button>
61
+ <button
62
+ type="button"
63
+ className={css.save}
64
+ disabled={blocked}
65
+ onClick={props.onSave}
66
+ >
67
+ {state.saving ? copy.saving : copy.save}
68
+ </button>
69
+ </div>
70
+ </div>
109
71
  )
110
72
  }
@@ -5,44 +5,50 @@
5
5
  * the denoise checkbox, staged and saved through the card form like the
6
6
  * built-in plugin cards.
7
7
  *
8
+ * The Plugins page asks for `view: 'summary'` (a row's description
9
+ * fallback) or `view: 'page'` (this form). The same component serves both
10
+ * seats it is registered into: the bundle's own page (between its
11
+ * description and its rows) and the row's page (under the plugin's own
12
+ * title); one controller stages the edits shared by the two.
13
+ *
8
14
  * @module dsh-web-fetch-playwright/client/card
9
15
  */
10
16
 
11
17
  import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
12
- import { PluginCard } from './PluginCard.tsx'
18
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
19
+ import type {} from '@deepseek-ai/dsh-client-ui-plugin-manager/client'
20
+ import { CardForm } from './PluginCard.tsx'
13
21
  import { CheckboxField, RadioGroupField, ValueField } from './fields.tsx'
14
22
  import type { PlaywrightCardFace, PlaywrightCardState } from './controller.ts'
15
23
 
16
24
  /** Props the renderer binds for the Playwright card. */
17
25
  export type PlaywrightCardProps =
18
- PropsRuntime<'settings.plugin.item'>
26
+ (PropsRuntime<'plugins.bundle.config'> | PropsRuntime<'plugins.row.config'>)
19
27
  & PropsLocale<'web-fetch-playwright'>
20
28
  & InjectFace<PlaywrightCardFace>
21
29
 
22
30
  /**
23
- * Render the Playwright card.
24
- * @param props - locale copy, the card snapshot, and its form actions.
25
- * @returns the card.
31
+ * Render the Playwright card: its one-liner for the list, or the staged form
32
+ * for the page.
33
+ * @param props - the view asked for, locale copy, the card snapshot, and its form actions.
34
+ * @returns the one-liner, the form, or nothing while the namespace is unavailable.
26
35
  */
27
36
  export function PlaywrightCard(props: PlaywrightCardProps) {
28
37
  const { t } = props
38
+ if (props.view === 'summary') return t('description')
29
39
  const state = props.usePlaywrightCard(snapshot => snapshot)
40
+ if (!state.available) return null
30
41
  const disabled = !state.writable
31
42
  const backend = state.backend.text === 'cdp' ? 'cdp' : 'local'
32
43
  return (
33
- <PluginCard
44
+ <CardForm
34
45
  copy={{
35
- expand: t('expand'),
36
- collapse: t('collapse'),
37
- unsaved: t('unsaved'),
38
46
  readOnly: t('readOnly'),
39
47
  saveFailed: t('saveFailed'),
40
48
  discard: t('discard'),
41
49
  save: t('save'),
42
50
  saving: t('saving'),
43
51
  }}
44
- title={t('title')}
45
- description={t('description')}
46
52
  state={state}
47
53
  onSave={props.save}
48
54
  onDiscard={props.discard}
@@ -154,6 +160,6 @@ export function PlaywrightCard(props: PlaywrightCardProps) {
154
160
  onEdit={(text) => { props.edit('challengeWaitMs', text) }}
155
161
  onReset={() => { props.resetField('challengeWaitMs') }}
156
162
  />
157
- </PluginCard>
163
+ </CardForm>
158
164
  )
159
165
  }
@@ -1,18 +1,24 @@
1
1
  /**
2
2
  * The Playwright card's controller: the staged form over the
3
- * `web-fetch-playwright` settings namespace, projected into one snapshot the
4
- * card's slot entry injects.
3
+ * `web-fetch-playwright` plugin-entry configuration form, projected into one
4
+ * snapshot the card's slot entry injects.
5
+ *
6
+ * Since dsh 0.1.7 the scope is the shared `configForms` form for the plugin
7
+ * entry — the host's settings service derives the section from the plugin's
8
+ * Config schema (its volatile fields), keyed by the composition entry id.
5
9
  *
6
10
  * @module dsh-web-fetch-playwright/client/controller
7
11
  */
8
12
 
9
- import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client'
13
+ import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client'
10
14
  import { CardForm, checkboxField, numberField, radioField, textField } from './form.ts'
11
15
  import type { CardShell, CardFieldState, CardActions, SnapshotStore } from './form.ts'
12
16
 
13
17
  /**
14
- * Settings namespace this card edits. Spelled here rather than imported: a
15
- * client package must not depend on a Host package.
18
+ * Settings namespace this card edits: the composition entry id, which is
19
+ * what the host's settings service keys the section derived from the
20
+ * plugin's Config schema by. Spelled here rather than imported: a client
21
+ * package must not depend on a Host package.
16
22
  */
17
23
  export const WEB_FETCH_PLAYWRIGHT_NS = 'web-fetch-playwright'
18
24
 
@@ -67,15 +73,17 @@ export interface PlaywrightCardFace extends CardActions {
67
73
  }
68
74
  }
69
75
 
70
- /** Bridges the `web-fetch-playwright` settings scope onto the card. */
76
+ /**
77
+ * Bridges the `web-fetch-playwright` configuration form onto the card.
78
+ */
71
79
  export class PlaywrightCardController {
72
80
  private readonly form: CardForm<PlaywrightSettings>
73
81
  private readonly store: SnapshotStore<PlaywrightCardState>
74
82
 
75
83
  /**
76
- * @param scope - the bound settings scope for the `web-fetch-playwright` namespace.
84
+ * @param scope - the shared configuration form for the `web-fetch-playwright` entry.
77
85
  */
78
- constructor(scope: SettingsScope<PlaywrightSettings>) {
86
+ constructor(scope: ConfigForm<PlaywrightSettings>) {
79
87
  this.form = new CardForm(
80
88
  scope,
81
89
  [
@@ -111,4 +119,9 @@ export class PlaywrightCardController {
111
119
  inject(): PlaywrightCardFace {
112
120
  return { hooks: { playwrightCard: this.store }, ...this.form.actions() }
113
121
  }
122
+
123
+ /** Release the form subscription and every bound stores. */
124
+ dispose(): void {
125
+ this.form.dispose()
126
+ }
114
127
  }
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * The staged-form model behind the Playwright card — a faithful subset of the
3
- * shipped `ui-settings-plugins` CardForm (same staging semantics: edits stay
3
+ * shipped plugin-configuration CardForm (same staging semantics: edits stay
4
4
  * local until the card's save, presence in the user layer — not value
5
5
  * equality — marks a field overridden), plus the two field kinds this card
6
6
  * adds: a radio group (backend) and a checkbox (denoise), staged through the
7
- * same draft mechanism as text.
7
+ * same draft mechanism as text. Since dsh 0.1.7 the scope is the shared
8
+ * `configForms` form for the plugin entry (reads ride the describe mirror;
9
+ * writes are revision-fenced path mutations).
8
10
  *
9
11
  * Bundled locally because external client bundles cannot value-import
10
12
  * `@deepseek-ai/*` packages; the snapshot store is a local structural clone
@@ -13,7 +15,7 @@
13
15
  * @module dsh-web-fetch-playwright/client/form
14
16
  */
15
17
 
16
- import type { SettingsScope, SettingsScopeSnapshot } from '@deepseek-ai/dsh-client-runtime/client'
18
+ import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
17
19
 
18
20
  /** The write one field's staged draft performs when the card is saved. */
19
21
  export type FieldWrite =
@@ -164,27 +166,35 @@ export function numberField(field: string, min: number, max: number): CardFieldS
164
166
  }
165
167
 
166
168
  /**
167
- * Stages the Playwright card's edits over one settings namespace and writes
168
- * them on save. Publishes through a snapshot store because slot components
169
- * read through a selector while both the scope and the drafts change below.
169
+ * Stages the Playwright card's edits over one plugin-entry configuration
170
+ * form and writes them on save. Publishes through a snapshot store because
171
+ * slot components read through a selector while both the form and the drafts
172
+ * change below.
170
173
  */
171
174
  export class CardForm<T> {
172
175
  private readonly specs: Map<string, CardFieldSpec>
173
176
  private readonly staged = new Map<string, StagedEdit>()
174
177
  private readonly listeners = new Set<() => void>()
178
+ private readonly unsubscribe: () => void
175
179
  private saving = false
176
180
  private failed = false
177
181
 
178
182
  /**
179
- * @param scope - the bound settings scope for this card's namespace.
183
+ * @param scope - the shared configuration form for this plugin's entry.
180
184
  * @param specs - the section fields this card edits.
181
185
  */
182
186
  constructor(
183
- private readonly scope: SettingsScope<T>,
187
+ private readonly scope: ConfigForm<T>,
184
188
  specs: CardFieldSpec[],
185
189
  ) {
186
190
  this.specs = new Map(specs.map(spec => [spec.field, spec]))
187
- scope.subscribe(() => { this.publish() })
191
+ this.unsubscribe = scope.subscribe(() => { this.publish() })
192
+ }
193
+
194
+ /** Release the form subscription and every bound stores. */
195
+ dispose(): void {
196
+ this.unsubscribe()
197
+ this.listeners.clear()
188
198
  }
189
199
 
190
200
  /**
@@ -270,7 +280,9 @@ export class CardForm<T> {
270
280
  /**
271
281
  * Write every staged edit, then re-seed from what the Host accepted. A save
272
282
  * that did not land keeps its drafts, so the user corrects them instead of
273
- * retyping.
283
+ * retyping. The shared form reports `false` (and reloads Host state) for a
284
+ * refused revision or validation, and a transport drop rejects — both fold
285
+ * into the same failed-save path.
274
286
  */
275
287
  async save(): Promise<void> {
276
288
  const plan = this.plan()
@@ -312,13 +324,21 @@ export class CardForm<T> {
312
324
  }
313
325
 
314
326
  private async clear(field: string): Promise<boolean> {
315
- await this.scope.unset(field)
316
- return !this.stored(field)
327
+ try {
328
+ return await this.scope.unset(field)
329
+ } catch (_sectionWriteFailure) {
330
+ // The Host refused the write: keep the drafts, flag the failure.
331
+ return false
332
+ }
317
333
  }
318
334
 
319
335
  private async store(field: string, value: unknown): Promise<boolean> {
320
- await this.scope.set(field, value)
321
- return this.userLayer()?.[field] === value
336
+ try {
337
+ return await this.scope.set(field, value)
338
+ } catch (_sectionWriteFailure) {
339
+ // The Host refused the write: keep the drafts, flag the failure.
340
+ return false
341
+ }
322
342
  }
323
343
 
324
344
  private stage(field: string, edit: StagedEdit): void {
@@ -333,7 +353,7 @@ export class CardForm<T> {
333
353
  return spec
334
354
  }
335
355
 
336
- private snapshotOf(): SettingsScopeSnapshot<T> {
356
+ private snapshotOf(): ConfigFormSnapshot<T> {
337
357
  return this.scope.getSnapshot()
338
358
  }
339
359