@linxin666/dsh-client-ui-task-board-ssh 0.0.0-stage → 0.4.21

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 (128) hide show
  1. package/LICENSE +202 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +96 -2
  4. package/README.zh.md +97 -0
  5. package/cordis.patch.yml +15 -0
  6. package/icon.svg +5 -0
  7. package/lib/client.js +4435 -0
  8. package/lib/index.js +7082 -0
  9. package/lib/types/client/PluginSettingsCard.d.ts +255 -0
  10. package/lib/types/client/RangeBubble.d.ts +46 -0
  11. package/lib/types/client/SegmentGroup.d.ts +28 -0
  12. package/lib/types/client/index.d.ts +100 -0
  13. package/lib/types/client/locales.d.ts +125 -0
  14. package/lib/types/client/seat-props.d.ts +53 -0
  15. package/lib/types/client/settings-entry-form.d.ts +49 -0
  16. package/lib/types/client/settings-form.d.ts +237 -0
  17. package/lib/types/client/ssh/card-decoration.d.ts +23 -0
  18. package/lib/types/client/ssh/compose-section.d.ts +7 -0
  19. package/lib/types/client/ssh/detail-section.d.ts +7 -0
  20. package/lib/types/client/ssh/extension.d.ts +54 -0
  21. package/lib/types/client/ssh/log-buffer.d.ts +128 -0
  22. package/lib/types/client/ssh/log-view.d.ts +37 -0
  23. package/lib/types/client/ssh/model.d.ts +130 -0
  24. package/lib/types/client/ssh/settings-section.d.ts +134 -0
  25. package/lib/types/client/ssh/summary.d.ts +160 -0
  26. package/lib/types/client/ssh/target-form.d.ts +60 -0
  27. package/lib/types/core/action.d.ts +89 -0
  28. package/lib/types/core/adapters/claude.d.ts +15 -0
  29. package/lib/types/core/adapters/codex.d.ts +15 -0
  30. package/lib/types/core/adapters/custom.d.ts +29 -0
  31. package/lib/types/core/adapters/dsh.d.ts +21 -0
  32. package/lib/types/core/adapters/index.d.ts +25 -0
  33. package/lib/types/core/adapters/types.d.ts +76 -0
  34. package/lib/types/core/contract.d.ts +453 -0
  35. package/lib/types/core/launcher-script.d.ts +13 -0
  36. package/lib/types/core/launcher.d.ts +153 -0
  37. package/lib/types/core/ledger.d.ts +123 -0
  38. package/lib/types/core/shell.d.ts +61 -0
  39. package/lib/types/core/target.d.ts +149 -0
  40. package/lib/types/core/task-record.d.ts +74 -0
  41. package/lib/types/core/workspace.d.ts +74 -0
  42. package/lib/types/host/board.d.ts +75 -0
  43. package/lib/types/host/engine.d.ts +563 -0
  44. package/lib/types/host/extension.d.ts +61 -0
  45. package/lib/types/host/inspect.d.ts +99 -0
  46. package/lib/types/host/logs.d.ts +135 -0
  47. package/lib/types/host/payload.d.ts +75 -0
  48. package/lib/types/host/prompt.d.ts +44 -0
  49. package/lib/types/host/queue.d.ts +53 -0
  50. package/lib/types/host/remote.d.ts +137 -0
  51. package/lib/types/host/settings.d.ts +149 -0
  52. package/lib/types/host/timers.d.ts +20 -0
  53. package/lib/types/host/tools.d.ts +17 -0
  54. package/lib/types/host/workspace/errors.d.ts +29 -0
  55. package/lib/types/host/workspace/git.d.ts +108 -0
  56. package/lib/types/host/workspace/in-place.d.ts +36 -0
  57. package/lib/types/host/workspace/index.d.ts +28 -0
  58. package/lib/types/host/workspace/layout.d.ts +62 -0
  59. package/lib/types/host/workspace/local-git.d.ts +72 -0
  60. package/lib/types/host/workspace/remote-git.d.ts +111 -0
  61. package/lib/types/host/workspace/remote.d.ts +85 -0
  62. package/lib/types/host/workspace/types.d.ts +28 -0
  63. package/lib/types/host/workspace-seam.d.ts +100 -0
  64. package/lib/types/index.d.ts +97 -0
  65. package/lib/types/mount-once.d.ts +55 -0
  66. package/locale/en.json +6 -0
  67. package/locale/zh.json +6 -0
  68. package/package.json +89 -3
  69. package/src/client/PluginSettingsCard.tsx +838 -0
  70. package/src/client/RangeBubble.tsx +164 -0
  71. package/src/client/SegmentGroup.tsx +93 -0
  72. package/src/client/css-modules.d.ts +5 -0
  73. package/src/client/index.ts +195 -0
  74. package/src/client/locales.ts +257 -0
  75. package/src/client/seat-props.ts +58 -0
  76. package/src/client/settings-card.module.css +821 -0
  77. package/src/client/settings-entry-form.ts +141 -0
  78. package/src/client/settings-form.ts +529 -0
  79. package/src/client/ssh/card-decoration.tsx +55 -0
  80. package/src/client/ssh/compose-section.tsx +147 -0
  81. package/src/client/ssh/detail-section.tsx +345 -0
  82. package/src/client/ssh/extension.ts +271 -0
  83. package/src/client/ssh/log-buffer.ts +224 -0
  84. package/src/client/ssh/log-view.tsx +149 -0
  85. package/src/client/ssh/model.ts +299 -0
  86. package/src/client/ssh/settings-section.tsx +401 -0
  87. package/src/client/ssh/summary.ts +388 -0
  88. package/src/client/ssh/target-form.tsx +380 -0
  89. package/src/client/ssh.module.css +617 -0
  90. package/src/core/action.ts +270 -0
  91. package/src/core/adapters/claude.ts +64 -0
  92. package/src/core/adapters/codex.ts +83 -0
  93. package/src/core/adapters/custom.ts +88 -0
  94. package/src/core/adapters/dsh.ts +87 -0
  95. package/src/core/adapters/index.ts +74 -0
  96. package/src/core/adapters/types.ts +95 -0
  97. package/src/core/contract.ts +515 -0
  98. package/src/core/launcher-script.ts +313 -0
  99. package/src/core/launcher.ts +283 -0
  100. package/src/core/ledger.ts +377 -0
  101. package/src/core/shell.ts +77 -0
  102. package/src/core/target.ts +420 -0
  103. package/src/core/task-record.ts +73 -0
  104. package/src/core/workspace.ts +78 -0
  105. package/src/host/board.ts +107 -0
  106. package/src/host/engine.ts +2026 -0
  107. package/src/host/extension.ts +310 -0
  108. package/src/host/inspect.ts +264 -0
  109. package/src/host/logs.ts +297 -0
  110. package/src/host/payload.ts +134 -0
  111. package/src/host/prompt.ts +89 -0
  112. package/src/host/queue.ts +73 -0
  113. package/src/host/remote.ts +356 -0
  114. package/src/host/settings.ts +294 -0
  115. package/src/host/timers.ts +33 -0
  116. package/src/host/tools.ts +449 -0
  117. package/src/host/workspace/errors.ts +43 -0
  118. package/src/host/workspace/git.ts +305 -0
  119. package/src/host/workspace/in-place.ts +58 -0
  120. package/src/host/workspace/index.ts +37 -0
  121. package/src/host/workspace/layout.ts +122 -0
  122. package/src/host/workspace/local-git.ts +164 -0
  123. package/src/host/workspace/remote-git.ts +244 -0
  124. package/src/host/workspace/remote.ts +181 -0
  125. package/src/host/workspace/types.ts +34 -0
  126. package/src/host/workspace-seam.ts +132 -0
  127. package/src/index.ts +243 -0
  128. package/src/mount-once.ts +142 -0
@@ -0,0 +1,164 @@
1
+ // Generated by scripts/sync-shared.mjs from shared/client/settings/RangeBubble.tsx. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
2
+ /**
3
+ * Coarse adjustment for a bounded number: resting the pointer on the control
4
+ * (or moving focus into it) raises a small bubble holding a slider across the
5
+ * field's whole range, so a large change is one drag instead of many presses
6
+ * or a retyped value. The control itself stays the precise entry.
7
+ *
8
+ * The bubble belongs to the anchor's subtree, so moving from the control onto
9
+ * the bubble never counts as leaving. It opens after a short rest and closes a
10
+ * moment after the pointer and focus have both gone, so crossing the control
11
+ * on the way elsewhere does not flash it. While a drag is in progress the
12
+ * bubble stays put even if the pointer strays off it.
13
+ *
14
+ * Dragging reports each value through `onInput`, so the field shows it live;
15
+ * releasing the thumb, or a key press on it, reports `onCommit` once. The
16
+ * bubble opens on the side of the control that has room inside the nearest
17
+ * scrolling ancestor, so a row near the top of a settings page does not hang
18
+ * its bubble under the page edge.
19
+ */
20
+
21
+ import { useEffect, useRef, useState, type ChangeEvent, type CSSProperties, type KeyboardEvent, type ReactNode } from 'react'
22
+ import css from './settings-card.module.css'
23
+
24
+ /** Rest on the control before the bubble opens. */
25
+ const OPEN_DELAY_MS = 220
26
+ /** Grace after pointer and focus have left before the bubble closes. */
27
+ const CLOSE_DELAY_MS = 200
28
+ /** Room the bubble needs between the control and the scroller's edge. */
29
+ const BUBBLE_ROOM_PX = 64
30
+
31
+ /** Props of {@link RangeBubble}. */
32
+ export interface RangeBubbleProps {
33
+ /** Lowest value the slider reaches. */
34
+ min: number
35
+ /** Highest value the slider reaches. */
36
+ max: number
37
+ /** Slider granularity. */
38
+ step: number
39
+ /** Current value; a value outside the range parks the thumb at the nearer end. */
40
+ value: number
41
+ /** Accessible name of the slider. */
42
+ label: string
43
+ /** Disables the bubble along with the control. */
44
+ disabled?: boolean
45
+ /** Each value while the thumb moves. */
46
+ onInput: (value: number) => void
47
+ /** The value the thumb was released on, once per drag or key press. */
48
+ onCommit: (value: number) => void
49
+ /** The precise control the bubble hangs off. */
50
+ children: ReactNode
51
+ }
52
+
53
+ /** The nearest ancestor that scrolls vertically, or the viewport's root. */
54
+ function scroller(node: HTMLElement): HTMLElement {
55
+ for (let parent = node.parentElement; parent !== null; parent = parent.parentElement) {
56
+ const overflow = getComputedStyle(parent).overflowY
57
+ if (overflow === 'auto' || overflow === 'scroll') return parent
58
+ }
59
+ return node.ownerDocument.documentElement
60
+ }
61
+
62
+ /**
63
+ * Render the control with its coarse-adjustment bubble.
64
+ * @param props - the range, the value and the two report callbacks.
65
+ * @returns the anchor holding the control and the bubble.
66
+ */
67
+ export function RangeBubble(props: RangeBubbleProps): ReactNode {
68
+ const { min, max, step, disabled = false } = props
69
+ const [open, setOpen] = useState(false)
70
+ const [side, setSide] = useState<'above' | 'below'>('above')
71
+ const [live, setLive] = useState<number | null>(null)
72
+ const anchorRef = useRef<HTMLDivElement | null>(null)
73
+ const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
74
+ const hovered = useRef(false)
75
+ const focused = useRef(false)
76
+ const dragging = useRef(false)
77
+
78
+ useEffect(() => () => { clearTimeout(timer.current) }, [])
79
+ useEffect(() => {
80
+ if (disabled) {
81
+ clearTimeout(timer.current)
82
+ setOpen(false)
83
+ }
84
+ }, [disabled])
85
+
86
+ const show = (): void => {
87
+ const anchor = anchorRef.current
88
+ if (anchor !== null) {
89
+ const room = anchor.getBoundingClientRect().top - scroller(anchor).getBoundingClientRect().top
90
+ setSide(room >= BUBBLE_ROOM_PX ? 'above' : 'below')
91
+ }
92
+ setOpen(true)
93
+ }
94
+ const schedule = (): void => {
95
+ clearTimeout(timer.current)
96
+ if (disabled) return
97
+ if (hovered.current || focused.current || dragging.current) {
98
+ if (!open) timer.current = setTimeout(show, focused.current ? 0 : OPEN_DELAY_MS)
99
+ return
100
+ }
101
+ timer.current = setTimeout(() => { setOpen(false) }, CLOSE_DELAY_MS)
102
+ }
103
+
104
+ const commit = (value: number): void => {
105
+ dragging.current = false
106
+ setLive(null)
107
+ props.onCommit(value)
108
+ schedule()
109
+ }
110
+ const onChange = (event: ChangeEvent<HTMLInputElement>): void => {
111
+ const value = Number(event.target.value)
112
+ setLive(value)
113
+ props.onInput(value)
114
+ }
115
+ const onKeyUp = (event: KeyboardEvent<HTMLInputElement>): void => {
116
+ if (live !== null) commit(live)
117
+ if (event.key === 'Escape') {
118
+ clearTimeout(timer.current)
119
+ setOpen(false)
120
+ }
121
+ }
122
+ const shown = live ?? Math.min(max, Math.max(min, props.value))
123
+
124
+ return (
125
+ <div
126
+ ref={anchorRef}
127
+ className={css.rangeAnchor}
128
+ onPointerEnter={() => { hovered.current = true; schedule() }}
129
+ onPointerLeave={() => { hovered.current = false; schedule() }}
130
+ onFocus={() => { focused.current = true; schedule() }}
131
+ onBlur={(event) => {
132
+ if (event.currentTarget.contains(event.relatedTarget as Node | null)) return
133
+ focused.current = false
134
+ if (live !== null) commit(live)
135
+ else schedule()
136
+ }}
137
+ >
138
+ {props.children}
139
+ <div className={css.rangeBubble} data-open={open ? '' : undefined} data-side={side}>
140
+ <input
141
+ type="range"
142
+ className={css.rangeSlider}
143
+ min={min}
144
+ max={max}
145
+ step={step}
146
+ value={shown}
147
+ aria-label={props.label}
148
+ tabIndex={open ? 0 : -1}
149
+ disabled={disabled}
150
+ style={{ '--range-fill': `${((shown - min) / (max - min)) * 100}%` } as CSSProperties}
151
+ onPointerDown={() => { dragging.current = true }}
152
+ onPointerUp={(event) => { commit(Number(event.currentTarget.value)) }}
153
+ onPointerCancel={(event) => { commit(Number(event.currentTarget.value)) }}
154
+ onChange={onChange}
155
+ onKeyUp={onKeyUp}
156
+ />
157
+ <span className={css.rangeEnds} aria-hidden="true">
158
+ <span>{min}</span>
159
+ <span>{max}</span>
160
+ </span>
161
+ </div>
162
+ </div>
163
+ )
164
+ }
@@ -0,0 +1,93 @@
1
+ // Generated by scripts/sync-shared.mjs from shared/client/settings/SegmentGroup.tsx. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
2
+ /**
3
+ * The family's segmented control: a quiet track whose options share one
4
+ * highlight that slides to the pressed option, instead of each option fading
5
+ * its own background out and the next one in. The settings fields' small
6
+ * choices and the Web Extensions TAB strip both render through it, so the two
7
+ * read as one control.
8
+ *
9
+ * The caller builds the option buttons and marks the pressed one with
10
+ * `data-active`; the group measures that button after every render and writes
11
+ * its box as four custom properties, and the stylesheet draws the highlight
12
+ * there (`.segmentGroup[data-pill]::before`). Attribute and first placement
13
+ * land in the same task, so the highlight appears in place and only later
14
+ * changes slide. A ResizeObserver re-measures when the group or an option
15
+ * changes size: a longer locale, a font arriving, a container growing, a
16
+ * strip wrapping onto a second line.
17
+ */
18
+
19
+ import { Children, useLayoutEffect, useRef, type HTMLAttributes, type ReactNode } from 'react'
20
+ import css from './settings-card.module.css'
21
+
22
+ /** The attribute marking a group whose highlight has been placed. */
23
+ const PILL_ATTR = 'data-pill'
24
+ /** The pressed option, relative to the group. */
25
+ const ACTIVE_SELECTOR = ':scope > [data-active]'
26
+ const PILL_PROPERTIES = ['--segment-pill-x', '--segment-pill-y', '--segment-pill-w', '--segment-pill-h'] as const
27
+
28
+ /** Props of {@link SegmentGroup}: the track's own attributes and the option buttons. */
29
+ export interface SegmentGroupProps extends HTMLAttributes<HTMLDivElement> {
30
+ /** The option buttons; the pressed one carries `data-active`. */
31
+ children: ReactNode
32
+ }
33
+
34
+ /**
35
+ * Write the highlight's box from the pressed option's box, or take the
36
+ * highlight off when nothing is pressed or the group has no layout yet.
37
+ * The two boxes are read in viewport pixels and turned back into the group's
38
+ * own CSS pixels, so a dialog that opens through a scale transform still
39
+ * lands the highlight on its option.
40
+ */
41
+ function placePill(group: HTMLElement): void {
42
+ const item = group.querySelector<HTMLElement>(ACTIVE_SELECTOR)
43
+ const box = group.getBoundingClientRect()
44
+ if (item === null || group.offsetWidth === 0 || box.width === 0) {
45
+ group.removeAttribute(PILL_ATTR)
46
+ for (const property of PILL_PROPERTIES) group.style.removeProperty(property)
47
+ return
48
+ }
49
+ const scale = box.width / group.offsetWidth
50
+ const itemBox = item.getBoundingClientRect()
51
+ const values = [
52
+ (itemBox.left - box.left) / scale - group.clientLeft,
53
+ (itemBox.top - box.top) / scale - group.clientTop,
54
+ itemBox.width / scale,
55
+ itemBox.height / scale,
56
+ ]
57
+ values.forEach((value, index) => {
58
+ group.style.setProperty(PILL_PROPERTIES[index], `${Math.round(value * 100) / 100}px`)
59
+ })
60
+ if (!group.hasAttribute(PILL_ATTR)) group.setAttribute(PILL_ATTR, '')
61
+ }
62
+
63
+ /**
64
+ * Render a segmented track around the caller's option buttons.
65
+ * @param props - the track's attributes (role, accessible name, key handler) and its options.
66
+ * @returns the track.
67
+ */
68
+ export function SegmentGroup(props: SegmentGroupProps): ReactNode {
69
+ const { children, className, ...rest } = props
70
+ const group = useRef<HTMLDivElement | null>(null)
71
+ const count = Children.count(children)
72
+
73
+ // Placed before the frame is painted, after every render: a press moves the
74
+ // pressed mark and the highlight follows it in the same frame.
75
+ useLayoutEffect(() => {
76
+ if (group.current !== null) placePill(group.current)
77
+ })
78
+
79
+ useLayoutEffect(() => {
80
+ const element = group.current
81
+ if (element === null || typeof ResizeObserver === 'undefined') return undefined
82
+ const observer = new ResizeObserver(() => { placePill(element) })
83
+ observer.observe(element)
84
+ for (const item of Array.from(element.children)) observer.observe(item)
85
+ return () => { observer.disconnect() }
86
+ }, [count])
87
+
88
+ return (
89
+ <div {...rest} ref={group} className={className === undefined ? css.segmentGroup : `${css.segmentGroup} ${className}`}>
90
+ {children}
91
+ </div>
92
+ )
93
+ }
@@ -0,0 +1,5 @@
1
+ /** CSS Modules are compiled into the bundle by the shared tsdown preset. */
2
+ declare module '*.module.css' {
3
+ const classes: Record<string, string>
4
+ export default classes
5
+ }
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Browser half of the task-board SSH provider.
3
+ *
4
+ * It registers the extension's copy, contributes one settings section into the
5
+ * task board's own settings card, and installs the provider's three rendering
6
+ * seats into the board: the task-detail section, the card badge, and the
7
+ * new-card section of the create dialog. Both halves of the extension's own
8
+ * switch are followed live: the seats appear and disappear with the settings
9
+ * section's `enabled` value, while the section itself stays reachable so the
10
+ * switch can be turned back on.
11
+ *
12
+ * Failure policy: a missing slot, settings surface, or board service is handled,
13
+ * never thrown — the web shell fails the whole boot when a plugin apply throws,
14
+ * and one external plugin must not take the GUI down.
15
+ *
16
+ * @module dsh-task-board-ssh/client
17
+ */
18
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
19
+ import type { ConfigForm, ConfigFormSnapshot, ConfigForms } from '@deepseek-ai/dsh-client-ui-settings/client'
20
+ // Type-only: pulls the settings-surface Context merge (ctx.configForms).
21
+ import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
22
+ // Type-only: pulls the locale plugin's Context merge (ctx.locale) and its
23
+ // LocaleNamespaceMap merge table.
24
+ import type {} from '@deepseek-ai/dsh-client-locale/client'
25
+ // Type-only: pulls the renderer's Context merge (ctx.slots) and uiRenderer.
26
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
27
+ import type {} from '@deepseek-ai/dsh-client-ui-slots'
28
+ import { SshSettingsCardController, SshSettingsSection, type SshSettings } from './ssh/settings-section.tsx'
29
+ import { installSshClientHalf, type ExtensionEnabledSource } from './ssh/extension.ts'
30
+ import { en, setRuntimeTranslate, zh, type TaskBoardSshKey } from './locales.ts'
31
+ import { createServedEntryForm } from './settings-entry-form.ts'
32
+
33
+ /** Locale namespace this half owns. */
34
+ export const NS = 'task-board-ssh'
35
+
36
+ /** Settings namespace the section edits: this extension's family settings identity. */
37
+ export const SETTINGS_NAMESPACE = 'task-board-ssh'
38
+
39
+ /**
40
+ * Profile entry id the family aggregate's generated row carries — the shape
41
+ * nearly every user runs, and the id the shared-forms fallback binds when the
42
+ * family binder cannot resolve the namespace.
43
+ */
44
+ const AGGREGATE_ENTRY_ID = 'web-ui-task-board-ssh'
45
+
46
+ /** Profile entry ids this package's patch rows carry, most specific first. */
47
+ const ENTRY_IDS: readonly string[] = [AGGREGATE_ENTRY_ID, 'ui-task-board-ssh', 'dsh-task-board-ssh', SETTINGS_NAMESPACE]
48
+
49
+ /**
50
+ * The family settings binder published by dsh-web-settings; absent when that
51
+ * group plugin is not installed.
52
+ */
53
+ interface SettingsFormBinder {
54
+ /** Resolve this package's family namespace onto the row the Host serves. */
55
+ bind<T>(spec: { namespace: string }): ConfigForm<T>
56
+ }
57
+
58
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
59
+ interface SlotMap {
60
+ /** Provider task-detail section; the board declares and renders it. */
61
+ 'task-board.detail.section': { kind: 'list'; scope: 'root'; owner: import('./seat-props.ts').SshDetailSectionProps }
62
+ /** Provider settings section; the board declares and renders it. */
63
+ 'task-board.settings.section': { kind: 'list'; scope: 'root'; owner: import('./seat-props.ts').SshSettingsSectionProps }
64
+ /** Provider card decoration; the board declares and renders it. */
65
+ 'task-board.card.decoration': { kind: 'list'; scope: 'root'; owner: import('./seat-props.ts').SshCardDecorationProps }
66
+ /** Provider new-card section; the board renders it inside the create dialog's execution settings. */
67
+ 'task-board.compose.section': { kind: 'list'; scope: 'root'; owner: import('./seat-props.ts').SshComposeSectionProps }
68
+ }
69
+
70
+ interface LocaleNamespaceMap {
71
+ /** The SSH provider extension copy. */
72
+ 'task-board-ssh': TaskBoardSshKey
73
+ }
74
+ }
75
+
76
+ declare module '@deepseek-ai/cordis' {
77
+ interface Context {
78
+ /**
79
+ * Optional family settings binder provided by dsh-web-settings; absent when
80
+ * that group plugin is not installed, so callers bind the shared forms
81
+ * service (`ctx.configForms`) by profile entry id directly.
82
+ */
83
+ webUiSettings?: SettingsFormBinder
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Required client services: the slot registry, the locale catalog, and the
89
+ * shared configuration forms the section stages over.
90
+ */
91
+ export const inject = ['slots', 'locale', 'configForms']
92
+
93
+ /**
94
+ * Bind the settings form the section stages over.
95
+ *
96
+ * The family binder comes first: it resolves this package's family namespace
97
+ * onto the profile entry id the Host serves the form under. A page without that
98
+ * group binds through the shared forms service on the entry id the describe
99
+ * mirror justifies, rebound as soon as the mirror answers.
100
+ * @param ctx - the browser plugin context.
101
+ * @returns the form the settings section reads and writes.
102
+ */
103
+ export function bindSettingsForm(ctx: ClientContext): ConfigForm<SshSettings> {
104
+ const binder = ctx.get('webUiSettings')
105
+ if (binder !== undefined && typeof binder.bind === 'function') {
106
+ return binder.bind<SshSettings>({ namespace: SETTINGS_NAMESPACE })
107
+ }
108
+ return createServedEntryForm<SshSettings>({
109
+ forms: ctx.configForms as ConfigForms,
110
+ entryIds: ENTRY_IDS,
111
+ })
112
+ }
113
+
114
+ /**
115
+ * A form for a page that serves this namespace to nobody: it never answers, so
116
+ * the section explains the missing namespace instead of pretending to be broken,
117
+ * and the seats still follow the documented default (enabled).
118
+ * @returns an inert configuration form.
119
+ */
120
+ function unavailableForm(): ConfigForm<SshSettings> {
121
+ const snapshot: ConfigFormSnapshot<SshSettings> = {
122
+ status: 'unavailable',
123
+ value: undefined,
124
+ base: undefined,
125
+ user: undefined,
126
+ revision: undefined,
127
+ writable: false,
128
+ }
129
+ return {
130
+ getSnapshot: () => snapshot,
131
+ subscribe: () => () => {},
132
+ set: async () => false,
133
+ unset: async () => false,
134
+ mutate: async () => false,
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Mount the extension's browser half: the dictionaries, the settings section,
140
+ * and the provider's child seats.
141
+ * @param ctx - the browser plugin context.
142
+ */
143
+ export function apply(ctx: ClientContext): void {
144
+ ctx.effect(() => {
145
+ try {
146
+ return ctx.locale.register(NS, { zh, en })
147
+ } catch {
148
+ return () => {}
149
+ }
150
+ }, 'task-board-ssh: dictionaries')
151
+
152
+ // Wire the SDK translate seat into the module-level t the child seats use: it
153
+ // reads the active locale at call time, so the seats follow a runtime language
154
+ // switch without a reload.
155
+ try { setRuntimeTranslate(ctx.locale.bind(NS)) } catch { /* locale missing: document-language fallback stays */ }
156
+
157
+ let scope: ConfigForm<SshSettings>
158
+ try {
159
+ scope = bindSettingsForm(ctx)
160
+ } catch {
161
+ // No settings surface on this page: the section is unavailable, but the
162
+ // provider's seats stay on their documented default.
163
+ scope = unavailableForm()
164
+ }
165
+
166
+ // The rendering seats follow the extension's own master switch, live: the
167
+ // settings form is the same volatile reference the Host commits an edit into.
168
+ const enabledSource: ExtensionEnabledSource = {
169
+ read: () => scope.getSnapshot().value?.enabled !== false,
170
+ subscribe: listener => scope.subscribe(listener),
171
+ }
172
+
173
+ let controller: SshSettingsCardController | undefined
174
+ try {
175
+ controller = new SshSettingsCardController(scope)
176
+ } catch {
177
+ // A form that cannot be staged over: the extension keeps its rendering
178
+ // seats and loses only the configuration section.
179
+ controller = undefined
180
+ }
181
+
182
+ // Seats. The rendering seats (task-detail section, card decoration and the
183
+ // create dialog's new-card section) sit behind both switches; the
184
+ // configuration section sits behind the board service alone, because it is
185
+ // where this extension's own switch lives — a section gated by that switch
186
+ // could never turn it back on.
187
+ const settingsSeat = controller === undefined
188
+ ? undefined
189
+ : { inject: () => controller.inject(), component: SshSettingsSection }
190
+ ctx.effect(() => installSshClientHalf(ctx, enabledSource, settingsSeat), 'task-board-ssh: provider seats')
191
+ if (controller !== undefined) {
192
+ const owned = controller
193
+ ctx.effect(() => () => { owned.dispose() }, 'task-board-ssh: provider settings section')
194
+ }
195
+ }