Skip to content

feat(todomvc-demo): add ?bug=1 reproducible bug for the connector case study#154

Merged
harry-harish merged 1 commit into
mainfrom
feat/todomvc-demo-bug-mode
Jul 9, 2026
Merged

feat(todomvc-demo): add ?bug=1 reproducible bug for the connector case study#154
harry-harish merged 1 commit into
mainfrom
feat/todomvc-demo-bug-mode

Conversation

@harry-harish

@harry-harish harry-harish commented Jul 9, 2026

Copy link
Copy Markdown
Member

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.tsisBugMode(search) reads the ?bug=1 flag.
  • src/lib/sortByPriority.ts — a "Sort by priority" sort that reads an unmigrated priority.level field (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).
  • Adds vitest + a minimal config; unit tests cover both the flag and the runtime TypeError.

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=1 keeps the shipped /demo byte-for-byte unaffected.

Notes

  • Default demo path is unchanged (button only appears with ?bug=1 and at least one todo).
  • No changeset — @peekdev/todomvc-demo is private: true.
  • Reproduce: 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

    • Added a “Sort by priority” option in the demo when bug mode is enabled.
    • Added support for a bug-mode query setting to toggle this behavior.
  • Tests & Chores

    • Added automated test coverage for bug-mode detection and sorting behavior.
    • Added project test and preview commands for easier local validation.

…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>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Bug-mode sort demo

Layer / File(s) Summary
bugMode and sortByPriority helpers
apps/peek-todomvc-demo/src/lib/bugMode.ts, apps/peek-todomvc-demo/src/lib/bugMode.test.ts, apps/peek-todomvc-demo/src/lib/sortByPriority.ts, apps/peek-todomvc-demo/src/lib/sortByPriority.test.ts
isBugMode checks for bug=1 in a query string; sortByPriority sorts todos by priority.level via an unsafe cast documented as causing a TypeError for todos without a priority field; both are covered by Vitest tests.
App.tsx wiring
apps/peek-todomvc-demo/src/App.tsx
App derives bugMode from window.location.search and conditionally renders a "Sort by priority" button that calls todos.reorder(sortByPriority(todos.todos)) on click, marked as an intentional demo bug.
Vitest configuration and scripts
apps/peek-todomvc-demo/package.json, apps/peek-todomvc-demo/vitest.config.ts
Adds vitest devDependency, preview and test scripts, and a vitest.config.ts restricting tests to src/**/*.test.ts under the node environment.

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)
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: an opt-in ?bug=1 reproducible bug added to the TodoMVC demo.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/todomvc-demo-bug-mode

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/peek-todomvc-demo/vitest.config.ts (1)

5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Broaden the include glob to match the workspace test-file convention.

The pattern src/**/*.test.ts won't discover .test.tsx or .test.js files. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 763c623 and ae14781.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (7)
  • apps/peek-todomvc-demo/package.json
  • apps/peek-todomvc-demo/src/App.tsx
  • apps/peek-todomvc-demo/src/lib/bugMode.test.ts
  • apps/peek-todomvc-demo/src/lib/bugMode.ts
  • apps/peek-todomvc-demo/src/lib/sortByPriority.test.ts
  • apps/peek-todomvc-demo/src/lib/sortByPriority.ts
  • apps/peek-todomvc-demo/vitest.config.ts

@harry-harish harry-harish merged commit e8951fb into main Jul 9, 2026
7 checks passed
@harry-harish harry-harish deleted the feat/todomvc-demo-bug-mode branch July 9, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant