Docs: the events page and the CSS variables table don't match the widget

Aperta Adatta ai principianti
#611 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
markdown, typescript
Ambito
documentation

Direzione di ricerca

Inizia leggendo website/src/content/docs/widget/events.mdx (righe 59-87) insieme a packages/widget/src/widget.ts agli intervalli citati (804-809, 916-940, 988-994, 1001-1023) e packages/widget/src/api/client.ts (205, 239-273, 280-291) per confermare quando si attivano message e error e l'elenco completo dei valori di error.message; controlla MessageData in packages/widget/src/dom/messages.ts (righe 10-19) per sources. Poi sostituisci la tabella CSS in website/src/content/docs/widget/configuration.mdx (righe 388-408) con un link alla tabella dei token in theming.mdx (righe 49-71). Fatto significa che entrambe le pagine corrispondono al codice, pnpm docs:check passa e hai verificato gli eventi con packages/widget/dev.html dopo aver compilato i pacchetti ed eseguito pnpm dev in website/.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

documentation good first issue widget

Two widget docs pages describe behavior the code doesn't have.

The events page (website/src/content/docs/widget/events.mdx)

The message section (lines 59 to 75) says the payload is { id, role, content, status?, errorType? }, with status one of 'streaming' | 'complete' | 'error' and four error types. In the code, message fires for a visitor's message when it's sent (deliver() in packages/widget/src/widget.ts, lines 804 to 809) and for a reply once it has finished (lines 988 to 994). It never fires while a reply streams, and it never fires for a failed reply, which fires error only (lines 916 to 940 and 1001 to 1023). So status is undefined on the visitor's message and 'complete' on a reply, and errorType never appears. A reply also carries sources, the pages the answer came from (see MessageData in packages/widget/src/dom/messages.ts, lines 10 to 19). The page leaves that out, though it's handy for analytics.

The error section (lines 77 to 87) only says the payload is an Error. Its message is the kind of failure, built at widget.ts line 937 from what packages/widget/src/api/client.ts yields: errorChunk() maps the server's codes to rate_limit, timeout, budget, budget_daily, unavailable or provider_error (lines 280 to 291), and the stream itself gives cut_off, network or timeout (lines 239 to 273). A server error without a code gives HTTP <status> (line 205). Pressing Stop doesn't fire error (widget.ts line 917). A site needs this list to tell a rate limit from an outage in its own analytics.

The CSS custom properties table (website/src/content/docs/widget/configuration.mdx, lines 388 to 408)

Its "Default" column has the dark theme's values, such as --cc-bg: #0a0a0a, --cc-text: #ffffff and --cc-accent: #6366f1. Light is the default (packages/widget/src/styles/launcher.css, lines 2 to 28). --cc-font and --cc-shadow are also wrong, and six tokens are missing: --cc-on-accent, --cc-accent-contrast, --cc-surface-raised, --cc-danger, --cc-code-bg and --cc-pre-bg. The theming page already has a correct table with both modes (website/src/content/docs/widget/theming.mdx, lines 49 to 71).

What to do

  • Rewrite the message and error sections of the events page from the code: when each one fires, what the payload has, and the list of error.message values. A short example that sends error.message to analytics would help.
  • Replace the CSS table on the configuration page with a sentence that links to the theming page's token table, so there's only one list to keep current.

Acceptance criteria

  • Everything the events page says about message and error matches widget.ts and client.ts (link the lines in the PR description)
  • The configuration page links to the theming table instead of repeating it
  • pnpm docs:check passes (it type-checks the TypeScript samples)
  • No changeset (docs only)

How to test

Build the packages (pnpm --filter "./packages/*" build), then run pnpm dev in website/ and read both pages. To watch the events, use packages/widget/dev.html, which already logs message and error to the console. With no backend running, sending a message logs an error whose message is network.


Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #611. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.

Lingua principale
TypeScript
Stelle
13
Fork
7
Merge medio
1g 14h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codercops/chatcops

Tutte le issue di codercops/chatcops

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.