@ruckc/truss-chat 1.43.0 → 1.45.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ruckc/truss-chat
2
2
 
3
- Chat building blocks for [Truss UI](https://truss.ruck.io): thread, messages, reasoning, tool calls, composer, status line, a question form, a conversation list (`ChatSessions`) and a conversation title row (`ChatTitle`).
3
+ Chat building blocks for [Truss UI](https://truss.ruck.io): thread, messages, an issue-style comment thread (`CommentThread`, `Comment`, `ThreadEvent`), reasoning, tool calls, composer, status line, a question form, a conversation list (`ChatSessions`) and a conversation title row (`ChatTitle`).
4
4
 
5
5
  Docs: <https://truss.ruck.io/docs/packages>
6
6
 
@@ -44,6 +44,24 @@ A conversation list with select, rename and archive (the component never edits `
44
44
  />
45
45
  ```
46
46
 
47
+ An issue-tracker thread (comments between people and a bot, oldest first, with status lines and a reply box). It is a separate set from `ChatMessage` on purpose: a comment has an author with avatar, a role badge and a time, and the thread is a list of articles, not a live log of user/assistant turns.
48
+
49
+ ```svelte
50
+ <script lang="ts">
51
+ import { CommentThread, Comment, ThreadEvent, ChatComposer } from '@ruckc/truss-chat';
52
+ let value = $state('');
53
+ </script>
54
+
55
+ <CommentThread label="Issue 42">
56
+ <Comment author="Dana" role="Customer" time="2026-11-20T09:00:00Z" text="The export **times out**." />
57
+ <Comment author="Truss Bot" role="Bot" roleIntent="accent" avatar="/bot.png" time={Date.now() - 300_000} text="Looking into it." />
58
+ <ThreadEvent intent="success" text="Solution shared" time={Date.now()} />
59
+ {#snippet composer()}<ChatComposer bind:value onsend={(text) => post(text)} placeholder="Reply" />{/snippet}
60
+ </CommentThread>
61
+ ```
62
+
63
+ Markdown is rendered from the parsed tree (no `{@html}`), times use `RelativeTime` (the server renders the absolute UTC time, the browser the relative text once mounted, the title is always the absolute time), and `tone="self"` tints the reader's own comments.
64
+
47
65
  ## License
48
66
 
49
67
  MIT
@@ -0,0 +1,81 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { Avatar, Badge, RelativeTime, type Intent, type TimeValue } from '@ruckc/truss-ui';
5
+ import { Markdown } from '@ruckc/truss-markdown';
6
+
7
+ let {
8
+ author,
9
+ avatar,
10
+ role,
11
+ roleIntent = 'neutral',
12
+ tone = 'other',
13
+ time,
14
+ timeFormat = 'long',
15
+ text,
16
+ plain = false,
17
+ code,
18
+ link,
19
+ class: klass = '',
20
+ children,
21
+ ...rest
22
+ }: Omit<HTMLAttributes<HTMLLIElement>, 'children' | 'class'> & {
23
+ /** The author's name: the avatar's name (initials without `avatar`), the heading of the entry and, with the time, its accessible name. */
24
+ author: string;
25
+ /** The avatar image URL. Without it, or when it fails to load, the author's initials are shown. */
26
+ avatar?: string;
27
+ /** A badge next to the name: "Customer", "Team", "Bot"... */
28
+ role?: string;
29
+ /** Colour of the role badge. */
30
+ roleIntent?: Intent;
31
+ /** `self` tints the body as the reader's own comment; `other` (default) is neutral. */
32
+ tone?: 'self' | 'other';
33
+ /** When it was written (a `Date`, epoch ms or ISO string). Rendered with `RelativeTime`: the server and the first client render show the absolute UTC time, the relative text replaces it once mounted, and the title is always the absolute time. */
34
+ time?: TimeValue;
35
+ /** `long` is "3 days ago", `narrow` is "3d". */
36
+ timeFormat?: 'long' | 'narrow';
37
+ /** The body as Markdown (rendered from the parsed tree, nothing is injected as HTML). Used when `children` is not given. */
38
+ text?: string;
39
+ /** Show `text` as plain text, with line breaks kept, instead of Markdown. */
40
+ plain?: boolean;
41
+ /** Renders a fenced code block of the Markdown in place of the default `<pre><code>`, e.g. with `truss-code`. */
42
+ code?: Snippet<[{ lang: string; text: string }]>;
43
+ /** Renders a Markdown link in place of the default `<a>`, e.g. for client-side routing. */
44
+ link?: Snippet<[{ href: string; children: Snippet }]>;
45
+ /** Other attributes (`data-testid`, `id`, ...) go to the root `<li>`. `class` is added to it. */
46
+ class?: string;
47
+ /** The body in place of `text`. */
48
+ children?: Snippet;
49
+ } = $props();
50
+
51
+ const id = $props.id();
52
+ </script>
53
+
54
+ <li {...rest} class={['cm', klass]} data-tone={tone}>
55
+ <article aria-labelledby="{id}-a{time === undefined ? '' : ` ${id}-t`}" class="art">
56
+ <Avatar name={author} src={avatar} />
57
+ <div class="main">
58
+ <header class="head">
59
+ <strong id="{id}-a" class="author">{author}</strong>
60
+ {#if role}<Badge intent={roleIntent}>{role}</Badge>{/if}
61
+ {#if time !== undefined}<RelativeTime value={time} format={timeFormat} live id="{id}-t" class="time" />{/if}
62
+ </header>
63
+ <div class="body">
64
+ {#if children}{@render children()}{:else if text}{#if plain}<div class="plain">{text}</div>{:else}<Markdown {text} {code} {link} />{/if}{/if}
65
+ </div>
66
+ </div>
67
+ </article>
68
+ </li>
69
+
70
+ <style>
71
+ .cm { display: block; min-width: 0; max-width: 100%; }
72
+ .art { display: flex; gap: var(--tr-space-3); min-width: 0; }
73
+ .main { flex: 1; min-width: 0; }
74
+ .head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tr-space-1) var(--tr-space-2); min-width: 0; margin-bottom: var(--tr-space-1); }
75
+ .author { min-width: 0; overflow-wrap: anywhere; color: var(--tr-on-surface); }
76
+ .head :global(.time) { color: var(--tr-on-surface-variant); font-size: var(--tr-text-sm); }
77
+ .body { min-width: 0; max-width: 100%; overflow-wrap: anywhere; line-height: 1.5; color: var(--tr-on-surface); padding: var(--tr-space-2) var(--tr-space-3); border: 1px solid var(--tr-outline-variant); border-radius: var(--tr-radius-md); background: var(--tr-surface); }
78
+ [data-tone='self'] .body { background: var(--tr-primary-container); color: var(--tr-on-primary-container); border-color: transparent; }
79
+ [data-tone='self'] .body :global(a) { color: inherit; }
80
+ .plain { white-space: pre-wrap; }
81
+ </style>
@@ -0,0 +1,40 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Intent, type TimeValue } from '@ruckc/truss-ui';
4
+ type $$ComponentProps = Omit<HTMLAttributes<HTMLLIElement>, 'children' | 'class'> & {
5
+ /** The author's name: the avatar's name (initials without `avatar`), the heading of the entry and, with the time, its accessible name. */
6
+ author: string;
7
+ /** The avatar image URL. Without it, or when it fails to load, the author's initials are shown. */
8
+ avatar?: string;
9
+ /** A badge next to the name: "Customer", "Team", "Bot"... */
10
+ role?: string;
11
+ /** Colour of the role badge. */
12
+ roleIntent?: Intent;
13
+ /** `self` tints the body as the reader's own comment; `other` (default) is neutral. */
14
+ tone?: 'self' | 'other';
15
+ /** When it was written (a `Date`, epoch ms or ISO string). Rendered with `RelativeTime`: the server and the first client render show the absolute UTC time, the relative text replaces it once mounted, and the title is always the absolute time. */
16
+ time?: TimeValue;
17
+ /** `long` is "3 days ago", `narrow` is "3d". */
18
+ timeFormat?: 'long' | 'narrow';
19
+ /** The body as Markdown (rendered from the parsed tree, nothing is injected as HTML). Used when `children` is not given. */
20
+ text?: string;
21
+ /** Show `text` as plain text, with line breaks kept, instead of Markdown. */
22
+ plain?: boolean;
23
+ /** Renders a fenced code block of the Markdown in place of the default `<pre><code>`, e.g. with `truss-code`. */
24
+ code?: Snippet<[{
25
+ lang: string;
26
+ text: string;
27
+ }]>;
28
+ /** Renders a Markdown link in place of the default `<a>`, e.g. for client-side routing. */
29
+ link?: Snippet<[{
30
+ href: string;
31
+ children: Snippet;
32
+ }]>;
33
+ /** Other attributes (`data-testid`, `id`, ...) go to the root `<li>`. `class` is added to it. */
34
+ class?: string;
35
+ /** The body in place of `text`. */
36
+ children?: Snippet;
37
+ };
38
+ declare const Comment: import("svelte").Component<$$ComponentProps, {}, "">;
39
+ type Comment = ReturnType<typeof Comment>;
40
+ export default Comment;
@@ -0,0 +1,32 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+
5
+ let {
6
+ label = 'Conversation',
7
+ composer,
8
+ class: klass = '',
9
+ children,
10
+ ...rest
11
+ }: Omit<HTMLAttributes<HTMLElement>, 'children' | 'class'> & {
12
+ /** Accessible name of the thread (a labelled region). */
13
+ label?: string;
14
+ /** The reply box shown under the entries, typically a `ChatComposer`. Kept outside the list. */
15
+ composer?: Snippet;
16
+ /** Other attributes (`data-testid`, `id`, ...) go to the root `<section>`. `class` is added to it. */
17
+ class?: string;
18
+ /** The entries, oldest first (newest at the bottom): `Comment` and `ThreadEvent`. */
19
+ children: Snippet;
20
+ } = $props();
21
+ </script>
22
+
23
+ <section {...rest} class={['ct', klass]} aria-label={label}>
24
+ <ol class="list">{@render children()}</ol>
25
+ {#if composer}<div class="reply">{@render composer()}</div>{/if}
26
+ </section>
27
+
28
+ <style>
29
+ .ct { display: flex; flex-direction: column; gap: var(--tr-space-4); min-width: 0; max-width: 100%; }
30
+ .list { display: flex; flex-direction: column; gap: var(--tr-space-4); margin: 0; padding: 0; list-style: none; min-width: 0; }
31
+ .reply { min-width: 0; }
32
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ type $$ComponentProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'class'> & {
4
+ /** Accessible name of the thread (a labelled region). */
5
+ label?: string;
6
+ /** The reply box shown under the entries, typically a `ChatComposer`. Kept outside the list. */
7
+ composer?: Snippet;
8
+ /** Other attributes (`data-testid`, `id`, ...) go to the root `<section>`. `class` is added to it. */
9
+ class?: string;
10
+ /** The entries, oldest first (newest at the bottom): `Comment` and `ThreadEvent`. */
11
+ children: Snippet;
12
+ };
13
+ declare const CommentThread: import("svelte").Component<$$ComponentProps, {}, "">;
14
+ type CommentThread = ReturnType<typeof CommentThread>;
15
+ export default CommentThread;
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { Icon, RelativeTime, type IconSource, type Intent, type TimeValue } from '@ruckc/truss-ui';
5
+
6
+ let {
7
+ text,
8
+ intent = 'neutral',
9
+ icon,
10
+ time,
11
+ timeFormat = 'long',
12
+ class: klass = '',
13
+ children,
14
+ ...rest
15
+ }: Omit<HTMLAttributes<HTMLLIElement>, 'children' | 'class'> & {
16
+ /** The status text, e.g. "Solution shared" or "Merged". Used when `children` is not given. */
17
+ text?: string;
18
+ /** Colour of the icon. The meaning is in the text and icon, not the colour alone. */
19
+ intent?: Intent;
20
+ /** The icon. Defaults to one that fits the intent (a tick for `success`, a warning sign for `warning`, an error mark for `danger`, an info mark otherwise). */
21
+ icon?: IconSource;
22
+ /** When it happened (a `Date`, epoch ms or ISO string), shown with `RelativeTime` like a `Comment`'s. */
23
+ time?: TimeValue;
24
+ /** `long` is "3 days ago", `narrow` is "3d". */
25
+ timeFormat?: 'long' | 'narrow';
26
+ /** Other attributes (`data-testid`, `id`, ...) go to the root `<li>`. `class` is added to it. */
27
+ class?: string;
28
+ /** The status content in place of `text`. */
29
+ children?: Snippet;
30
+ } = $props();
31
+
32
+ const glyph = $derived(icon ?? (intent === 'success' ? 'success' : intent === 'warning' ? 'warning' : intent === 'danger' ? 'error' : 'info'));
33
+ </script>
34
+
35
+ <li {...rest} class={['ev', klass]} data-intent={intent}>
36
+ <span class="icon"><Icon name={glyph} /></span>
37
+ <span class="text">{#if children}{@render children()}{:else}{text}{/if}</span>
38
+ {#if time !== undefined}<RelativeTime value={time} format={timeFormat} live class="time" />{/if}
39
+ </li>
40
+
41
+ <style>
42
+ .ev { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tr-space-1) var(--tr-space-2); min-width: 0; max-width: 100%; padding-inline: var(--tr-space-2); color: var(--tr-on-surface-variant); font-size: var(--tr-text-sm); }
43
+ .icon { display: inline-flex; flex: none; color: var(--tr-on-surface-variant); }
44
+ .text { min-width: 0; overflow-wrap: anywhere; }
45
+ .ev :global(.time) { font-size: var(--tr-text-xs); }
46
+ [data-intent='primary'] .icon { color: var(--tr-primary); }
47
+ [data-intent='secondary'] .icon { color: var(--tr-secondary); }
48
+ [data-intent='accent'] .icon { color: var(--tr-accent); }
49
+ [data-intent='success'] .icon { color: var(--tr-success); }
50
+ [data-intent='warning'] .icon { color: var(--tr-warning); }
51
+ [data-intent='danger'] .icon { color: var(--tr-danger); }
52
+ </style>
@@ -0,0 +1,22 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type IconSource, type Intent, type TimeValue } from '@ruckc/truss-ui';
4
+ type $$ComponentProps = Omit<HTMLAttributes<HTMLLIElement>, 'children' | 'class'> & {
5
+ /** The status text, e.g. "Solution shared" or "Merged". Used when `children` is not given. */
6
+ text?: string;
7
+ /** Colour of the icon. The meaning is in the text and icon, not the colour alone. */
8
+ intent?: Intent;
9
+ /** The icon. Defaults to one that fits the intent (a tick for `success`, a warning sign for `warning`, an error mark for `danger`, an info mark otherwise). */
10
+ icon?: IconSource;
11
+ /** When it happened (a `Date`, epoch ms or ISO string), shown with `RelativeTime` like a `Comment`'s. */
12
+ time?: TimeValue;
13
+ /** `long` is "3 days ago", `narrow` is "3d". */
14
+ timeFormat?: 'long' | 'narrow';
15
+ /** Other attributes (`data-testid`, `id`, ...) go to the root `<li>`. `class` is added to it. */
16
+ class?: string;
17
+ /** The status content in place of `text`. */
18
+ children?: Snippet;
19
+ };
20
+ declare const ThreadEvent: import("svelte").Component<$$ComponentProps, {}, "">;
21
+ type ThreadEvent = ReturnType<typeof ThreadEvent>;
22
+ export default ThreadEvent;
package/dist/index.d.ts CHANGED
@@ -11,3 +11,6 @@ export { default as QuestionForm } from './QuestionForm.svelte';
11
11
  export { default as QuestionAnswers } from './QuestionAnswers.svelte';
12
12
  export type { Question, QuestionAnswer } from './QuestionForm.svelte';
13
13
  export { formatToolName, previewInput, formatValue } from './chat.js';
14
+ export { default as CommentThread } from './CommentThread.svelte';
15
+ export { default as Comment } from './Comment.svelte';
16
+ export { default as ThreadEvent } from './ThreadEvent.svelte';
package/dist/index.js CHANGED
@@ -9,3 +9,6 @@ export { default as ChatTitle } from './ChatTitle.svelte';
9
9
  export { default as QuestionForm } from './QuestionForm.svelte';
10
10
  export { default as QuestionAnswers } from './QuestionAnswers.svelte';
11
11
  export { formatToolName, previewInput, formatValue } from './chat.js';
12
+ export { default as CommentThread } from './CommentThread.svelte';
13
+ export { default as Comment } from './Comment.svelte';
14
+ export { default as ThreadEvent } from './ThreadEvent.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruckc/truss-chat",
3
- "version": "1.43.0",
3
+ "version": "1.45.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.43.0"
30
+ "@ruckc/truss-markdown": "^1.45.0"
31
31
  },
32
32
  "author": "Curtis Ruck",
33
33
  "homepage": "https://truss.ruck.io",