Skip to content

styles: ship optional core + default reference stylesheets - #26

Merged
jonathanKingston merged 3 commits into
mainfrom
claude/streaming-markdown-css-examples-2fwp20
Jul 5, 2026
Merged

jonathanKingston merged 3 commits into
mainfrom
claude/streaming-markdown-css-examples-2fwp20

Conversation

@jonathanKingston

Copy link
Copy Markdown
Collaborator

Why

The renderer emits a documented set of class hooks (stream-pending-*, contains-task-list, mermaid-diagram, hljs-*, …) but shipped no CSS, so every consumer had to reconstruct styling from the class contract in ARCHITECTURE.md. This adds optional reference stylesheets while keeping the package host-independent (no auto-injection, opt-in import).

What

Two layered stylesheets under a new styles/ dir, both scoped under a .streaming-markdown class the host adds to its render sink:

  • styles/core.css — structural only: the rules the emitter's output needs to render correctly regardless of theme (pending-state whitespace, task-list marker suppression, code-block whitespace, layout-blowout guards). No colours, spacing, or typography.
  • styles/default.css — imports core.css and layers a batteries-included look (spacing, typography, tables, links, blockquotes, VS Code Dark+ highlight.js palette). Every value is var(--sm-*, <fallback>), so it stands alone and rethemes cleanly.

Authored with native CSS nesting (works in any current engine; a bundler can lower it for old targets). Also covers the .stream-complete / .stream-pending-block pending-tail spacing, since streaming.ts emits those classes.

Package wiring: exports subpaths for both files, "styles" in files, and sideEffects: ["**/*.css"] so bundlers don't drop the imports.

Usage

import '@copse/streaming-markdown/styles/default.css'
el.classList.add('streaming-markdown')

Retheme by setting --sm-* custom properties (--sm-border, --sm-accent, --sm-code-bg, …) — see the header comment in styles/default.css.

Notes

  • No runtime/source changes — CSS + docs (README Styling section, cross-referenced from the class-contract table in ARCHITECTURE.md) only.
  • Validated by bundling default.css through esbuild (@import resolves, nesting parses, no warnings).
  • Companion consumer change: agent-pane adopts these sheets and deletes its duplicated markdown CSS (separate PR).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FzxuME5EjN8PnsdcF5in6s


Generated by Claude Code

claude added 3 commits July 5, 2026 18:37
The renderer emits a documented set of class hooks (stream-pending-*,
contains-task-list, mermaid-diagram, hljs-*, …) but shipped no CSS, so every
consumer had to reconstruct styling from the class contract in ARCHITECTURE.md.

Add two optional stylesheets, both scoped under a `.streaming-markdown` class
the host puts on its render sink:

- styles/core.css: structural rules the output needs to render correctly
  regardless of theme — pending-state whitespace, task-list marker suppression,
  code-block whitespace, and layout-blowout guards. No colour/spacing/type.
- styles/default.css: imports core.css and layers a batteries-included look
  (spacing, typography, tables, links, VS Code Dark+ highlight.js palette),
  retheming via --sm-* custom properties that each carry a fallback.

Authored with native CSS nesting. Wire up package exports/files and mark
*.css as sideEffects so bundlers keep the imports. Document in README and
cross-reference from the class contract in ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzxuME5EjN8PnsdcF5in6s
The DOM streaming renderer wraps committed content in `.stream-complete` and
emits a `.stream-pending-block` tail (streaming.ts). Add the adjacency spacing
for that tail to default.css so consumers don't have to reproduce it; the
existing first-child rule already covers pending-heading top-margin reset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzxuME5EjN8PnsdcF5in6s
`:is(td, th) > code:only-child { overflow-wrap: anywhere; display: block }`
forced char-level wrapping on every table cell's lone code span. That is
host-specific table nuance (e.g. a consumer that pins a first "id" column and
wants it on one line) rather than a generic default, and it overrode such a
host rule. Table blowout is already handled generically by the base cell
`overflow-wrap: break-word` and the table's `overflow-x: auto`; leave the
lone-code-span policy to the host.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzxuME5EjN8PnsdcF5in6s
@jonathanKingston
jonathanKingston force-pushed the claude/streaming-markdown-css-examples-2fwp20 branch from e32257f to 20c72cd Compare July 5, 2026 18:38
@jonathanKingston
jonathanKingston merged commit 870999a into main Jul 5, 2026
1 check passed
jonathanKingston added a commit to copse-dev/agent-pane that referenced this pull request Jul 5, 2026
## Why

`@copse/streaming-markdown` now ships its markdown styling as `core.css`
+ `default.css` (scoped under `.streaming-markdown`). Adopt it here and
delete the duplicated rules so the package is the single source of truth
for markdown-output styling.

Depends on copse-dev/streaming-markdown#26.

## What

**−284 / +33 lines.**

- Bump the `@copse/streaming-markdown` pin to the commit that ships
`styles/`.
- Import `styles/default.css` in `main.ts` (before `global.css` so app
rules win ties) and add the `.streaming-markdown` scope class to every
render sink: conversation messages, subagent cards, pr-pane,
review-panel, context-panel.
- Bridge the package's `--sm-*` knobs onto agent-pane's theme tokens in
`conversation.css`, so rendered markdown still tracks the active theme.
- **Delete** the migrated rules: base typography, lists, task lists, all
`stream-pending`/`stream-complete` rules, inline code, links,
`pre`/`code`, tables, blockquote, hr, and the whole `hljs` theme
(`syntax-highlight.css` removed).
- **Keep** host-only chrome the package never emits: code/table copy
buttons, mermaid expand/zoom dialog + folded affordance + fallback,
artifact images, and the app-specific wide-table first-column pinning
(it out-specifies the library's generic rule, so table behavior is
unchanged).

## Verification

- ✅ Edited `global.css` bundles through esbuild (agent-pane's bundler)
with no errors.
- ✅ Package-CSS import type-checks via the ambient `declare module
'*.css'` (`src/renderer/css.d.ts`).
- ✅ No dangling references to the removed file; no tests assert the
deleted CSS.
- ⚠️ Not yet run against a full install: `npm run typecheck` / app build
/ WebdriverIO e2e need an environment where the new dependency pin is
installed. Before merge, run those and eyeball a streamed message, a
mermaid diagram, and a wide PR table for visual drift — the two judgment
calls are the `--sm-*` bridge reproducing spacing/colours exactly, and
the wide-table first-column pinning still holding.

## Merge ordering

Merge streaming-markdown#26 first. The dep is pinned to a **commit SHA**
on that branch; if #26 is **squash-merged** (SHA changes), update this
pin to the resulting `main` commit before merging here.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01FzxuME5EjN8PnsdcF5in6s

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FzxuME5EjN8PnsdcF5in6s)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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