@ruckc/truss-chat 1.41.0 → 1.42.0

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.
@@ -4,7 +4,7 @@
4
4
  import { Button, Dialog, Icon, Tooltip } from '@ruckc/truss-ui';
5
5
  import { formatValue, previewInput } from './chat.js';
6
6
 
7
- type Status = 'pending' | 'awaiting' | 'in_progress' | 'completed' | 'failed';
7
+ type Status = 'pending' | 'awaiting' | 'in_progress' | 'completed' | 'failed' | 'skipped';
8
8
 
9
9
  let {
10
10
  name,
@@ -13,6 +13,7 @@
13
13
  formatName,
14
14
  labels,
15
15
  summary,
16
+ reason,
16
17
  input,
17
18
  output,
18
19
  error,
@@ -26,16 +27,18 @@
26
27
  }: Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
27
28
  /** The tool's display name. Pass a raw identifier together with `formatName` to tidy it. */
28
29
  name: string;
29
- /** Where the call is: `pending` (queued), `awaiting` (waiting for the user to confirm or approve it), `in_progress`, `completed` or `failed`. Shown as an icon (a spinner while `in_progress`, a question mark while `awaiting`) and always as text (the row's label, the chip's accessible name and tooltip), never by colour alone. */
30
+ /** Where the call is: `pending` (queued), `awaiting` (waiting for the user to confirm or approve it), `in_progress`, `completed` `failed` or `skipped` (not run: nothing executed, so neither a failure nor still waiting; shown muted with a ban icon). Shown as an icon (a spinner while `in_progress`, a question mark while `awaiting`) and always as text (the row's label, the chip's accessible name and tooltip), never by colour alone. */
30
31
  status?: Status;
31
32
  /** `row` (default) is a full-width line with the status text, for a list of calls. `chip` is a compact pill coloured by status with a tooltip, for many calls side by side (wrap them in `ToolCalls`). */
32
33
  variant?: 'row' | 'chip';
33
34
  /** Turns `name` into what is displayed, e.g. `formatToolName`, which strips an `mcp__server__` prefix and replaces underscores with spaces (`mcp__github__create_issue` becomes `create issue`). */
34
35
  formatName?: (name: string) => string;
35
- /** Replaces the status texts, e.g. for another language. Missing keys keep the defaults: Pending, Awaiting confirmation, Running, Done, Failed. */
36
+ /** Replaces the status texts, e.g. for another language. Missing keys keep the defaults: Pending, Awaiting confirmation, Running, Done, Failed, Not run. */
36
37
  labels?: Partial<Record<Status, string>>;
37
38
  /** A one-line result for the row, e.g. "3 rows" or the error message: shown between the name and the status, muted and cut with an ellipsis (the full text is its tooltip and is repeated in the details). In a chip it is added to the tooltip and the accessible name. */
38
39
  summary?: string;
40
+ /** Why the call did not run, for `status="skipped"`, e.g. "depends on a denied change". Takes the place of `summary`: shown in the row beside the status, added to the chip's tooltip and accessible name, and repeated as "Reason" in the details. */
41
+ reason?: string;
39
42
  /** What the tool was called with: a string or any JSON-able value. Shown as a one-line preview in the chip's tooltip (see `previewInput`) and in full, pretty-printed, in the details. */
40
43
  input?: unknown;
41
44
  /** What the tool returned: a string or any JSON-able value. Pretty-printed in the details. */
@@ -62,8 +65,8 @@
62
65
  } = $props();
63
66
 
64
67
  const uid = $props.id();
65
- const DEFAULTS: Record<Status, string> = { pending: 'Pending', awaiting: 'Awaiting confirmation', in_progress: 'Running', completed: 'Done', failed: 'Failed' };
66
- const ICONS = { pending: 'clock', awaiting: 'help', in_progress: 'refresh', completed: 'success', failed: 'error' } as const;
68
+ const DEFAULTS: Record<Status, string> = { pending: 'Pending', awaiting: 'Awaiting confirmation', in_progress: 'Running', completed: 'Done', failed: 'Failed', skipped: 'Not run' };
69
+ const ICONS = { pending: 'clock', awaiting: 'help', in_progress: 'refresh', completed: 'success', failed: 'error', skipped: 'ban' } as const;
67
70
  const shown = $derived(formatName ? formatName(name) : name);
68
71
  const statusText = $derived(labels?.[status] ?? DEFAULTS[status]);
69
72
 
@@ -88,8 +91,9 @@
88
91
  };
89
92
  const hasBody = $derived(!!custom || sections.length > 0);
90
93
  const preview = $derived(previewInput(input));
91
- const tip = $derived(summary ? `${statusText}: ${summary}` : preview ? `${statusText}: ${preview}` : statusText);
92
- const spoken = $derived(summary ? `${shown}, ${statusText}, ${summary}` : `${shown}, ${statusText}`);
94
+ const line = $derived(reason || summary);
95
+ const tip = $derived(line ? `${statusText}: ${line}` : preview ? `${statusText}: ${preview}` : statusText);
96
+ const spoken = $derived(line ? `${shown}, ${statusText}, ${line}` : `${shown}, ${statusText}`);
93
97
 
94
98
  // the dialog is created on first use, so a long list of calls does not render every call's details up front
95
99
  let mounted = $state(false);
@@ -126,7 +130,7 @@
126
130
 
127
131
  {#snippet body()}
128
132
  <p class="line">Status: <strong>{statusText}</strong></p>
129
- {#if summary}<p class="line">Result: <strong>{summary}</strong></p>{/if}
133
+ {#if line}<p class="line">{reason ? 'Reason' : 'Result'}: <strong>{line}</strong></p>{/if}
130
134
  {#if custom}{@render custom()}{/if}
131
135
  {#each sections as s (s.key)}
132
136
  {@const c = cut(s.text, s.key)}
@@ -180,11 +184,11 @@
180
184
  aria-controls={mode === 'inline' ? `${uid}-details` : undefined}
181
185
  onclick={() => (open = !open)}
182
186
  >
183
- {@render lead()}<span class="name">{shown}</span>{#if summary}<span class="summary" title={summary}>{summary}</span>{/if}<span class="status">{statusText}</span>
187
+ {@render lead()}<span class="name">{shown}</span>{#if line}<span class="summary" title={line}>{line}</span>{/if}<span class="status">{statusText}</span>
184
188
  {#if mode === 'inline'}<span class="chev" data-open={open}><Icon name="chevron-down" /></span>{/if}
185
189
  </button>
186
190
  {:else}
187
- <div class="row">{@render lead()}<span class="name">{shown}</span>{#if summary}<span class="summary" title={summary}>{summary}</span>{/if}<span class="status">{statusText}</span></div>
191
+ <div class="row">{@render lead()}<span class="name">{shown}</span>{#if line}<span class="summary" title={line}>{line}</span>{/if}<span class="status">{statusText}</span></div>
188
192
  {/if}
189
193
  {#if hasBody && mode === 'inline' && open}
190
194
  <div class="details" id="{uid}-details">{@render body()}</div>
@@ -233,6 +237,7 @@
233
237
  [data-status='completed'] .chip { background: var(--tr-success-container); color: var(--tr-on-success-container); border-color: transparent; }
234
238
  [data-status='failed'] .chip { background: var(--tr-danger-container); color: var(--tr-on-danger-container); border-color: transparent; }
235
239
  [data-status='awaiting'] .chip { background: var(--tr-warning-container); color: var(--tr-on-warning-container); border-color: transparent; }
240
+ [data-status='skipped'] .chip { background: var(--tr-surface-container-high); color: var(--tr-on-surface-variant); border-color: transparent; }
236
241
  [data-status='pending'] .chip { color: var(--tr-on-surface-variant); border-style: dashed; }
237
242
 
238
243
  .line { margin: 0 0 var(--tr-space-2); color: var(--tr-on-surface-variant); }
@@ -1,19 +1,21 @@
1
1
  import { type Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
- type Status = 'pending' | 'awaiting' | 'in_progress' | 'completed' | 'failed';
3
+ type Status = 'pending' | 'awaiting' | 'in_progress' | 'completed' | 'failed' | 'skipped';
4
4
  type $$ComponentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
5
5
  /** The tool's display name. Pass a raw identifier together with `formatName` to tidy it. */
6
6
  name: string;
7
- /** Where the call is: `pending` (queued), `awaiting` (waiting for the user to confirm or approve it), `in_progress`, `completed` or `failed`. Shown as an icon (a spinner while `in_progress`, a question mark while `awaiting`) and always as text (the row's label, the chip's accessible name and tooltip), never by colour alone. */
7
+ /** Where the call is: `pending` (queued), `awaiting` (waiting for the user to confirm or approve it), `in_progress`, `completed` `failed` or `skipped` (not run: nothing executed, so neither a failure nor still waiting; shown muted with a ban icon). Shown as an icon (a spinner while `in_progress`, a question mark while `awaiting`) and always as text (the row's label, the chip's accessible name and tooltip), never by colour alone. */
8
8
  status?: Status;
9
9
  /** `row` (default) is a full-width line with the status text, for a list of calls. `chip` is a compact pill coloured by status with a tooltip, for many calls side by side (wrap them in `ToolCalls`). */
10
10
  variant?: 'row' | 'chip';
11
11
  /** Turns `name` into what is displayed, e.g. `formatToolName`, which strips an `mcp__server__` prefix and replaces underscores with spaces (`mcp__github__create_issue` becomes `create issue`). */
12
12
  formatName?: (name: string) => string;
13
- /** Replaces the status texts, e.g. for another language. Missing keys keep the defaults: Pending, Awaiting confirmation, Running, Done, Failed. */
13
+ /** Replaces the status texts, e.g. for another language. Missing keys keep the defaults: Pending, Awaiting confirmation, Running, Done, Failed, Not run. */
14
14
  labels?: Partial<Record<Status, string>>;
15
15
  /** A one-line result for the row, e.g. "3 rows" or the error message: shown between the name and the status, muted and cut with an ellipsis (the full text is its tooltip and is repeated in the details). In a chip it is added to the tooltip and the accessible name. */
16
16
  summary?: string;
17
+ /** Why the call did not run, for `status="skipped"`, e.g. "depends on a denied change". Takes the place of `summary`: shown in the row beside the status, added to the chip's tooltip and accessible name, and repeated as "Reason" in the details. */
18
+ reason?: string;
17
19
  /** What the tool was called with: a string or any JSON-able value. Shown as a one-line preview in the chip's tooltip (see `previewInput`) and in full, pretty-printed, in the details. */
18
20
  input?: unknown;
19
21
  /** What the tool returned: a string or any JSON-able value. Pretty-printed in the details. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruckc/truss-chat",
3
- "version": "1.41.0",
3
+ "version": "1.42.0",
4
4
  "description": "Chat building blocks for Truss UI: thread, messages, tool calls, composer, status line and a question form",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "@ruckc/truss-ui": "^1.0.0"
28
28
  },
29
29
  "dependencies": {
30
- "@ruckc/truss-markdown": "^1.41.0"
30
+ "@ruckc/truss-markdown": "^1.42.0"
31
31
  },
32
32
  "author": "Curtis Ruck",
33
33
  "homepage": "https://truss.ruck.io",