Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f63875
Add design spec for React/TypeScript rewrite
dkackman Jul 6, 2026
68b1045
Add implementation plan for React/TypeScript rewrite
dkackman Jul 6, 2026
600b245
Scaffold Vite + React + TypeScript app with copied static assets
dkackman Jul 6, 2026
7237567
Add geometry and velocity primitives
dkackman Jul 6, 2026
c65b240
Port fish physics engine from FishAnimation.cs
dkackman Jul 6, 2026
096f47f
Port chat message model with commands and emotes
dkackman Jul 6, 2026
5d6192f
Port reasoning parser for think-tag streams
dkackman Jul 6, 2026
cd293e5
Add fish tank store with bubble visibility timers
dkackman Jul 6, 2026
b19c2fb
Add streaming LLM generation with stall watchdogs and web worker
dkackman Jul 6, 2026
48695d2
Add LLM engine module with transcript and model cache queries
dkackman Jul 6, 2026
e89bbed
Clear fake engine mock between LLM engine tests
dkackman Jul 6, 2026
38ed9ac
Add LLM store for model selection, loading, and progress
dkackman Jul 6, 2026
0c80a07
Strengthen LLM store test assertions
dkackman Jul 6, 2026
38271bc
Add message dispatcher with command routing and streaming updates
dkackman Jul 6, 2026
07f3fad
Add styles, message bubble, and floating toast components
dkackman Jul 6, 2026
b0db962
Add animation ticker, fish, and fish tank components
dkackman Jul 6, 2026
e85415a
Clean up drag listeners when a fish unmounts mid-drag
dkackman Jul 6, 2026
a933f83
Add chat input, LLM settings dialog, and complete app wiring
dkackman Jul 6, 2026
9dd3611
Add PWA manifest and service worker via vite-plugin-pwa
dkackman Jul 6, 2026
a6f6780
Remove Blazor projects; update README, dig.toml, and editor config fo…
dkackman Jul 6, 2026
67290c7
Ignore TypeScript build-info and Playwright MCP scratch files
dkackman Jul 6, 2026
ec52008
Update package.json to add allowScripts for esbuild and fsevents
dkackman Jul 6, 2026
10f9288
Enhance chat input and dispatcher to manage message sending state
dkackman Jul 6, 2026
3bd51fd
Refactor FishTank component to use ID for ticker reference and update…
dkackman Jul 6, 2026
c4c28e8
Refactor CI workflow to remove .NET setup and replace with Node.js se…
dkackman Jul 6, 2026
c9a1431
chore: update dependencies in package.json
dkackman Jul 6, 2026
b3e443e
chore: update package.json with linting and formatting scripts, add E…
dkackman Jul 6, 2026
1df48e8
format
dkackman Jul 6, 2026
0f5fef3
chore: update Node.js version requirement in README, refine ESLint ig…
dkackman Jul 6, 2026
c3d1825
format
dkackman Jul 6, 2026
b949c77
docs: add digstore notes and publishing workflow to README
dkackman Jul 6, 2026
a769eb1
fix: regenerate package-lock.json to resolve npm ci inconsistency
dkackman Jul 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Setup .NET
uses: actions/setup-dotnet@v5
- name: Setup Node
uses: actions/setup-node@v4
with:
dotnet-version: "10.0.x"
node-version: "24.x"
cache: npm

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --no-restore --configuration Release
- name: Install
run: npm ci

- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
run: npm test

- name: Build
run: npm run build
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,15 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# Vite / node
node_modules/
dist/
.superpowers/

# TypeScript incremental build state
*.tsbuildinfo

# Playwright MCP scratch
.playwright-mcp/
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
package-lock.json
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"printWidth": 100,
"tabWidth": 2
}
28 changes: 0 additions & 28 deletions .vscode/launch.json

This file was deleted.

69 changes: 25 additions & 44 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/ChatFish.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/ChatFish.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/ChatFish.sln"
],
"problemMatcher": "$msCompile"
}
]
}
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "npm",
"script": "build",
"group": { "kind": "build", "isDefault": true },
"problemMatcher": ["$tsc"]
},
{
"label": "dev",
"type": "npm",
"script": "dev",
"isBackground": true,
"problemMatcher": []
},
{
"label": "test",
"type": "npm",
"script": "test",
"group": { "kind": "test", "isDefault": true },
"problemMatcher": []
}
]
}
47 changes: 47 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What this is

ChatFish is a React 19 + TypeScript + Vite SPA: an animated fish tank where an AI fish chats with you using a local LLM. Inference runs entirely client-side via [web-llm](https://github.com/mlc-ai/web-llm) — the model is downloaded to the browser and run on WebGPU in a Web Worker; no server, no data leaves the machine.

## Commands

```sh
npm run dev # start Vite dev server
npm run build # tsc -b && vite build -> dist/
npm test # vitest run (single run, CI mode)
npm run test:watch # vitest watch mode
npx vitest run src/engine/geometry.test.ts # run a single test file
npm run lint # eslint .
npm run format # prettier --write .
npm run format:check # prettier --check .
```

CI (`.github/workflows/ci.yml`) runs `npm test` then `npm run build` on push/PR to `master`. Node >= 24 is required (see `engines` in package.json).

Requires a WebGPU-capable browser (recent Chrome/Edge/Firefox) to actually exercise the LLM at runtime; unit tests run under jsdom and don't need WebGPU.

## Architecture

Three largely independent layers, wired together by a thin dispatcher:

- **`src/engine/`** — pure fish-tank physics/animation, no React or DOM dependencies beyond `getBoundingClientRect`. `ticker.ts` runs a `requestAnimationFrame` loop that steps the simulation in fixed `TICK_MS` (50ms) increments — this cadence matches physics constants (speeds, turn probabilities) inherited from the original Blazor app's 50ms timer, so don't change `TICK_MS` without re-tuning `fishAnimation.ts`. `geometry.ts` handles tank bounds/collision math.

- **`src/llm/`** — wraps `@mlc-ai/web-llm`. `engine.ts` owns a module-level singleton (`engine`, `loadedModel`, `transcript`) — there is one shared conversation transcript across the whole app, not one per component. `worker.ts` is the actual Web Worker entry (loaded via `new Worker(new URL("./worker.ts", ...))`) that runs `WebWorkerMLCEngineHandler` off the main thread. `generation.ts` defines the narrow `GenerationEngine`/`GenerationCallbacks` interface that `engine.ts` adapts web-llm to, so the rest of the app isn't coupled to web-llm's full API surface.

- **`src/state/`** — Zustand stores plus message/command parsing.
- `fishStore.ts`: UI state (per-fish message bubbles with auto-hide timers, toast, settings dialog visibility, offline flag, `isGenerating` guard).
- `llmStore.ts`: model selection/download/load state, persists `selectedModel` to `localStorage`.
- `dispatcher.ts`: the seam between chat input and the LLM — parses slash commands (`/help`, `/about`, `/llm`) vs. emotes vs. plain messages, streams tokens from `sendChatMessage` into the AI fish's bubble, and defers to `reasoningParser.ts` to split a model's `<think>...</think>` chain-of-thought from its actual answer (only the answer is shown and persisted to transcript; reasoning is transient).
- `isGenerating` in `fishStore` exists specifically to stop a second send from racing a second `generate()` call against the same shared engine/transcript — don't remove this guard without replacing the underlying serialization.

- **`src/components/`** — presentational React components (`FishTank`, `Fish`, `ChatInput`, `MessageBubble`, `LLMSettingsDialog`, `FloatingToast`) that read/write the Zustand stores above; no business logic of note lives here beyond wiring.

Data flow for a chat turn: `ChatInput` → `dispatcher.dispatchMessage` → `llm/engine.sendChatMessage` (pushes onto the shared transcript, calls into the worker) → streamed `onUpdate`/`onFinish` callbacks → `reasoningParser` splits thinking vs. answer → `fishStore.setFishMessage` updates the bubble.

## PWA / deployment

- `vite-plugin-pwa` precaches build assets; the web-llm chunk is large, so `maximumFileSizeToCacheInBytes` is raised to 10MiB in `vite.config.ts`. Model _weights_ are fetched/cached separately by web-llm itself (browser Cache Storage), not by the service worker precache.
- The site is published to a DIG (Chia) on-chain store; `dig.toml` at the repo root configures `store-id`, `output-dir` (`dist`), and the `build-command` run before each `digstore deploy`.
25 changes: 0 additions & 25 deletions ChatFish.Tests/ChatFish.Tests.csproj

This file was deleted.

97 changes: 0 additions & 97 deletions ChatFish.Tests/ChatMessageTests.cs

This file was deleted.

Loading
Loading