@timbal-ai/timbal-react 0.3.0 → 0.5.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
@@ -18,27 +18,36 @@ npm install react react-dom @assistant-ui/react @timbal-ai/timbal-sdk
18
18
 
19
19
  ### Tailwind setup
20
20
 
21
- The package ships pre-built Tailwind class names. Add this `@source` line to your CSS entry file **without it the components will be unstyled**:
21
+ The package ships pre-built Tailwind class names **plus a complete light + dark token set** (`bg-background`, `text-foreground`, `bg-card`, `bg-bubble-user`, `from-elevated-from`, `bg-playground-from/via/to`, etc.). Your app CSS only needs three lines:
22
22
 
23
23
  ```css
24
24
  /* src/index.css */
25
25
  @import "tailwindcss";
26
-
26
+ @import "@timbal-ai/timbal-react/styles.css";
27
27
  @source "../node_modules/@timbal-ai/timbal-react/dist";
28
28
  ```
29
29
 
30
- > Adjust the path if your CSS file lives at a different depth relative to `node_modules`.
30
+ That's it no `@theme`, `:root`, or `.dark` blocks of your own. Toggling dark mode is a single `document.documentElement.classList.toggle("dark")` (or `next-themes` `attribute="class"`).
31
31
 
32
- ### Companion stylesheet (optional)
32
+ > Adjust the `@source` path if your CSS file lives at a different depth relative to `node_modules`.
33
33
 
34
- For blueprint-style polish (welcome animations, suggestion chips, tool indicators), import the shipped companion CSS once. Requires Tailwind v4 design tokens (`--primary`, etc.) in your app:
34
+ ### Overriding the palette
35
35
 
36
- ```ts
37
- // src/main.tsx
38
- import "@timbal-ai/timbal-react/styles.css";
36
+ Every token has a CSS-variable indirection in `styles.css`. Override individual variables to rebrand without forking:
37
+
38
+ ```css
39
+ :root {
40
+ --primary: oklch(0.5 0.12 265);
41
+ --playground-from: oklch(0.95 0.04 265 / 0.6);
42
+ }
43
+
44
+ .dark {
45
+ --primary: oklch(0.72 0.14 265);
46
+ --playground-from: oklch(0.27 0.04 265);
47
+ }
39
48
  ```
40
49
 
41
- You can omit this entirely and style components yourselfthe package does not bundle mandatory CSS beyond what Tailwind scans from `dist/`.
50
+ Both light AND dark blocks must be defined for every overridden token otherwise toggling dark mode produces an inconsistent UI. The library prints a one-time dev-only console warning when it detects a mismatch.
42
51
 
43
52
  ### CSS imports
44
53
 
@@ -129,6 +138,57 @@ const [workforceId, setWorkforceId] = useState("agent-a");
129
138
  <TimbalChat workforceId={workforceId} key={workforceId} />
130
139
  ```
131
140
 
141
+ ### Studio shell (sidebar + header + chat)
142
+
143
+ `TimbalStudioShell` is the most opinionated layout — a floating workforce sidebar, a top bar for actions (mode toggle, account), and a full-height `TimbalChat`. Works as a one-line app:
144
+
145
+ ```tsx
146
+ import {
147
+ TimbalStudioShell,
148
+ ModeToggle,
149
+ TimbalMark,
150
+ } from "@timbal-ai/timbal-react";
151
+ import { useTheme } from "next-themes";
152
+
153
+ export default function App() {
154
+ const { resolvedTheme, setTheme } = useTheme();
155
+
156
+ return (
157
+ <TimbalStudioShell
158
+ brand={<TimbalMark size={32} />}
159
+ welcome={{ heading: "How can I help you today?" }}
160
+ headerActions={
161
+ <ModeToggle theme={resolvedTheme} setTheme={setTheme} />
162
+ }
163
+ suggestions={[{ title: "Get started" }]}
164
+ attachments
165
+ />
166
+ );
167
+ }
168
+ ```
169
+
170
+ When `workforceId` is omitted, the shell fetches the workforce list and lets the sidebar drive selection. Pass `workforceId` to pin a single agent and hide the picker UI.
171
+
172
+ Apps that need finer control can compose the public building blocks (`StudioSidebar` + `TimbalChat`) directly:
173
+
174
+ ```tsx
175
+ import { StudioSidebar, TimbalChat } from "@timbal-ai/timbal-react";
176
+
177
+ function MyShell() {
178
+ const [agent, setAgent] = useState("agent-a");
179
+ return (
180
+ <div className="relative h-dvh bg-background">
181
+ <StudioSidebar selectedId={agent} onSelect={setAgent} />
182
+ <main className="h-full pl-[var(--studio-inset-left)]">
183
+ <TimbalChat workforceId={agent} key={agent} />
184
+ </main>
185
+ </div>
186
+ );
187
+ }
188
+ ```
189
+
190
+ The `--studio-inset-left` CSS variable is automatically set on the document by `StudioSidebar`, so a normal Tailwind `pl-[var(--studio-inset-left)]` call resolves to the correct offset.
191
+
132
192
  ### Drop-in shell (header + agent picker)
133
193
 
134
194
  `TimbalChatShell` wraps the common blueprint layout: brand area, workforce selector, optional header actions, and a full-height chat. When `workforceId` is omitted, it fetches `{baseUrl}/workforce` and selects the first agent automatically:
@@ -658,6 +718,11 @@ if (res.ok) {
658
718
 
659
719
  | Export | Description |
660
720
  |---|---|
721
+ | `TimbalStudioShell` | Floating sidebar + top bar + full-height `TimbalChat`. Most opinionated layout |
722
+ | `StudioSidebar` | Floating workforce sidebar — collapses, mobile drawer, runtime portal anchor |
723
+ | `ModeToggle` | Sun/moon theme toggle styled for the studio top bar |
724
+ | `TimbalMark` | Liquid-metal brand mark — drop-in welcome icon |
725
+ | `StudioWelcome` | Welcome screen with `TimbalMark` + staggered intro animation |
661
726
  | `TimbalChatShell` | Header + workforce picker + full-height `TimbalChat` |
662
727
  | `Thread` | Full chat UI — messages, composer, attachments, action bar |
663
728
  | `Composer` | Standalone composer bar (for custom thread layouts) |
@@ -671,10 +736,6 @@ if (res.ok) {
671
736
  | `UiCustomNodeRegistryProvider` | Register `{ kind: "custom" }` node renderers |
672
737
  | `ArtifactView` | Render a single artifact object |
673
738
  | `parseArtifactFromToolResult` | Parse tool output into an artifact |
674
- | `SyntaxHighlighter` | Shiki-based code highlighter (vitesse-dark / vitesse-light themes) |
675
- | `UserMessageAttachments` | Attachment thumbnails in user messages |
676
- | `ComposerAttachments` | Attachment previews inside the composer |
677
- | `ComposerAddAttachment` | "+" button to add attachments |
678
739
  | `TooltipIconButton` | Icon button with a tooltip |
679
740
 
680
741
  ### Hooks
@@ -685,6 +746,7 @@ if (res.ok) {
685
746
  | `useTimbalStream` | Low-level SSE chat state without `<Thread>` |
686
747
  | `useTimbalRuntime` | Access runtime context inside custom providers |
687
748
  | `useResolvedSuggestions` | Resolve static/async `SuggestionsSource` to an array |
749
+ | `useOptionalSession` | Same as `useSession` but returns `null` when no `SessionProvider` is mounted |
688
750
 
689
751
  ### UI primitives
690
752
 
@@ -764,6 +826,42 @@ For a fully custom header, combine `useWorkforces` with `TimbalChat` instead of
764
826
 
765
827
  ---
766
828
 
829
+ ## Migrating from 0.4 to 0.5
830
+
831
+ `0.5.0` slims the public API to the surface that blueprint apps actually use. Every feature still works — only the export list changed.
832
+
833
+ ### Re-brand via CSS variables, not internals
834
+
835
+ All sizing and class composites moved to internal modules. Override the CSS variables in your own `:root` / `.dark` blocks instead of importing helper strings:
836
+
837
+ ```css
838
+ :root {
839
+ --studio-sidebar-width: 15rem;
840
+ --studio-topbar-height: 3.25rem;
841
+ }
842
+ ```
843
+
844
+ For colours, override the existing semantic tokens (`--background`, `--foreground`, `--composer-bg`, `--bubble-user`, `--playground-from/via/to`, …). See [`src/styles.css`](src/styles.css) for the full list.
845
+
846
+ ### Removed from the public API
847
+
848
+ The following symbols are no longer exported. Most have no replacement because they were never meant to be public; for the rest, prefer the high-level shells or CSS-variable overrides:
849
+
850
+ - All `STUDIO_*` layout constants (`STUDIO_SIDEBAR_WIDTH`, `STUDIO_INSET_LEFT`, `STUDIO_SIDEBAR_COLLAPSED_STORAGE_KEY`, `STUDIO_SIDEBAR_PX_*`, …) — override the matching `--studio-*` CSS variables instead.
851
+ - All `studio*Class` / `studioChromeShellStyle` helpers — re-create the look with normal Tailwind classes against semantic tokens (`bg-elevated-from`, `border-border`, `shadow-card`, …).
852
+ - All `TIMBAL_V2_*` button token records and `TimbalV2Button` — use the standard `Button` export from this package; it covers the same variants.
853
+ - `StudioSidebarPanel`, `StudioSidebarHeader/Nav/Footer/Entries/Backdrop/Tooltip/RuntimePortal/EntryMotion`, `StudioSidebarContext`, `useStudioSidebarLayout`, `useStudioSidebarCollapsed`, `useSidebarCollapsePhase`, `workforceItemId/Label/Initial` — use `StudioSidebar` or `TimbalStudioShell` directly.
854
+ - `runThemeSanityCheck` — `<Thread>` already schedules the dev-only check.
855
+ - `SyntaxHighlighter`, `UserMessageAttachments`, `ComposerAttachments`, `ComposerAddAttachment`, `MessagePartPrimitive`, `ActionBarMorePrimitive`, `ErrorPrimitive`, `useAuiState`, `buttonVariants` — internal composer/markdown details. Override the `Composer` / `AssistantMessage` slot via the `components` prop if you need a custom layout.
856
+
857
+ Everything else (the three shells, primitives, hooks, auth, artifact API, design-token CSS variables) is unchanged.
858
+
859
+ ---
860
+
861
+ ## Mock UI demo
862
+
863
+ An offline Vite app lives in [`examples/mock-ui`](examples/mock-ui). It uses a scripted mock `fetch` (no API keys) and includes a component gallery for artifacts. See that folder’s README for run instructions.
864
+
767
865
  ## Local development
768
866
 
769
867
  Install via a local path reference: