Repository navigation
Add Markdown component with GFM support and XSS protection - #19
Conversation
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Markdown component to Object UI, enabling schema-driven rendering of markdown content with GitHub Flavored Markdown support and XSS protection.
Changes:
- Added markdown UI component with Tailwind prose styling and security hardening
- Created markdown renderer component and registered it with ComponentRegistry
- Added comprehensive test coverage and a working demo in the prototype application
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/ui/markdown.tsx | New UI component wrapping react-markdown with Tailwind styling and security |
| packages/components/src/ui/index.ts | Export statement for the new markdown component |
| packages/components/src/renderers/data-display/markdown.tsx | Renderer component registering markdown with ComponentRegistry |
| packages/components/src/renderers/data-display/index.ts | Import statement to include markdown renderer |
| packages/components/src/new-components.test.ts | Test case verifying markdown component registration |
| packages/components/package.json | Added react-markdown, remark-gfm, and rehype-sanitize dependencies |
| examples/prototype/src/App.tsx | Demo implementation showcasing markdown component features |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| export interface MarkdownProps { | ||
| content: string | ||
| className?: string | ||
| } |
There was a problem hiding this comment.
The MarkdownProps interface lacks JSDoc comments. According to Rule #3 ('Schema First' Mindset), every property in the Schema MUST have JSDoc to enable auto-generated documentation for the open-source community. Add JSDoc describing the purpose of 'content' and 'className' properties.
There was a problem hiding this comment.
Added comprehensive JSDoc documentation to the MarkdownProps interface describing the purpose and supported features of each property. Documentation follows the "Schema First" principle to enable auto-generated API docs. (commit c31876c)
| import { Markdown } from '@/ui'; | ||
|
|
||
| ComponentRegistry.register('markdown', | ||
| ({ schema, className, ...props }) => ( |
There was a problem hiding this comment.
The renderer component function lacks JSDoc documentation. Add a JSDoc comment explaining that this is a Schema-driven renderer for markdown content, following the 'Schema First' principle outlined in Rule #3.
There was a problem hiding this comment.
Added detailed JSDoc documentation to the markdown renderer component explaining its schema-driven architecture and usage. Includes example JSON configuration and lists all supported features. (commit c31876c)
|
✅ All checks passed!
|
|
@copilot 从主分支之更新最新代码并修正代码冲突 |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
✅ All checks passed!
|
…mes, so the refusal screen becomes reachable (objectstack-ai#7062) * fix(app-shell,plugin-list): stop inventing calendar field names for views that declared none A view carrying no `calendar:` block used to have a complete-looking calendar config synthesized for it: `ObjectView` fabricated `startDateField: 'due_date'` and `titleField: 'name'`, and `ListView`'s calendar branch floored the same two bindings at `'start_date'` / `'end_date'` one layer down. `ObjectCalendar` decides whether it has a usable configuration by asking whether a start-date binding is PRESENT, so the fabrication short-circuited its own refusal screen — which has existed all along and was simply unreachable from this route. Both faces now forward only what the author declared. With no binding to forward, the capability gate stops offering the Calendar toggle to views that configured none, and a view forced onto the renderer reaches the refusal screen instead of a plausible, fully wrong one. Ruled on objectstack#13748 (director batch objectstack-ai#19, option A). The spec half — cross-field validation of a half-written declaration — is objectstack#13817. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013hfmP9hoMd3dJwTh85J4yB * fix(plugin-view): stop inventing calendar bindings on the element route too `generateViewSchema` runs when no host supplies `renderListView` — the authored `object-view` element — so it bypasses `ListView` and carried its own copy of the fabrication (`start_date` / `end_date` / `name`). Same defect, same ruling (objectstack#13748: no invented field names either way); fixing only the console route would have left this one producing the same wrong screen. Also retargets `ObjectView.titleFieldConvergence.test.tsx`: its `calendar` column pinned the `|| 'name'` floor this card deletes, and the seam count drops from seven to six. What objectui#6557 owns is unchanged and still pinned. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013hfmP9hoMd3dJwTh85J4yB * chore(changeset): objectui#7029 — no invented calendar field names Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013hfmP9hoMd3dJwTh85J4yB --------- Co-authored-by: Claude <noreply@anthropic.com>
…unwrap `rows` (objectui#7028) (objectstack-ai#10363) Fixes objectstack-ai#7028 Clause-②: yes ## What `aggregate()` now reads the `client.analytics.query` answer in one spelling: `rows` on the post-unwrap `AnalyticsResult`. This is condition 3 of the objectstack#13079 ruling's landing requirements (director batch objectstack-ai#19, option A, maintainer 2026-08-31), quoted verbatim: 「objectui 容错链同波收紧:已立 objectui#7028,带时序门(严格在收敛合并、objectui 采版之后 —— 该链今天是承重的)」. The card's sequencing gate is met: `@objectstack/client` 17.3.0 carries the convergence, and the workspace lockfile resolves 17.4.0. - **The ladder had five spellings, not the card's two.** It read a bare array, `rows`, `data` as an array, `data.data.rows` and `results`, and answered anything else with `[]`. Only `rows` survives. Any other value throws the new exported `AnalyticsResultShapeError` (`code: 'ANALYTICS_RESULT_SHAPE_INVALID'`, `envelope: true` for the pre-17.3.0 envelope). - **Loud means a throw, and the throw escapes the fallback.** The row read sits inside `aggregate()`'s `try`. Its `catch` would have classified the error as `unknown` and answered it with `aggregateViaFind`'s client-side numbers, so the catch now rethrows `AnalyticsResultShapeError` before it classifies anything. I chose a throw over a diagnostic because the file already treats contract violations that way: `AnalyticsQueryRejectedError` refuses the fallback for the same reason (framework#3878). A `[]` would repeat the confident zero that objectui#5954 removed on the failure side. - **The widened `AnalyticsResult` alias is gone**, along with the branches it existed for. - **The `@objectstack/client` floor moves from `^17.0.0` to `^17.3.0`** in `packages/data-objectstack` and `apps/console`. Only the lockfile specifier changes; the resolution stays at 17.4.0. `QUICK_REFERENCE.md`'s Client row was rewritten by `pnpm quick-reference:sync`. ## The premise, measured - **This was never a server question.** The comment above the old ladder (and the objectui#7122 changeset) described deleting the branches as "a runtime compatibility decision about servers older than objectstack-ai#13079". The convergence commit `db16b94` changes only `packages/client` and the spec migration registry, and no server code. `POST /analytics/query` answers `deps.success(result)` in objectstack's `domains/analytics.ts` from its first extraction (`8f124a7b7`, 2026-07-27, before 17.0.0 shipped on 2026-08-14) to `main`. Every 17.x server therefore sends the same `{ success, data }` envelope. Only the client decides whether it is unwrapped: `unwrapResponse` strips it at 17.3.0+, while 17.2.0 ended `return res.json()` (read in the installed 17.4.0 `dist/index.mjs` and a packed 17.2.0 tarball). No server is dropped. The compatibility axis is the **client** range, and that is why the floor moves. - **Which producer each branch served** (`git log -S` on the unshallowed history): - `rows` and `data.data.rows` came from `70cb62b85` (2026-04-01): the post-unwrap and envelope forms of the one route. - A bare array, `data` as an array and `results` came from `f25e6c288` (2026-02-25). That commit targeted a raw `GET /api/v1/analytics/{resource}` fetch, which `d91f2e2a0` replaced with `client.analytics.query` ten minutes later, and the three branches were carried over without shape evidence. - Even the retired in-kernel shim (removed by objectstack `77fadbfca` before 17.0.0) answered `{ success, data: { rows, fields } }`. No producer of this call site ever returned the other three shapes. - **`analytics.meta` and `analytics.explain` have no call sites in objectui.** `git grep` finds only `analytics.query` here, with a positive control on the same pattern. In the installed 17.4.0 client, `meta` and `explain` both end `return this.unwrapResponse(res)`, declared `AnalyticsMetadataResponse["data"]` and `AnalyticsSqlResponse["data"]`. `analytics.query` is declared as a Promise of `AnalyticsResult` (the generic is spelled out in words because GitHub strips angle-bracket spans). ## Surface beyond the claim, stated The claim named only `index.ts` (the ladder), the tests beside it and one changeset. Two extensions were needed: 1. **The rethrow line in `aggregate()`'s `catch` plus the new error class.** Without them the throw is silently answered by the fallback, which the pins require it must not be. 2. **The client floor, in `packages/data-objectstack/package.json`, `apps/console/package.json`, the two `pnpm-lock.yaml` specifier lines and `QUICK_REFERENCE.md`.** Leaving `^17.0.0` would publish a range this change makes false. `scripts/__tests__/quick-reference-current-release-4143.test.ts` went red on the adapter-only bump, because that row anchors both manifests. No open pull request holds these lines: objectstack-ai#10341 and objectstack-ai#8941 touch the lockfile and the console manifest in disjoint hunks, and objectstack-ai#5400 is the release pull request. `isLegacyOverlayRow` and the rest of `index.ts` are untouched. **Seat amendment (2026-09-24T20:14Z).** The seat accepted both extensions and widened the claim's File surface to match (claim comment `5820950909`, edited). Line 2 now reads `Clause-②: yes`, because the diff adds a public export (`AnalyticsResultShapeError`); a contract review is owed before enqueue. The changeset level moved from `patch` to `minor` at head `e6e26e35d` (objectui precedent objectstack-ai#9061 / objectstack-ai#9175). ## Pins (site-scoped, new file) `packages/data-objectstack/src/aggregate-rows-post-unwrap-7028.test.ts`, 7 tests: - The unwrapped shape yields its rows. The server's `{ success, data: { rows } }` wire envelope goes through the real client. - An envelope at the boundary throws, and `/api/v1/data` is never requested. This is tested twice: through the real client (a success-less `{ data: { rows } }` body that `unwrapResponse` leaves alone), and as the value a pre-17.3.0 client handed back. - The other three retired spellings throw instead of degrading to `[]`. - CONTROL: rows missing the measure still fall back to client-side aggregation. ## Verification (final head `52f5a6c21`) - `pnpm --filter @object-ui/data-objectstack type-check`: exit 0. `--listFiles` confirms the new test file is in that program. - `pnpm exec vitest run packages/data-objectstack/` from the repo root: `Test Files 68 passed (68)`, `Tests 933 passed (933)`. - These root suites read the touched files off disk, outside the package graph: every `scripts/__tests__` suite naming `data-objectstack`, `QUICK_REFERENCE`, `apps/console/package.json` or `pnpm-lock.yaml`. Result: `Test Files 27 passed (27)`, `Tests 1137 passed (1137)`. - `eslint .` in the package: 77 files linted (from `--format json`), 0 errors. Type-aware linting is off, so this diff cannot move any verdict in untouched files. - Gates, all exit 0: `check:control-bytes`, `check:new-line-citations` (0 new), `check-changeset-presence`, `check:changeset-claims`, `check:lockfile-integrity`, `check:lockfile-dedupe`, `check:installed-pin-claims`, `check:pending-changeset-literals`, `quick-reference:check`. - `check:changeset-claims` lists `5793`, `6361` and `7122` for naming `pnpm-lock.yaml`. I read each paragraph, and none is falsified by this diff. - `check:spec-floors`: NOT MEASURED. It refuses on an unbuilt workspace (`no-artifact`), and it reads `@objectstack/spec` floors only, which this diff does not move. - **Ablation 1:** I restored the five-spelling ladder with `ablation-replace.mjs` (anchor 1 to 0, blob `0b7bc68a9ed1` to `3b936fc60bb8`). Result: `Tests 5 failed | 2 passed (7)`, with every failure being `aggregate() resolved; it was expected to throw AnalyticsResultShapeError`. The two greens are the positive pin and the control. The restore is proven: blob equals HEAD `0b7bc68a9ed1` and `git diff HEAD` is empty. - **Ablation 2:** I deleted the `catch` rethrow. Result: the same 5 fail and 2 pass, because the error is answered by the fallback. The restore is proven the same way. - Both ablations run from source through a relative `./index` import, so no `dist` leg applies. ## Acceptance notes - `analytics.meta` and `analytics.explain` are not called anywhere in this repo, so they have nothing to tighten. - The pending `.changeset/7122-objectstack-family-17-3-0.md` still says the branches were kept "rather than deleted" and frames the question as one about servers. It is true of its own change and will publish in the same release as this one, so the new changeset names it and supersedes it rather than editing it. - The existing `aggregate-capability.test.ts` case "a `{ success, data: { rows } }` envelope is still a result" stays green. It is the server's wire envelope, which the installed client unwraps. After this change it is a positive control, not tolerance. - Dependents' type-check: `plugin-charts`, `plugin-dashboard` and `components` read `aggregate()` results through the `DataSource` interface and do not depend on this package. The only export-surface change is one added class: `export` lines in the diff are `+1 -0`, and the `aggregate` signature is untouched. No export-star re-export exists, and no other declaration of the name exists, so no importer's type-check input changes. The full workspace Type Check runs in CI. Session: `https://claude.ai/code/session_01BA3nKVUwKQJf8DBxrSVtNC` (dev run dispatched by the `domain:ui` seat 1). --- _Generated by [Claude Code](https://claude.ai/code/session_01BA3nKVUwKQJf8DBxrSVtNC)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
Implementation Plan for Markdown Component
Summary
Successfully implemented a new Markdown component for Object UI with comprehensive JSDoc documentation and merged latest changes from main branch.
Changes in This Update
✅ Added JSDoc Documentation
MarkdownPropsinterface✅ Merged Main Branch
Component Features
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.