Repository navigation
Apply the B3Pay design system to B3Note and add on-device AI - #12
Merged
Merged
Conversation
Restyle the app with the B3Note design system (B3Pay's tokens plus paper): - Tailwind's zinc palette now maps to B3Pay's warm graphite and brand to B3Pay amber (bronze where it is text on a light ground); B3Pay radii, buttons, fields, chips and notices; Schibsted Grotesk and Martian Mono bundled with Fontsource instead of Inter, so no font request leaves the app. - Notes are paper: each note gets one of five papers from its id, with a folded top-right corner, in the list (a stack of small sheets that lift under the pointer) and in the editor (a ruled sheet for writing). - Empty states show a stack of blank paper; waits use the animated mark. - New draft B3Note mark (B3Pay's mark with the node folded into a note) for the header, favicons, app icons and README; scripts/brand-icons.py now generates it. The mark still needs sign-off. Add an on-device AI assistant (lib/localAi.ts): Chrome's built-in Gemini Nano when the browser has it, otherwise Qwen2.5-1.5B-Instruct on the GPU with WebLLM, downloaded once only after the user asks. Every assistant action and "Ask your notes" run in the browser by default, so note text stays inside the end-to-end encryption; the LLM canister remains a second, opt-in choice. AI results show as blocks that are dashed while drafting and solid when ready, and always say where they ran. Settings can remove the downloaded model. The CSP gains 'wasm-unsafe-eval' and the model download hosts (Hugging Face, raw.githubusercontent.com) for WebLLM; nothing else changes on the network. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two holes in the on-device AI's promise that no note text leaves the browser. Remote images. AI answers render as Markdown, and the CSP's img-src allowed any https host. A prompt hidden in a note (pasted from a web page, say) could steer the model into writing a Markdown image whose URL carries other notes' text, and the browser would fetch it. An image in a shared note also told its sender when it was opened. Markdown now shows images as links, and img-src allows only 'self' and data:. The WebLLM model. web-llm's own record downloads the model's files and its WebAssembly library from the main branches of Hugging Face and GitHub, unchecked. WEBLLM_CONFIG pins both at a commit (Hugging Face 9bd564b, binary-mlc-llm-libs 025bcaf, the commit that added the v0_2_84 library) and gives web-llm SRI hashes for the config, tokenizer.json and the library, with onFailure "error". Loading and removing the model both use it. A test compares it with web-llm 0.2.85's own record. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017cSwEz3Q2o3DpuJ8qSQzY5
fix(ai): load no remote images, and pin the on-device model
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.
What changed
A new look, from the B3Pay design system. B3Note now uses B3Pay's tokens (warm graphite neutrals, B3Pay amber, its radii, buttons, fields and notices) plus a B3Note layer of paper:
zincpalette is remapped to B3Pay's graphite andbrandto amber (bronze where it is text on a light ground), so the existing utility classes pick up the new look with few edits (frontend/src/styles.css).frontend/scripts/brand-icons.pynow generates it.On-device AI (
frontend/src/lib/localAi.ts). Every assistant action and "Ask your notes" now runs in the browser by default:ai_enabledis on, with its consent dialog unchanged.Why
The ask was to use our B3Pay design system, give the note app a cuter look and add AI. The canister's AI is off on mainnet because it needs plaintext. An on-device model gives users AI without leaving the encryption.
For reviewers
public/.ic-assets.json5):script-srcadds'wasm-unsafe-eval'(WebLLM compiles its WebAssembly) andconnect-srcaddshuggingface.co,*.huggingface.co,*.hf.coandraw.githubusercontent.comfor the one-time model download. Chrome's built-in model needs none of this. If we'd rather not widen the CSP, the WebLLM fallback can be dropped and on-device AI kept for Chrome only.tools/logo/build.js.@fontsource-variable/schibsted-grotesk,@fontsource/martian-mono,@mlc-ai/web-llm@0.2.85.Testing
pnpm typecheck,pnpm test(52 passing, including 4 new tests for the on-device prompts),vite buildand Prettier all pass.scripts/pocketic-dev.ts): landing, guest sign-in, creating and editing notes, tags, the AI panel on both engines, applying a result, Ask, Settings, light and dark themes, and phone width.LanguageModel; Gemini Nano and Qwen weren't downloaded, so answer quality and speed on real hardware still need a try. Internet Identity and share links weren't exercised locally (the PocketIC setup has no II).🤖 Generated with Claude Code