feat(todomvc-demo): add ?bug=1 reproducible bug for the connector case study#154
Conversation
…e study An opt-in, unit-tested TypeError (Sort by priority on unmigrated data), gated behind ?bug=1 so the default demo is unaffected. Backs the peek Slack-connector case study's reproducible read-path scenario. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: harry-harish <22562634+harry-harish@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds a demo bug-mode feature to the peek-todomvc-demo app: a bugMode query-param helper, a sortByPriority function with an intentionally unsafe cast, a wired-in "Sort by priority" button in App.tsx, corresponding unit tests, and Vitest test configuration/scripts. ChangesBug-mode sort demo
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant sortByPriority
participant todos
User->>App: click "Sort by priority"
App->>sortByPriority: sortByPriority(todos.todos)
sortByPriority-->>App: sorted array or TypeError
App->>todos: todos.reorder(sorted)
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/peek-todomvc-demo/vitest.config.ts (1)
5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winBroaden the
includeglob to match the workspace test-file convention.The pattern
src/**/*.test.tswon't discover.test.tsxor.test.jsfiles. Since App.tsx is modified in this PR and the coding guidelines reference**/*.{test,spec}.{ts,tsx,js}as the test-file convention, future component tests for the React UI would silently be skipped by Vitest.♻️ Suggested include pattern
- include: ['src/**/*.test.ts'], + include: ['src/**/*.{test,spec}.{ts,tsx,js}'],🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/peek-todomvc-demo/vitest.config.ts` at line 5, The Vitest config in the include setting is too narrow and only matches TypeScript test files under src, so React component tests like .test.tsx and .test.js will be skipped. Update the include glob in vitest.config.ts to follow the workspace test-file convention used elsewhere, and make sure it targets all test/spec files for ts, tsx, and js so App.tsx-related tests are discovered by Vitest.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/peek-todomvc-demo/vitest.config.ts`:
- Line 5: The Vitest config in the include setting is too narrow and only
matches TypeScript test files under src, so React component tests like .test.tsx
and .test.js will be skipped. Update the include glob in vitest.config.ts to
follow the workspace test-file convention used elsewhere, and make sure it
targets all test/spec files for ts, tsx, and js so App.tsx-related tests are
discovered by Vitest.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e67eec76-00ab-48e4-a7e1-66d2917e3795
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (7)
apps/peek-todomvc-demo/package.jsonapps/peek-todomvc-demo/src/App.tsxapps/peek-todomvc-demo/src/lib/bugMode.test.tsapps/peek-todomvc-demo/src/lib/bugMode.tsapps/peek-todomvc-demo/src/lib/sortByPriority.test.tsapps/peek-todomvc-demo/src/lib/sortByPriority.tsapps/peek-todomvc-demo/vitest.config.ts
What
Adds an opt-in, unit-tested, intentionally-introduced client-side bug to the demo app, gated behind
?bug=1, so the peek Slack-connector case study has a real, 1:1-reproducible failure to debug.src/lib/bugMode.ts—isBugMode(search)reads the?bug=1flag.src/lib/sortByPriority.ts— a "Sort by priority" sort that reads an unmigratedpriority.levelfield (hidden from the type-checker by a loose cast), so it compiles clean under strict TS but throws at runtime:TypeError: Cannot read properties of undefined (reading 'level'). The bug is disclosed in a JSDoc comment.src/App.tsx— a "Sort by priority" button rendered only under?bug=1; its click handler calls the buggy sort (the throw surfaces uncaught to the console while the app stays interactive).vitest+ a minimal config; unit tests cover both the flag and the runtimeTypeError.Why
It's the failure the case study reads back from a Slack thread ("what failed in my last session?" → causal chain → repro → act-with-consent). Gating behind
?bug=1keeps the shipped/demobyte-for-byte unaffected.Notes
?bug=1and at least one todo).@peekdev/todomvc-demoisprivate: true.pnpm --filter @peekdev/todomvc-demo dev, open/?bug=1, add a todo, click Sort by priority.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests & Chores