feat(developer-portal): integrate docs AI widget and landing updates#687
feat(developer-portal): integrate docs AI widget and landing updates#687
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
- Add i18n to DeviceActionAnimation (7 hardcoded Chinese strings) - Fix Chinese fallback text in PinDialog and PassphraseDialog t() calls - Fix Chinese console.log/error messages in GlobalDialogManager, PinDialog, PassphraseDialog - Fix Chinese default title in UnifiedLogger - Add deviceAction i18n keys to en.ts and zh.ts - Fix malformed code blocks in nip04.decrypt.mdx and nip04.encrypt.mdx - Fix stray code block delimiter in devicesettings.mdx (en + zh) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0bcf166 to
99d2b2d
Compare
…ator
- Add transformSourceUrl() to rewrite GitHub developer-portal content
URLs to live docs page URLs via regex, e.g.
github.com/.../developer-portal/content/en/hardware-sdk/foo.mdx
→ {origin}/en/hardware-sdk/foo
No static mapping table needed; works across test and prod origins
automatically via window.location.origin
- Replace status === 'submitted' streaming indicator condition with
isWaitingForContent = isGenerating && no renderable text yet, so the
"Generating…" dots stay visible until the first token actually renders
in the message list, eliminating the blank gap between dot-disappear
and text-appear during the LLM time-to-first-token window
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…format - Remove passphrase12_*.ts indirection in addressTest/pubkeyTest count12_three: move actual data into passphrase_empty/1/2.ts, update normal.ts to spread passphrase_empty directly, delete normal12.ts and all passphrase12_*.ts files. All 9 datasets now have the same flat file structure. - Fix stop button not giving immediate UI feedback: set progress.status to 'paused' in stopAutomation so isAutomationRunningAtom updates instantly, unlocking the start button without waiting for the loop to exit. - Change formatDuration to HH:MM:SS format for durations >= 1 minute (e.g. 1:23, 2:05:30 instead of 83.0s or 7530.0s). - Simplify start/stop button styling to use Tamagui theme="green/red", removing verbose hardcoded backgroundColor/hoverStyle/pressStyle overrides. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add notifyLiveCaseUpdate to the dependency arrays of 5 useCallback hooks that were using it but not declaring it, fixing react-hooks/exhaustive-deps lint warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…docs - Wrap @onekeyfe package names in backticks within markdown table links to prevent AI chat renderers from misinterpreting @ as mention syntax - Remove bare @ in search-devices.mdx code comments (en/zh) - Expand cancel-request.mdx (en/zh) from a stub into a full guide with: - Cancel vs disconnect explanation - Usage scenarios (timeout, unmount, retry) - Code examples (basic, React cleanup, timeout pattern) - Error code reference Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Revert the backtick wrapping of @onekeyfe package names in markdown links — the @ rendering issue is in the AI chat widget (PR #687), not in the documentation itself. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…estions, expand cancel docs - Add wrapBarePackageNames() to DocAIMarkdownMessage sanitizer: wraps bare @onekeyfe/... package names in backticks so remark-gfm doesn't mangle them as autolinks. Skips content already in backticks or fenced code blocks. - Update default AI chat suggestions (en + zh) to more practical developer questions: WebUSB connection, React Native BLE setup, and EVM transaction signing with full code examples. - Expand cancel-request.mdx (en + zh) from a minimal stub to a comprehensive guide with cancel vs disconnect comparison, usage scenarios, React cleanup patterns, and error code reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…/add-doc-ai-chat-widget
…kdown rendering - Fix streaming freeze: replace memo-based throttle with leading+trailing edge state-based throttle so UI always catches up within 150ms - Fix @ symbol: broaden scoped package wrapping to all @scope/pkg patterns - Fix syntax highlighting: use ESM import, remove color !important override - Increase markdown font size (13px→14px) for better readability - Redesign header: inline search input with tab switcher on one row - Fix search bottom padding: wrap content in inner div (reliable for scroll containers) - Add keyboard navigation: arrow keys switch selection, ↵ icon follows active item - Move onKeyDown to panel level so arrow keys work regardless of focus - Add scroll-into-view for both search results and bridge row - Style navbar search hotkey as separate ⌘ K keycaps like Inkeep - Fix SSR hydration: defer resolveApiUrl to useEffect - Soften input placeholder styling Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…disabled endpoint
The previous hydration fix used useState with env var fallback, but when
NEXT_PUBLIC_DOCS_AI_API_URL is not set, the initial state was '' causing
chatApiUrl to be '/api/__docs_ai_disabled'. The transport was created with
this URL before useEffect could resolve the real URL from window.location.
Now: useState('') + useEffect(resolveApiUrl) ensures no request is made to
the disabled endpoint because the widget is closed (returns null) during
the first render, and the real URL is set before any user interaction.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…utton for user messages
Root cause: DefaultChatTransport was always created with a URL, even when
apiUrl was empty (''). The fallback '/api/__docs_ai_disabled' triggered a
405 POST. Now transport is undefined when no API URL is available — useChat
receives no transport and makes no requests until the real URL resolves.
Also adds a copy button to user messages so both sides of the conversation
can be copied.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ton color
- Remove useState/useEffect for API URL — call resolveApiUrl() directly
during render. The URL is derived from env var or window.location hostname,
same as the sources endpoint. SSR returns '' but widget is closed so no
hydration mismatch.
- Move user message copy button outside .bubble div to avoid color being
overridden by .userMessage .bubble * { color: inherit !important }.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Changed .userMessage from horizontal flex to vertical column so the copy button appears below the bubble instead of beside it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… streaming Two root causes for streaming lag: 1. SyntaxHighlighter (Prism) runs expensive parsing on every throttled render during streaming — a large TypeScript block can take 50-100ms per render, blocking the main thread and causing visible stalling. 2. The `components` object was recreated on every render, forcing ReactMarkdown to re-process even when displayText hadn't changed. Fixes: - Disable syntax highlighting during streaming (disableHighlight=true) — code blocks render as plain <pre><code> which is nearly instant. Full Prism highlighting activates once streaming ends. - Memoize the components object and move remarkPlugins to module scope so ReactMarkdown skips unnecessary re-processing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eact-renderer Switch from react-syntax-highlighter (~200KB, heavy Prism bundle) to prism-react-renderer (~3KB) — the same library Inkeep/Docusaurus use. Key improvements: - Syntax highlighting now works DURING streaming without lag - Bundle size reduced significantly - Throttle interval lowered to 120ms (was 150ms) since rendering is cheaper - Removed disableHighlight flag — no longer needed - Registered bash/shell/java grammars manually for coverage - Cleaned up CSS: removed react-syntax-highlighter-specific :global overrides Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EditorCodeBlock also depended on react-syntax-highlighter which was removed. Migrated to prism-react-renderer while preserving all features: line numbers, active line highlight, breakpoint indicators, dark/light mode theming. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ebpack remark-gfm@4 and its dependencies (unist-util-visit@5, unist-util-visit-parents@6) are ESM-only modules that cause webpack code generation errors. Adding them to transpilePackages lets Next.js transform them for compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace horizontal scrolling cards with a vertical list layout: - Simple row per source: index badge + title + arrow icon - Removed CODE type badge and excerpt text for cleaner look - Bordered list with dividers between items - Arrow icon animates on hover (translate + accent color) - Title text truncates with ellipsis on overflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…-up messages
1. Prism global CSS leak: Nextra loads prismjs CSS globally which adds
`background: #ffffff80` to `.token.operator/.entity/.url` — visible as
white selection-like highlights on operators in chat code blocks.
Added `.codeScroll :global(.token) { background: none }` reset.
2. Font: removed Fira Code from monospace stack, use system monospace
(ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas) instead.
3. 403 on follow-up: long assistant responses were sent back verbatim
in conversation history, making the request body too large for the
RAG API. Now truncates older assistant messages to 2000 chars.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…and enrich passphrase docs - Wrap markdown tables in scrollable div to fix width not filling container - Neutralize Nextra global Prism CSS (.token background) in EditorCodeBlock - Enrich passphrase docs with device support matrix, interaction flow diagrams, and FAQ (en/zh) - Remove security risk descriptions about software input from passphrase docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ce ASCII diagrams - Remove BLE/USB/Air-Gap rows from device matrix (not passphrase-specific) - Remove recommendation callout - Replace ASCII sequence diagrams with clean numbered step lists Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace step lists with Mermaid sequenceDiagram for proactive, reactive, and session caching flows (en/zh). Nextra 4.6.0 has built-in mermaid support via @theguild/remark-mermaid. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove dev:docs:webpack and dev:docs:ai-gateway shortcuts from root package.json — these can be run directly in developer-portal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Changes
developer-portaland keep the modal available by defaultNEXT_PUBLIC_DOCS_AI_API_URLto override for local or stagingValidation
yarn build:docsNotes