Repository navigation
feat: CopilotDrawer — promote threads management to SDK (shadow-DOM web component + React vertical) - #5701
Conversation
… threads feature Add the thread store (optimistic add/rename/archive/delete with delete rollback-on-reject, session-guarded results, startNewThread/refetchThreads, getServerState/getServerSnapshot, per-store memoized selectors, and non-fatal realtime diagnostics for channel-join and metadata-credential failures) and register the "threads" feature so the SDK can gate thread management.
…tkit-drawer> element Shadow-DOM Lit element that renders the threads drawer: self-contained styles with build-time token sync from react-core's theme, slot projection for custom rows, license/upsell gating, filtering, and a mobile modal. View-state lives on the element; domain state stays with the host. Multi-format build (ESM/CJS externalize lit as a peer dep; UMD inlines lit so the CDN <script> path is self-contained).
Add <CopilotDrawer> (interops with the shadow-DOM element, two-pronged license
gate, scoped chat-input focus return, registration-gated header launcher) and
extend CopilotChatConfigurationProvider with drawerOpen + mobile mutual
exclusion + a non-explicit active-thread setter so a bare drawer connects to the
picked thread and resets on New with no host wiring. useThreads gains an
{enabled} gate and a list-only error channel.
Angular signal wrapper over the core thread store: reactive runtime context (re-dispatches when wsUrl/threadEndpoints arrive), enabled-gated single-slot registration, bound result methods, and synthesized error/loading parity with react-core.
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
MikeRyanDev
left a comment
There was a problem hiding this comment.
Requesting changes for two blockers before this ships.
-
Required CI is red on the PR head. The failures are not isolated downstream noise:
build,compat-check,check-types,package-quality,bundle-size, and all Node unit matrices ultimately report@copilotkit/web-components:buildas the failed task, which then prevents@copilotkit/react-coreand dependents from building/testing. Since this PR publishes@copilotkit/web-componentsand adds it as areact-coredependency, we should not merge until the new package builds cleanly in CI. -
The mobile drawer is shipped as a modal dialog, but focus is not contained when focus is outside
.root. Inpackages/web-components/src/drawer/copilotkit-drawer.ts, the backdrop button is rendered as a sibling before.root(around lines 335-353), while the Tab trap is attached only to.root(line 352) and computes focusables only under.root(lines 277-323). That means if focus lands on the backdrop or starts elsewhere in the shadow root, Tab can escape the modal instead of cycling within it. For a public mobile modal, please trap at the shadow-root/host level or make all focusable modal-owned nodes part of one trap, and add a regression test for backdrop/outside-root focus.
The UMD bundle inlines lit for a self-contained CDN <script>; inlining lit also pulls in its runtime deps (@lit/reactive-element, lit-html, lit-element, @lit-labs/ssr-dom-shim). tsdown flags that transitive bundling as 'unintended' and promotes the warning to a fatal error under CI, breaking @copilotkit/web-components:build (and every dependent). Declare all lit packages in noExternal and set inlineOnly: false to mark the bundling intentional.
The mobile drawer is a modal dialog, but the Tab trap was bound to .root only, while the backdrop button renders as a sibling OUTSIDE .root — so Tab from the backdrop (or any out-of-root node) could escape the modal. Move the trap to the host keydown listener (keydown is composed, so it catches the backdrop too) and include the backdrop in the focusable cycle; keep initial focus on the first real control. Adds a regression test for backdrop/outside-root Tab containment.
|
Thanks for the careful review — both blockers are addressed. 1. CI red ( 2. Mobile modal focus trap. You're right — the Tab trap was bound to
As an extra check I loaded the built UMD bundle via a plain The broader a11y items (focus-restore to the opener on close, reference-counted scroll-lock, confirm-delete |
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/bot
@copilotkit/bot-discord
@copilotkit/bot-slack
@copilotkit/bot-store-postgres
@copilotkit/bot-store-redis
@copilotkit/bot-telegram
@copilotkit/bot-ui
@copilotkit/bot-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
|
Size Change: +21.7 kB (+2.01%) Total Size: 1.1 MB 📦 View Changed
ℹ️ View Unchanged
|
MikeRyanDev
left a comment
There was a problem hiding this comment.
Re-reviewed the latest head (225a3fc). The package build blocker is resolved: build, compat-check, check-types, package-quality, bundle-size, unit matrices, and dojo e2e checks are green. The mobile focus-trap blocker is also addressed by moving Tab handling to the host, including the backdrop in the focus cycle, preserving initial focus on an inner control, and adding a regression test for backdrop boundary trapping. Approving.
…ons, self-owned mobile launcher, and UX fixes Polish on top of the shipped <copilotkit-drawer> (#5701), surfaced by the first real de-fork pilot (langgraph-js): - Theming follows the host app's light/dark theme: each token resolves override -> host theme var (--background/--card/...) -> built-in light default, instead of baking light-only values (drawer was light on a dark app). - Row actions are icon buttons (inline lucide-style SVG, currentColor) with instant tooltips. Native title is replaced by a CSS tooltip (matches the react components' delayDuration:0; title's show-delay is browser-fixed) and is positioned to the side so the list's scroll-overflow never clips it. - Archived rows are muted, no longer struck through. - A refetch (e.g. Active<->All filter toggle) keeps the known list visible; the full loading state shows only on the initial empty fetch. - The reserved footer region hides when nothing is slotted into it (it rendered as an empty box at the bottom); mirrors the memories region. - Mobile gets a self-owned floating launcher so the drawer is always openable with no host header wiring. Its icon is swappable via a launcher-icon slot and its position via --cpk-drawer-launcher-top/left (host can center it on its own header controls); exposes part="launcher". Adds element tests for icons+tooltips, archived styling, refetch-preserves-list, footer hide-when-empty, and the mobile launcher (render + open + desktop-absent).
…ns + thread-management/tooltip fixes (#5707) ## CopilotDrawer — SDK polish + thread-management fixes Polish and fixes on top of the shipped `<copilotkit-drawer>` ([#5701](#5701)), surfaced by real de-fork pilots run against a locally-built SDK + the hosted Intelligence runtime: **langgraph-js** (rich canvas / inline `CopilotChat` / dark theme) and **mastra** (the proverbs CoAgents demo / `CopilotSidebar` / light theme / controlled→uncontrolled provider). Spans **`@copilotkit/web-components`** and **`@copilotkit/react-core`** — no example/de-fork changes here (those wait on a release that publishes web-components + a `react-core` bump that includes `CopilotDrawer`). Captured as Phase-5 acceptance requirements in the [design doc](https://app.notion.com/p/3883aa3818528190b5d1f9b6ba26dca0). ### `react-core` — thread management - **Thread switching works under `<CopilotKit>`.** `CopilotChatConfigurationProvider` treated any `threadId` prop as controlled, so the auto-minted, non-explicit threadId that `<CopilotKit>`'s v1 bridge seeds blocked the drawer's imperative `setActiveThreadId` / `startNewThread` — thread switching and "+ New" were dead in every app wrapped in `<CopilotKit>`. A non-explicit (`hasExplicitThreadId={false}`) threadId is now overridable; a genuine caller-supplied threadId stays controlled. - **"+ New" resets the chat.** `CopilotChat` clears messages when switching to a fresh non-explicit thread so the welcome screen shows instead of the prior thread's messages — including when a still-loading `/connect` is superseded by the switch (the aborted connect's stale snapshot is dropped instead of repopulating the view). - **No upsell flash/stick.** `CopilotDrawer` treats a pending (`null`) license status as loading, not unlicensed, so the upgrade upsell no longer flashes (or sticks) before the runtime reports the license. - **In-header drawer launcher is mobile-only.** `CopilotModalHeader.DrawerLauncher` toggles `drawerOpen`, which only drives the off-canvas *mobile* drawer; on desktop the drawer is a persistent in-flow panel that ignores `open`, so the launcher was a dead no-op there. It now renders only at ≤767px. On desktop the chat's own open/close (the toggle FAB + the header close, both lucide `X`) is the consistent pair. ### `web-components` — theming, launcher, icons, tooltips - **Host-theme inheritance (incl. dark mode).** Each token now resolves `--cpk-drawer-* override → host theme var (`--background`/`--card`/`--foreground`/`--border`/…) → built-in light default`. The drawer follows the host app's light/dark theme by inheritance, instead of baking light-only values (it showed a light drawer on a dark app). Custom properties aren't reset by the `:host { all: initial }` guard, so the standalone fallback still holds. - **Row actions are icon buttons with instant, on-brand tooltips.** Archive / Unarchive / Delete render inline lucide-style SVGs (`currentColor`). Native `title` is replaced by an instant CSS tooltip (matches the React components' Radix `delayDuration: 0`; `title`'s show-delay is browser-fixed at ~1.5s), styled to match the standard CopilotKit tooltip — a primary-colored bubble with an arrow, not a surface/bordered box — and positioned to the side so the list's scroll-overflow never clips it. The tooltip is suppressed while the delete-confirm dialog is open (the clicked trash button keeps `:focus-visible` otherwise, leaving its "Delete" tooltip floating over the dialog). - **Clipped thread names get a tooltip.** A truncated name exposes its full text via the same instant primary-bubble tooltip as the row actions (not the native `title`), shown only when actually clipped. The name text moved to an inner span (so the outer can host the un-clipped bubble) and the hovered row is z-lifted (each row is its own stacking context from the entry-animation transform, which otherwise painted the bubble under later rows). - **Archived rows are muted**, no longer struck through. - **Refetch preserves the list.** A refetch (e.g. Active↔All toggle) keeps the known threads visible; the full loading state only renders on the initial empty fetch. - **Empty `footer` region hides** (it rendered as a stray bordered box at the bottom). Driven by a `slotchange` listener, mirroring the `memories` region. - **Self-owned mobile launcher.** When the drawer is a closed off-canvas mobile modal it renders its own floating "open threads" launcher, so it's always openable without the host wiring a header button. The icon is swappable via a `launcher-icon` **slot**, position is themeable via `--cpk-drawer-launcher-top` / `--cpk-drawer-launcher-left` (so a host can center it on its own header controls), and it exposes `part="launcher"`. The richer in-header `CopilotModalHeader.DrawerLauncher` remains an optional integration. ### Tests - **react-core**: thread-control + non-explicit-override cases on `CopilotChatConfigurationProvider`, the "+ New" message reset on `CopilotChat`, license-pending gating on `CopilotDrawer`, and the mobile-only / desktop-hidden launcher on `CopilotModalHeader`. New regression tests verified red-green; chat + provider suites green, `tsc --noEmit` clean, build green. (The superseded-connect *race* guard is covered by live verification + its synchronous sibling test — an async-timing unit test would be flaky, which the repo treats as a bug.) - **web-components**: element tests for the icon tooltips + confirm-dialog suppression, the clipped-name tooltip (`data-tooltip` + placeholder), archived styling, refetch-preserves-list, footer hide-when-empty, and mobile launcher render/open + desktop-absent. Drawer suite green, `tsc --noEmit` clean, build + `es-check` green under `CI=true`. (Truncation detection + tooltip stacking are layout/CSS — verified live, not in jsdom.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CopilotDrawer — promote threads management to the SDK
Implements the hardened CopilotDrawer design (Threads v2). Promotes thread listing/selection/creation/rename/archive/delete out of the example apps and into the SDK as a framework-agnostic shadow-DOM web component plus a React vertical (Angular wrapper included; Vue/RN to follow).
What's in this PR (by area)
@copilotkit/core: thread store with optimistic add/rename/archive/delete (delete rolls back on reject), session-guarded results (a superseded session can't leak an error/rollback),startNewThread(non-explicit),refetchThreads,getServerState/getServerSnapshot, per-store memoized selectors, and non-fatal realtime diagnostics (a channel-join or metadata-credential failure warns and keeps the already-loaded list rather than blanking it). Registers a"threads"feature for catalog gating.@copilotkit/web-components(new package): the shadow-DOM<copilotkit-drawer>Lit element — self-contained styles with build-time token sync from react-core's@theme(checked-ingenerated-tokens.ts, drift-guarded), slot projection for custom rows (slot="row:{id}"), license/upsell gating, active/all filtering, and a mobile modal. The element owns view-state; the host owns domain state. Multi-format build: ESM/CJS externalizelit(peer dep); the UMD bundle inlineslitso the advertised<script>/CDN path is self-contained.@copilotkit/react-core:<CopilotDrawer>wrapper (custom-element interop, two-pronged license gate, scoped chat-input focus-return, registration-gated header launcher);CopilotChatConfigurationProvidergainsdrawerOpen+<768pxmodal/drawer mutual-exclusion + a non-explicit active-thread setter so a bare<CopilotDrawer>connects to the picked thread and shows the welcome screen on "+ New" with no host wiring;useThreadsgains an{enabled}gate and a list-only error channel.@copilotkit/angular:injectThreadssignal wrapper — reactive runtime context (re-dispatches whenwsUrl/threadEndpointsarrive), enabled-gated single-slot registration, bound result methods, and error/loading parity with react-core.Quality
tsc --noEmitclean across all four; full builds pass; oxfmt clean.Follow-ups (intentionally deferred)
alertdialogfocus management, the default-open-on-mobile scroll-lock, and a dedicated a11y test harness.hasMore/fetch-more UI but nothing triggers it and the wrapper doesn't pass alimit; also clear a recovered next-page error and cancel an in-flight next-page on filter change.onErrorto a transient toast and separate the mutation-error channel from the list-load error (the list no longer blanks on a failed mutation — the rollback restores the row — but mutation failures are currently silent beyond the rejected promise).startNewThreadconfig-error dismissal, add a list-onlylistError, and refresh intelligence/threadEndpoints inupdateRuntimeon a runtime-URL change.store.selectors; honor-or-dropThreadEnvironment.fetch(RxJSfromFetchignores it; both wrappers passglobalThis.fetch, so no behavior change today);threadId=""controlled-predicate edge; reveal animation for slotted rows; empty-string-timestamp coalescing;_visibleThreadsrecompute; empty-namearia-label.🤖 Generated with Claude Code