Skip to content

Add composable chat primitives - #10

Merged
scottopolis merged 4 commits into
mainfrom
refactor/compound-chat-components
Sep 25, 2026
Merged

scottopolis merged 4 commits into
mainfrom
refactor/compound-chat-components

Conversation

@scottopolis

Copy link
Copy Markdown
Owner

Summary

  • add controlled Chat.* compound components for root state, transcript scrolling/accessibility, standard messages/tools, safe composition, native textarea props, and send/stop behavior
  • keep ChatSurface and ChatWidget as compatibility presets assembled from those same primitives
  • add per-visible-assistant response composition with optional action rows and host-supplied suggestion chips; no LLM generation/provider contract
  • keep custom tool rendering authoritative, including suppression of tool-only rows and their response footers
  • document composition as the primary customization API

Public API

<Chat.Root messages={chat.messages} status={chat.status} actions={chat}>
  <Header />
  <Chat.Transcript>
    <Chat.Empty>How can we help?</Chat.Empty>
    <Chat.Messages renderTool={renderTool}>
      {(message) => suggestions[message.id]?.length ? (
        <Chat.ResponseFooter>
          <ResponseActions message={message} />
          <Chat.Suggestions>
            {suggestions[message.id].map(({ label, prompt }) => (
              <Chat.Suggestion key={prompt} prompt={prompt}>{label}</Chat.Suggestion>
            ))}
          </Chat.Suggestions>
        </Chat.ResponseFooter>
      ) : null}
    </Chat.Messages>
  </Chat.Transcript>
  <footer className="composer-wrap">
    <Chat.Composer>
      <Chat.Input ref={composerRef} />
      <ExtraControl />
      <Chat.Send />
    </Chat.Composer>
  </footer>
</Chat.Root>

Verification

  • npm test — 52 tests pass
  • npm run build — typecheck, library declarations/CSS/ESM, app, embed, and server builds pass
  • npm pack --dry-run --json — prepare builds the Git-consumption package with ESM, CSS, and declarations
  • rendered and inspected preset, composed desktop, and 390px narrow states at DPR 2
  • narrow DOM check: 24px transparent/borderless action controls with 14px icons; suggestion chips wrap onto two rows without overflow

ampagent and others added 4 commits September 25, 2026 13:28
Amp-Thread-ID: https://ampcode.com/threads/T-01a0d8b0-68d8-741d-913a-59d4e124ae83
Co-authored-by: Scott Bolinger <designbyscott@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0d8b0-68d8-741d-913a-59d4e124ae83
Co-authored-by: Scott Bolinger <designbyscott@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0d8b0-68d8-741d-913a-59d4e124ae83
Co-authored-by: Scott Bolinger <designbyscott@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a0d8b0-68d8-741d-913a-59d4e124ae83
Co-authored-by: Scott Bolinger <designbyscott@gmail.com>
@scottopolis
scottopolis merged commit 5a26d8d into main Sep 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants