@linxin666/dsh-client-ui-task-board 0.4.8 → 0.4.9

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 (64) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +28 -22
  3. package/README.zh.md +28 -22
  4. package/lib/client.js +1435 -682
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +356 -366
  7. package/lib/types/client/PluginSettingsCard.d.ts +21 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +7 -0
  9. package/lib/types/client/board/ExecutionLog.d.ts +16 -0
  10. package/lib/types/client/board/TaskForm.d.ts +4 -0
  11. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  12. package/lib/types/client/body-mutations.d.ts +45 -0
  13. package/lib/types/client/locales.d.ts +42 -6
  14. package/lib/types/client/suppress-schedule-row.d.ts +86 -0
  15. package/lib/types/core/controller.d.ts +1 -1
  16. package/lib/types/core/subtask.d.ts +59 -49
  17. package/lib/types/core/tasks.d.ts +5 -8
  18. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  19. package/lib/types/core/workspace-target.d.ts +23 -3
  20. package/lib/types/host/launch-admission.d.ts +8 -9
  21. package/lib/types/host-ledger.d.ts +72 -48
  22. package/lib/types/host-routes.d.ts +49 -0
  23. package/lib/types/host-runner.d.ts +20 -10
  24. package/lib/types/host-service.d.ts +7 -50
  25. package/lib/types/index.d.ts +61 -63
  26. package/lib/types/loopback.d.ts +21 -0
  27. package/lib/types/protocol.d.ts +0 -5
  28. package/lib/types/tool-surface.d.ts +1 -0
  29. package/package.json +25 -25
  30. package/src/client/CardDefaultPresetField.tsx +1 -1
  31. package/src/client/PluginSettingsCard.tsx +78 -18
  32. package/src/client/TaskBoardSettingsCard.tsx +68 -25
  33. package/src/client/board/ExecutionLog.tsx +140 -0
  34. package/src/client/board/LinkSubtaskModal.tsx +1 -9
  35. package/src/client/board/NewTaskModal.tsx +2 -11
  36. package/src/client/board/TaskCard.tsx +45 -23
  37. package/src/client/board/TaskDetail.tsx +407 -261
  38. package/src/client/board/TaskForm.tsx +19 -4
  39. package/src/client/board/VerificationReport.tsx +143 -104
  40. package/src/client/board/task-markdown.module.css +11 -8
  41. package/src/client/board-settings.module.css +35 -7
  42. package/src/client/board.module.css +855 -115
  43. package/src/client/body-mutations.ts +133 -0
  44. package/src/client/index.ts +10 -0
  45. package/src/client/locales.ts +97 -24
  46. package/src/client/settings-card.module.css +71 -10
  47. package/src/client/suppress-schedule-row.ts +198 -0
  48. package/src/core/controller.ts +1 -3
  49. package/src/core/subtask.ts +81 -76
  50. package/src/core/tasks.ts +5 -9
  51. package/src/core/use-cases/task-update.ts +1 -3
  52. package/src/core/workspace-target.ts +27 -3
  53. package/src/host/agent-tools.ts +14 -15
  54. package/src/host/launch-admission.ts +8 -9
  55. package/src/host-ledger.ts +158 -125
  56. package/src/host-routes.ts +65 -2
  57. package/src/host-runner.ts +53 -28
  58. package/src/host-service.ts +42 -127
  59. package/src/index.ts +84 -106
  60. package/src/loopback.ts +32 -0
  61. package/src/protocol.ts +2 -9
  62. package/src/tool-surface.ts +1 -0
  63. package/lib/types/client/board/team-run-promotion.d.ts +0 -26
  64. package/src/client/board/team-run-promotion.ts +0 -39
@@ -9,8 +9,9 @@ import type { Context, Volatile } from '@deepseek-ai/cordis';
9
9
  import z from '@deepseek-ai/schemastery';
10
10
  import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
11
11
  import type { LlmRuntime } from '@deepseek-ai/dsh-llm';
12
- import { type HostTimerFace, type TaskBoardTeamDispatcher } from './host-service.ts';
12
+ import { type HostTimerFace } from './host-service.ts';
13
13
  import { type TaskPermission } from './core/tasks.ts';
14
+ import { type TaskBoardConnectionTrust } from './host-routes.ts';
14
15
  /** Default environment variable holding the authenticated proxy token. */
15
16
  export declare const DEFAULT_PROXY_TOKEN_ENV = "DSH_TASK_BOARD_PROXY_TOKEN";
16
17
  export declare const inject: string[];
@@ -46,6 +47,19 @@ export interface Config {
46
47
  trustedProxyHosts?: string[];
47
48
  /** Environment variable whose value the authenticated proxy injects upstream. */
48
49
  proxyTokenEnv?: string;
50
+ /**
51
+ * Whether the operator's OWN reverse proxy or tunnel may speak for the
52
+ * browser (default OFF). Off keeps the pre-existing fence exactly: a request
53
+ * that carries a forwarding header is never local, so only a direct loopback
54
+ * client or an allowlisted token-injecting proxy reaches the board (issue
55
+ * #1906). On admits one narrower case — a forwarded request whose socket and
56
+ * Host are both this machine's loopback upstream, i.e. the proxy dials the
57
+ * board itself (issue #1918) — and still requires the browser same-origin
58
+ * marker, so a third party's tunnel is only trusted while the operator says
59
+ * it is. Volatile: the fence reads it at each request, so an edit binds the
60
+ * next request without re-registering the routes.
61
+ */
62
+ trustForwardedProxy?: Volatile<boolean>;
49
63
  /**
50
64
  * An explicit baseline for the permission confirmation gate. Left unset, the
51
65
  * board follows the Host's own default permission preset — the value new DSH
@@ -58,8 +72,8 @@ export interface Config {
58
72
  /**
59
73
  * Subtask depth limit, 1..3 (default 1). At 1 a task may carry one level of
60
74
  * subtasks and a subtask cannot be given subtasks of its own; raising it
61
- * allows deeper trees. Every extra level multiplies the sessions one run
62
- * of the root task opens, so the ceiling is deliberately small.
75
+ * allows deeper trees. Every extra level is another tree the card's own
76
+ * session may have to dispatch, so the ceiling is deliberately small.
63
77
  */
64
78
  maxSubtaskDepth?: Volatile<number>;
65
79
  /**
@@ -71,13 +85,13 @@ export interface Config {
71
85
  sessionPollSeconds?: Volatile<number>;
72
86
  /**
73
87
  * How many run launches this board may have in flight at once (1..16,
74
- * default 3). One run opens its whole subtree, so without a bound the Host
75
- * asks DSH for every member's session in the same tick; this is the mechanism
76
- * that enforces the repository's measured guidance for heavy implementation
77
- * subagents. Members wait their turn instead of being dropped: the subtree
78
- * still opens completely, they only enter the running column in batches. Read
79
- * at each admission, so an edit bounds the next launch of a run that is still
80
- * queueing.
88
+ * default 3). A run opens one session, so a burst is several cards run at
89
+ * once (several tabs, or a due schedule firing while a manual run starts);
90
+ * without a bound the Host would ask DSH for all of them in the same tick.
91
+ * This is the mechanism that enforces the repository's measured guidance for
92
+ * heavy implementation subagents. Runs wait their turn instead of being
93
+ * dropped, and every one of them still starts. Read at each admission, so an
94
+ * edit bounds the next launch of a run that is still queueing.
81
95
  */
82
96
  runLaunchWidth?: Volatile<number>;
83
97
  /**
@@ -89,12 +103,6 @@ export interface Config {
89
103
  * is skipped onto the scheduler with its run budget untouched.
90
104
  */
91
105
  spendBudgetTokens?: Volatile<number>;
92
- /**
93
- * Continuable-subagent provider the Agent Teams service uses to compose a
94
- * teammate. Matches the Agent Teams tool plugin's `freshProvider` default;
95
- * only team-mode runs use it.
96
- */
97
- teamProvider?: string;
98
106
  /**
99
107
  * GLOBAL native /goal switch (default OFF), the master control over whether
100
108
  * this board starts a run with dsh's built-in /goal at all. A run uses native
@@ -181,11 +189,6 @@ export interface Config {
181
189
  */
182
190
  goalVerificationBudgetSeconds?: Volatile<number>;
183
191
  }
184
- /**
185
- * Continuable-subagent provider for fresh teammates, matching the Agent Teams
186
- * tool plugin's own `freshProvider` default.
187
- */
188
- export declare const DEFAULT_TEAM_PROVIDER = "spawn";
189
192
  /**
190
193
  * Profile-patch shape of {@link Config}: what the Host validates the row's
191
194
  * config against, before the schema turns volatile fields into live references
@@ -207,6 +210,8 @@ export interface ConfigInput {
207
210
  trustedProxyHosts?: string[];
208
211
  /** Environment variable whose value the authenticated proxy injects. */
209
212
  proxyTokenEnv?: string;
213
+ /** Trust a forwarded request that landed on this machine's loopback upstream; default off. */
214
+ trustForwardedProxy?: boolean;
210
215
  /** Explicit baseline for the permission confirmation gate; unset follows the Host default. */
211
216
  sessionDefaultPermission?: TaskPermission;
212
217
  /** Subtask depth limit, 1..3. */
@@ -217,8 +222,6 @@ export interface ConfigInput {
217
222
  runLaunchWidth?: number;
218
223
  /** Daily token ceiling for board runs; 0 disables the gate. */
219
224
  spendBudgetTokens?: number;
220
- /** Continuable-subagent provider the Agent Teams service composes a teammate from. */
221
- teamProvider?: string;
222
225
  /** Global native /goal switch; default off, frozen per execution. */
223
226
  goalRunEnabled?: boolean;
224
227
  /** Agent preset a new card starts from; blank = not set. */
@@ -274,11 +277,45 @@ declare module '@deepseek-ai/cordis' {
274
277
  * @returns the effective field value.
275
278
  */
276
279
  export declare function readConfigField<T>(field: Volatile<T> | T | undefined, fallback: T): T;
277
- /** Resolve proxy access without ever placing the token value in plugin config. */
280
+ /**
281
+ * Resolve proxy access without ever placing the token value in plugin config.
282
+ *
283
+ * The forwarded-proxy switch travels as a reader rather than a value: it is
284
+ * schema-volatile, so the fence must read it when a request arrives instead of
285
+ * when the routes are registered.
286
+ * @param config - the resolved plugin config.
287
+ * @param env - environment holding the proxy token value.
288
+ * @returns the route access handed to {@link makeTaskBoardRoutes}.
289
+ */
278
290
  export declare function resolveProxyAccess(config: Config | undefined, env?: NodeJS.ProcessEnv): {
279
291
  trustedProxyHosts: string[];
280
292
  proxyToken?: string;
293
+ trustForwardedProxy: () => boolean;
281
294
  };
295
+ /**
296
+ /**
297
+ * Schema default for the forwarded-proxy switch, re-read for hand-built
298
+ * contexts. Deliberately false: a deployment that never configured it keeps
299
+ * refusing every forwarded request, which is the #1906 fence.
300
+ */
301
+ export declare const DEFAULT_TRUST_FORWARDED_PROXY = false;
302
+ /**
303
+ * Resolve the composition's optional `connection` service.
304
+ *
305
+ * The service is the Host's own browser-session authority: it fronts every
306
+ * `/api` request with the Host/Origin fence and the signed `dsh-auth-*` cookie,
307
+ * which is what a deployment behind a reverse proxy or ingress validates on the
308
+ * same authority the GUI is served from. The board bridges it instead of
309
+ * repeating that check, so a proxy request the Host already authenticated is
310
+ * admitted without a board-specific host allowlist (issue #1930). It is
311
+ * deliberately resolved like the agent-tool registry rather than injected:
312
+ * a composition that serves no connection keeps mounting the board on the
313
+ * pre-existing loopback fence, and one that mounts the service later is picked
314
+ * up on the next request because the fence asks this resolver each time.
315
+ * @param ctx - the plugin context.
316
+ * @returns the trust face, or undefined when this deployment serves none.
317
+ */
318
+ export declare function resolveConnectionTrust(ctx: Context): TaskBoardConnectionTrust | undefined;
282
319
  /** The registry face the agent tools register into. */
283
320
  interface AgentToolRegistry {
284
321
  register(definition: ToolDefinition): () => void;
@@ -316,45 +353,6 @@ export declare function resolveHostTimers(ctx: Context): HostTimerFace | undefin
316
353
  * @returns the Host default as a board permission, or undefined when unreadable.
317
354
  */
318
355
  export declare function resolveHostDefaultPermission(ctx: Context): TaskPermission | undefined;
319
- /** The subset of the Agent Teams service this plugin drives. */
320
- interface AgentTeamsFace {
321
- spawnTeammate(caller: unknown, request: {
322
- name: string;
323
- description: string;
324
- prompt: Array<{
325
- type: 'text';
326
- text: string;
327
- }>;
328
- context: 'fresh' | 'fork';
329
- provider: string;
330
- signal: AbortSignal;
331
- }): Promise<{
332
- member?: {
333
- id?: string;
334
- phase?: string;
335
- error?: string;
336
- };
337
- }>;
338
- }
339
- /**
340
- * Resolve the optional Agent Teams service. Like the tool registry and the llm
341
- * runtime, it is deliberately not injected: a deployment without Agent Teams
342
- * must still mount the whole board and only lose team-mode runs.
343
- * @param ctx - the plugin context.
344
- * @returns the service, or undefined when this deployment serves none.
345
- */
346
- export declare function resolveAgentTeams(ctx: Context): AgentTeamsFace | undefined;
347
- /**
348
- * Build the team dispatcher: the run's Lead session spawns one teammate per
349
- * subtask through the Agent Teams service, and the teammate's session id is
350
- * attached to that subtask's execution so the ordinary session monitor settles
351
- * it. Returns undefined when the deployment serves no Agent Teams service or
352
- * no live-agent registry, which makes a team run fail closed.
353
- * @param ctx - the plugin context.
354
- * @param provider - the continuable-subagent provider for fresh teammates.
355
- * @returns the dispatcher, or undefined when team runs cannot be served.
356
- */
357
- export declare function buildTeamDispatcher(ctx: Context, provider: string): TaskBoardTeamDispatcher | undefined;
358
356
  /**
359
357
  * Read the optional `llm` service. The board deliberately does not inject it:
360
358
  * a deployment without a model must still mount the board, and the parse route
@@ -15,6 +15,11 @@
15
15
  * request. Forwarding headers are the signal that a hop stands in between: a
16
16
  * request that carries CF-Connecting-IP or X-Forwarded-For is answered through
17
17
  * a proxy and is never treated as a local one (issue #1906).
18
+ *
19
+ * An operator who runs that proxy or tunnel themselves can opt into the
20
+ * narrower case: isForwardedLoopbackRequest describes a forwarded request that
21
+ * still landed on this machine's loopback upstream, and a route family admits
22
+ * it only behind its own default-off switch (issue #1918).
18
23
  * @module dsh-web-shared/host/loopback
19
24
  */
20
25
  import type { IncomingMessage } from 'node:http';
@@ -41,3 +46,19 @@ export declare function isProxiedRequest(request: IncomingMessage): boolean;
41
46
  * client. X-Forwarded-For is therefore never evidence *for* loopback.
42
47
  */
43
48
  export declare function isLoopbackRequest(request: IncomingMessage): boolean;
49
+ /**
50
+ * Whether a forwarded request landed on this machine's loopback upstream: a
51
+ * forwarding header (the proxy's own stamp), a loopback socket address (the
52
+ * proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
53
+ * the authority to its upstream literal).
54
+ *
55
+ * This is a fact about the route, not a trust decision. A public request to a
56
+ * tunnel satisfies all three by construction, because the proxy is the client
57
+ * of this process: only a caller that operates the proxy can decide it stands
58
+ * for the browser, which is why every consumer keeps this behind an explicit
59
+ * default-off switch and its own browser markers. isLoopbackRequest is
60
+ * unchanged and still refuses a forwarded request (issue #1906).
61
+ * @param request - node HTTP request.
62
+ * @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
63
+ */
64
+ export declare function isForwardedLoopbackRequest(request: IncomingMessage): boolean;
@@ -61,11 +61,6 @@ export interface TaskBoardSnapshot {
61
61
  * disable the subtask controls; the Host ledger is the authority.
62
62
  */
63
63
  maxSubtaskDepth?: number;
64
- /**
65
- * Whether this deployment serves the Agent Teams service, so a task may opt
66
- * into team execution (Team Lead session plus one teammate per subtask).
67
- */
68
- teamRunAvailable?: boolean;
69
64
  /**
70
65
  * Live GLOBAL native-/goal switch. The browser uses it to disable the
71
66
  * task-level option (and explain that the global switch must be turned on
@@ -30,6 +30,7 @@
30
30
  export declare const PLUGIN_TOOL_SECTION_ORDERS: {
31
31
  readonly ssh: 150;
32
32
  readonly 'task-board': 200;
33
+ readonly agents: 220;
33
34
  };
34
35
  /** One plugin id keyed by {@link PLUGIN_TOOL_SECTION_ORDERS}. */
35
36
  export type PluginToolSectionId = keyof typeof PLUGIN_TOOL_SECTION_ORDERS;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-task-board",
3
3
  "description": "Host-authoritative task board for the DSH Web GUI with real session execution, Host cron scheduling, and optional cross-platform idle-sleep protection; mounted without DSH source changes.",
4
- "version": "0.4.8",
4
+ "version": "0.4.9",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dsh": {
22
22
  "engines": {
23
- "dsh": ">=0.2.1-rc.2"
23
+ "dsh": ">=0.2.1-rc.3"
24
24
  },
25
25
  "bundle": {
26
26
  "patch": "./cordis.patch.yml"
@@ -40,7 +40,7 @@
40
40
  }
41
41
  },
42
42
  "peerDependencies": {
43
- "@deepseek-ai/dsh": ">=0.2.1-rc.2",
43
+ "@deepseek-ai/dsh": ">=0.2.1-rc.3",
44
44
  "react": "^18.2.0"
45
45
  },
46
46
  "dependencies": {
@@ -49,28 +49,28 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@deepseek-ai/cordis": "^4.0.5",
52
- "@deepseek-ai/dsh-agent": "^0.2.1-rc.2",
53
- "@deepseek-ai/dsh-agent-preset-registry": "^0.2.1-rc.2",
54
- "@deepseek-ai/dsh-api-gateway": "^0.2.1-rc.2",
55
- "@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.2",
56
- "@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.2",
57
- "@deepseek-ai/dsh-api-workspace-controller": "^0.2.1-rc.2",
58
- "@deepseek-ai/dsh-client-connection": "^0.2.1-rc.2",
59
- "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.2",
60
- "@deepseek-ai/dsh-client-store": "^0.2.1-rc.2",
61
- "@deepseek-ai/dsh-client-ui-layout": "^0.2.1-rc.2",
62
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.2",
63
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.2",
64
- "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.1-rc.2",
65
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.2",
66
- "@deepseek-ai/dsh-client-ui-workspace": "^0.2.1-rc.2",
67
- "@deepseek-ai/dsh-commands": "^0.2.1-rc.2",
68
- "@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.2",
69
- "@deepseek-ai/dsh-llm": "^0.2.1-rc.2",
70
- "@deepseek-ai/dsh-settings": "^0.2.1-rc.2",
71
- "@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.2",
72
- "@deepseek-ai/dsh-tools": "^0.2.1-rc.2",
73
- "@deepseek-ai/dsh-workspace": "^0.2.1-rc.2",
52
+ "@deepseek-ai/dsh-agent": "^0.2.1-rc.3",
53
+ "@deepseek-ai/dsh-agent-preset-registry": "^0.2.1-rc.3",
54
+ "@deepseek-ai/dsh-api-gateway": "^0.2.1-rc.3",
55
+ "@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.3",
56
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.3",
57
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.2.1-rc.3",
58
+ "@deepseek-ai/dsh-client-connection": "^0.2.1-rc.3",
59
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.3",
60
+ "@deepseek-ai/dsh-client-store": "^0.2.1-rc.3",
61
+ "@deepseek-ai/dsh-client-ui-layout": "^0.2.1-rc.3",
62
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.3",
63
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.3",
64
+ "@deepseek-ai/dsh-client-ui-sidebar": "^0.2.1-rc.3",
65
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.3",
66
+ "@deepseek-ai/dsh-client-ui-workspace": "^0.2.1-rc.3",
67
+ "@deepseek-ai/dsh-commands": "^0.2.1-rc.3",
68
+ "@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.3",
69
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.3",
70
+ "@deepseek-ai/dsh-settings": "^0.2.1-rc.3",
71
+ "@deepseek-ai/dsh-system-prompt": "^0.2.1-rc.3",
72
+ "@deepseek-ai/dsh-tools": "^0.2.1-rc.3",
73
+ "@deepseek-ai/dsh-workspace": "^0.2.1-rc.3",
74
74
  "@types/node": "^22.20.0",
75
75
  "@types/react": "~18.3.1",
76
76
  "@types/react-dom": "^18.3.5",
@@ -93,7 +93,7 @@ export function CardDefaultPresetField(props: CardDefaultPresetFieldProps) {
93
93
  )
94
94
  : null}
95
95
  </select>
96
- <p className={props.invalid ? css.invalid : css.hint}>
96
+ <p className={props.invalid ? css.invalid : css.hint} title={props.hintTitle}>
97
97
  {props.invalid ? props.invalidLabel : props.hint}
98
98
  </p>
99
99
  </div>
@@ -41,6 +41,14 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
41
41
  descriptionKey: TKey
42
42
  /** Optional rich header description rendered instead of the plain t(descriptionKey) text (the plain text stays as the tooltip). */
43
43
  descriptionNode?: ReactNode
44
+ /**
45
+ * Locale key of the full sentence behind a shortened description: when
46
+ * present, the header's native `title` takes this text while the visible
47
+ * line keeps `descriptionKey`/`descriptionNode`, so a compact card can
48
+ * compress the sentence without keeping a second visible copy of it.
49
+ * Defaults to the description key.
50
+ */
51
+ descriptionTitleKey?: TKey
44
52
  /**
45
53
  * Optional leading mark identifying the plugin. A card without one keeps the
46
54
  * plain official header shape, so the chrome stays a readable sibling of the
@@ -95,10 +103,27 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
95
103
  renderChildrenWhenNotExposed?: boolean
96
104
  /** Hide the 'not exposed' warning banner when the settings namespace is not exposed. */
97
105
  hideNotExposedNotice?: boolean
106
+ /**
107
+ * Compact chrome for a topic card rendered inside another card's body: a
108
+ * smaller title, a tighter header and body inset, and a one-line description
109
+ * whose full text stays on the header's own title. Defaults to the
110
+ * first-level chrome, which is unchanged.
111
+ */
112
+ density?: 'nested'
98
113
  /** The plugin's controls. */
99
114
  children: ReactNode
100
115
  }
101
116
 
117
+ /** Length of the body's disclosure motion; it matches `--settings-card-motion` on the card root. */
118
+ const BODY_MOTION_MS = 180
119
+
120
+ /**
121
+ * Lifecycle of one card body. `collapsed` is the mounted-but-closed frame the
122
+ * enter leg starts from, `entering` and `closing` are the two moving legs, and
123
+ * `shown` is the settled open body, which releases its clipping box.
124
+ */
125
+ type BodyPhase = 'hidden' | 'collapsed' | 'entering' | 'shown' | 'closing'
126
+
102
127
  /**
103
128
  * Render one plugin settings card.
104
129
  * @param props - the plugin's copy keys, its form state, and its controls.
@@ -107,12 +132,47 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
107
132
  export function PluginSettingsCard<TKey extends string = string>(props: PluginSettingsCardProps<TKey>) {
108
133
  const [open, setOpen] = useState(props.defaultOpen ?? true)
109
134
  const { state, alwaysOpen } = props
135
+ const expanded = alwaysOpen === true || open
136
+ const [bodyPhase, setBodyPhase] = useState<BodyPhase>(expanded ? 'shown' : 'hidden')
137
+ const bodyRef = useRef<HTMLDivElement | null>(null)
138
+ // Enter and leave run the same pair: a body that should open is mounted
139
+ // closed for one frame so its transition has a state to leave, and a closing
140
+ // one stays mounted until its leg has run.
141
+ useLayoutEffect(() => {
142
+ if (expanded) {
143
+ if (bodyPhase === 'hidden') setBodyPhase('collapsed')
144
+ else if (bodyPhase === 'collapsed') {
145
+ const node = bodyRef.current
146
+ if (node !== null) void node.offsetHeight
147
+ setBodyPhase('entering')
148
+ } else if (bodyPhase === 'closing') setBodyPhase('entering')
149
+ return
150
+ }
151
+ if (bodyPhase === 'collapsed') setBodyPhase('hidden')
152
+ else if (bodyPhase === 'entering' || bodyPhase === 'shown') setBodyPhase('closing')
153
+ }, [expanded, bodyPhase])
154
+ useEffect(() => {
155
+ if (bodyPhase !== 'entering' && bodyPhase !== 'closing') return
156
+ const timer = setTimeout(() => {
157
+ setBodyPhase(bodyPhase === 'entering' ? 'shown' : 'hidden')
158
+ }, BODY_MOTION_MS)
159
+ return () => { clearTimeout(timer) }
160
+ }, [bodyPhase])
110
161
  if (!state.available) return null
111
162
  const title = props.t(props.titleKey)
112
163
  const description = props.t(props.descriptionKey)
164
+ const descriptionTitle = props.descriptionTitleKey === undefined ? description : props.t(props.descriptionTitleKey)
113
165
  const blocked = !state.dirty || state.invalid || state.saving
114
- const expanded = alwaysOpen === true || open
115
- const cardClass = expanded ? `${css.cardOpen} ${css.card}` : css.card
166
+ const baseClass = expanded ? `${css.cardOpen} ${css.card}` : css.card
167
+ const cardClass = props.density === 'nested' ? `${baseClass} ${css.cardNested}` : baseClass
168
+ /** The body region both legs share; a hidden phase renders nothing at all. */
169
+ const bodyRegion = (content: ReactNode) => bodyPhase === 'hidden'
170
+ ? null
171
+ : (
172
+ <div className={css.disclosure} data-state={bodyPhase} ref={bodyRef}>
173
+ <div className={css.body}>{content}</div>
174
+ </div>
175
+ )
116
176
  // With alwaysOpen the nav entry already provides the selection, so the
117
177
  // header is a static title row instead of a disclosure button.
118
178
  const header = alwaysOpen === true
@@ -121,7 +181,7 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
121
181
  {props.icon !== undefined ? <span className={css.mark} aria-hidden="true">{props.icon}</span> : null}
122
182
  <span className={css.headText}>
123
183
  <span className={css.name} id={props.titleId} title={title}>{title}</span>
124
- <span className={css.description} title={description}>{props.descriptionNode ?? description}</span>
184
+ <span className={css.description} title={descriptionTitle}>{props.descriptionNode ?? description}</span>
125
185
  </span>
126
186
  {props.headerAction !== undefined ? <span className={css.headerAction}>{props.headerAction}</span> : null}
127
187
  {state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}
@@ -138,7 +198,7 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
138
198
  {props.icon !== undefined ? <span className={css.mark} aria-hidden="true">{props.icon}</span> : null}
139
199
  <span className={css.headText}>
140
200
  <span className={css.name} id={props.titleId} title={title}>{title}</span>
141
- <span className={css.description} title={description}>{props.descriptionNode ?? description}</span>
201
+ <span className={css.description} title={descriptionTitle}>{props.descriptionNode ?? description}</span>
142
202
  </span>
143
203
  {props.headerAction !== undefined ? <span className={css.headerAction}>{props.headerAction}</span> : null}
144
204
  {state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}
@@ -166,25 +226,19 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
166
226
  return (
167
227
  <li className={cardClass}>
168
228
  {header}
169
- {expanded
170
- ? (
171
- <div className={css.body}>
172
- {showNotice ? <p className={css.notExposed} role="status">{props.t('settings.notExposed')}</p> : null}
173
- </div>
174
- )
175
- : null}
229
+ {bodyRegion(showNotice ? <p className={css.notExposed} role="status">{props.t('settings.notExposed')}</p> : null)}
176
230
  </li>
177
231
  )
178
232
  }
179
233
  // A header-only card has no body region at all: the divider would otherwise
180
234
  // sit above an empty box.
181
- const bodyVisible = expanded && props.headerOnly !== true
235
+ const bodyVisible = props.headerOnly !== true
182
236
  return (
183
237
  <li className={cardClass}>
184
238
  {header}
185
239
  {bodyVisible
186
- ? (
187
- <div className={css.body}>
240
+ ? bodyRegion(
241
+ <>
188
242
  {!state.writable ? <p className={css.readOnly} role="status">{props.t('settings.readOnly')}</p> : null}
189
243
  {props.children}
190
244
  {props.hideFooter === true
@@ -216,7 +270,7 @@ export function PluginSettingsCard<TKey extends string = string>(props: PluginSe
216
270
  </button>
217
271
  </div>
218
272
  )}
219
- </div>
273
+ </>,
220
274
  )
221
275
  : null}
222
276
  </li>
@@ -231,6 +285,12 @@ export interface FieldProps {
231
285
  label: string
232
286
  /** One-line explanation rendered under the control. */
233
287
  hint: string
288
+ /**
289
+ * Full sentence behind the visible hint, exposed as the paragraph's native
290
+ * `title` so a card can shorten the line without losing the text. Omitted:
291
+ * the paragraph carries no title attribute at all.
292
+ */
293
+ hintTitle?: string
234
294
  /** Draft text this control renders. */
235
295
  text: string
236
296
  /** True when saving would leave a user-layer entry for this field. */
@@ -289,7 +349,7 @@ export function ValueField(props: FieldProps & {
289
349
  disabled={props.disabled}
290
350
  onChange={(event) => { props.onEdit(event.target.value) }}
291
351
  />
292
- <p className={props.invalid ? css.invalid : css.hint}>
352
+ <p className={props.invalid ? css.invalid : css.hint} title={props.hintTitle}>
293
353
  {props.invalid ? props.invalidLabel : props.hint}
294
354
  </p>
295
355
  </div>
@@ -541,7 +601,7 @@ export function BooleanField(props: FieldProps & {
541
601
  invalid={props.invalid}
542
602
  onEdit={props.onEdit}
543
603
  />
544
- <p className={css.hint}>{props.hint}</p>
604
+ <p className={css.hint} title={props.hintTitle}>{props.hint}</p>
545
605
  </div>
546
606
  )
547
607
  }
@@ -581,7 +641,7 @@ export function ChoiceField(props: FieldProps & {
581
641
  invalid={props.invalid}
582
642
  onEdit={props.onEdit}
583
643
  />
584
- <p className={props.invalid ? css.invalid : css.hint}>
644
+ <p className={props.invalid ? css.invalid : css.hint} title={props.hintTitle}>
585
645
  {props.invalid ? props.invalidLabel : props.hint}
586
646
  </p>
587
647
  </div>