[feat](copilot,chat,guide): Interactive Copilot, Chat Advisor & modern Guide (Phase 3) - #57
Merged
Merged
Conversation
A grounded, offline, rule-based assistant built on the Adapter Pattern. Engine/state (decoupled, src/lib/chat/): - ChatAdapter contract + getChatAdapter() single swap-point; localAdvisorAdapter answers from the FROZEN engine + config (answerText() pure, unit-tested) so it can never contradict the model or fabricate. Network LLM = drop-in later, zero UI change. Streams via AsyncIterable under an AbortSignal. - buildChatContext(): structuredClone deep-clone + dependency-free validation; invalid/partial input → complete moderate baseline (no undefined/crash). - useChat: throttled submits + ignore-while-streaming (no spam), stop/regenerate/ abort, hydration-safe persistence, cross-tab reset via BroadcastChannel. UI (lazy, src/components/chat/): - ChatFab (lazy) → ChatMount → ChatPanel; memoized bubbles render via the existing dependency-free XSS-safe-by-construction markdown renderer, each in a per-bubble ErrorBoundary. Smart-scroll (IntersectionObserver, pauses on manual scroll-up), streaming caret, Stop/Regenerate, suggestions, full a11y (labelled dialog, polite live region, keyboard), EN/ID. Wiring (anti-regression): FAB mounted GLOBALLY so tab-switch closes the Guide but never unmounts chat / disrupts a stream; "Start Over" wipes chat + broadcasts. Bundle: FAB + all chat lazy → INITIAL budget untouched (119.9/120); total 260→268 (documented). Browser-verified: grounded /100 reply, survives nav, reset wipes, EN/ID. 145 unit (+17) + 14 e2e, tsc, lint, all 6 guards green. README Phase 3 section + Mermaid + adapter integration snippet; DECISIONS records the two reconciliations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… (Phase 3) Add a pluggable, 100% client-side Interactive Copilot (`src/features/copilot/`): a "Guide me" launcher runs a bilingual, step-by-step walkthrough of the four-step Advisor journey — spotlighting each target with Do/Don't guidance. - Adapter Pattern (`getCopilotService()`), closed `data-tour-id` whitelist, typed leak-free event bus, React-portal overlay (spotlight + card) with live tracking (ResizeObserver + MutationObserver + scroll/resize/visualViewport). Missing target degrades to a silent fallback; every observer/listener/timer is cleaned up. - Pre-Flight Check: navigate to the step's view, wait for paint, scroll the target BELOW the pinned chrome (app bar + step rail) so the spotlight is never hidden, and keep it ABOVE the mobile bottom-sheet card (pinned header/footer, scroll-only body) so a full step — title, body, Do/Don't — is never clipped. The app's sticky step-rail hides while the tour runs (the Copilot is the guide). Step 1 anchors the compact "Build custom system" card so the spotlight fits small screens. - Dependency-free + XSS-safe-by-construction (reuses `lib/markdown`), lazy-loaded so the initial JS budget is untouched; engine is unit-tested, overlay verified in-browser. Gate the AI Advisor chat OFF behind a single flag (`FEATURES.chat`, `src/config/features.ts`) while its UX is finalized: App skips mounting the FAB and the tour filters out its chat step, so nothing points at a control that isn't on screen. Re-enabling is a one-line change. README + DECISIONS updated to reflect both. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Phase 3 — Interactive Copilot, Chat Advisor & a modernized Guide
All 100% client-side, offline, dependency-free; nothing in the frozen model was touched.
Interactive Copilot (
src/features/copilot/)A "Guide me" launcher runs a bilingual, step-by-step walkthrough of the four-step Advisor journey, spotlighting each target with Do/Don't guidance.
data-tour-idwhitelist, typed leak-free event bus, React-portal overlay with live tracking; missing target → silent fallback.Chat Advisor (formerly "AI Advisor", Advisor-tab only)
Renamed so the name matches reality — a client-side, offline, rule-based assistant computed from the frozen engine, never a language model. Confined to the Advisor tab (that's where the scenario is).
Modernized Guide / Manual ("Panduan")
.aa-manual-*classes; inline styles removed). The TOC usesscrollIntoView, not#hashanchors, so it never touches the share-state URL.Cross-feature
Gates
tsc clean · lint 0 warnings · 184/184 unit · 14/14 E2E · 6/6 guards · bundle within budget (initial 120.5/121 · total 274.6/278 · CSS 27.6/29 kB gzip — total raised 268→278 for the added grounded content, still lazy-loaded, under the 300kB NFR cap).
README + DECISIONS updated throughout.
🤖 Generated with Claude Code