feat: add chat app example#7518
Open
janechu wants to merge 9 commits into
Open
Conversation
5 tasks
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These editor-only TypeScript LSP plugins were inherited from the todo-app template but are not required for chat-app to build or run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Makes the iframe + document.write streaming visibly progressive during manual smoke tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Merge every component's <style> block into public/styles.css. - Scope each component's rules with :host(<tag>) so the same file can be loaded into multiple shadow roots without cross-component bleed. - Link the file from <head> in entry.html (render-blocking, so it loads before the rest of the HTML is processed) and from inside every declarative shadow DOM template in templates.html. - Update DESIGN.md to describe the new structure. The browser fetches the file once; each shadow root applies the cached stylesheet. Built output (www/index.html) shrinks ~70% (17.6 -> 5.5 kB) and the CSS is now cacheable across page loads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…okens - Move examples/chat-app/ → examples/ssr/chat-app/ to group it alongside other server-side-rendered examples. - Consume @microsoft/fast-examples-design-system via tokens.css; replace every hard-coded color, font size, line height, spacing, corner, stroke, shadow, duration, and curve in public/styles.css with var(--fast-...). Import tokens.css from src/main.ts and add the design-system.d.ts shim for the side-effect CSS import. - Hard-code the dark theme via <html data-theme="dark"> in entry.html; no runtime theme switching. - Gitignore the build-generated index.html. - Update root workspaces config (examples/ssr/*), workspace-level README.md and DESIGN.md, and .github/copilot-instructions to reference the new ssr/ location. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
743b249 to
9883a20
Compare
9883a20 to
517ee26
Compare
The chat-app's runtime is updated to use the workspace versions of `@microsoft/fast-element` and `@microsoft/fast-html` shipped on main instead of pinning to the v3 release-candidate from npm: - Components extend `RenderableFASTElement(FASTElement)` from `@microsoft/fast-html` and use the v2 `attr` decorator from `@microsoft/fast-element`. No more subpath imports (`fast-element/declarative.js`, `fast-element/hydration.js`, etc.) or per-element `declarativeTemplate()` definitions. - `src/main.ts` triggers hydration by registering `<f-template>` via `TemplateElement.options(...).define(...)` with `observerMap: 'all'` for each component, matching the pattern used by the webui-todo-app example. - `<f-template>` definitions in `templates.html` and the `@microsoft/fast-build` pipeline (build-markup.mjs + fast-build.config.json) are unchanged — they already speak the v2 marker format. - `package.json` switches every workspace `@microsoft/*` dependency to `*` so the chat-app always resolves to the in-repo packages on whichever branch it sits on, never to a pinned npm version. - README and DESIGN updates to describe the v2 hydration path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
517ee26 to
1efb264
Compare
Three issues prevented the chat-app from hydrating correctly: 1. The chat-* components were never registered with customElements. Calling defineAsync on each component (chat-app, chat-card, chat-message, chat-suggestion) registers them so the SSR markers in templates.html have something to hydrate against. 2. With target: ES2022, TypeScript emits class fields as Object.defineProperty calls, which create own properties on the instance that shadow the prototype getter/setter installed by @attr. Setting useDefineForClassFields: false in tsconfig.json makes TypeScript emit fields as constructor assignments, which correctly go through the @attr setter and keep bindings reactive. 3. fast-html's template parser does not trim whitespace inside {{ ... }} expressions. Bindings like '{{ welcomeTitle }}' became the property name ' welcomeTitle ' (with surrounding spaces) and silently evaluated to undefined, blanking the SSR text. Bindings are now written without inner whitespace and a local biome.json disables the HTML formatter for this app so biome cannot reintroduce the spaces. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous package-lock.json was regenerated on macOS arm64 and stripped the optional platform binaries for @ast-grep/cli (linux, windows, etc.). Azure Pipelines CI runs on Linux and could not install @ast-grep/cli-linux-x64-gnu, so the @ast-grep/cli postinstall script failed with 'Failed to move @ast-grep/cli binary into place.'. Regenerate the lockfile from main with all 7 platform entries preserved so 'npm ci' resolves the correct binary on every CI host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
📖 Description
examples/chat-appworkspace that mirrors thetodo-appexample shape while using declarative FAST templates@microsoft/fast-buildfromentry.html,state.json, andtemplates.htmldocument.write()streaming for canned assistant replies, including newchat-message,chat-card, andchat-suggestioncustom elementsREADME.mdandDESIGN.md👩💻 Reviewer Notes
Hi, and watch the assistant reply stream in chunk-by-chunk.index.htmlis generated from the declarative sources bybuild-markup.mjs; if the shell changes, regenerate it withnpm run build -w @microsoft/fast-chat-app-example.📑 Test Plan
npm run buildnpm run build -w @microsoft/fast-chat-app-examplenpm run test -w @microsoft/fast-chat-app-exampleHi→ streamed reply +How are you?suggestion)npm run testcurrently hits unrelated existing Playwright failures inpackages/fast-element/src/components/hydration.pw.spec.ts(Firefox) andpackages/fast-element/src/platform.pw.spec.ts(WebKit)✅ Checklist
General
$ npm run change