Skip to content

Rewrite stale example provenance on pre-#400 duplicates - #445

Merged
andeplane merged 3 commits into
mainfrom
claude/project-thread-beoay2
Oct 16, 2026
Merged

andeplane merged 3 commits into
mainfrom
claude/project-thread-beoay2

Conversation

@andeplane

Copy link
Copy Markdown
Owner

Requested by Anders Hafreager · project thread

Before: projects duplicated before #400 still have source: { type: "example", exampleId } in their project.json, so every run of them reports the original example's id to Mixpanel (Run.Start, Run.Finish, Simulation.Start) and inflates that example's numbers.

After: opening such a project rewrites its source to { type: "duplicate" } on disk, once, and its runs report as a normal project. Genuine example projects, renamed or not, and quick projects are left alone.

How: openProject checks a new isStaleExampleCopy(meta): an example source whose display name ends in "(copy)" or whose dirName ends in -copy / -copy-N, which is how duplicateProject names copies. Comparing dirName with exampleId doesn't work, because example projects get dirName = slug(displayName). Unit tests cover the check, and integration tests cover the on-disk rewrite, the metrics payload afterwards, and the untouched cases.

Closes #403

🤖 Generated with Claude Code

https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN


Generated by Claude Code

Before #400, duplicating a project copied the original's source, so copies
of example projects kept reporting the original's exampleId to metrics on
every run. When a library project is opened, detect such a copy (example
source and a "(copy)" display name or a -copy / -copy-N dirName) and
rewrite its source to { type: "duplicate" } once. Quick projects and
genuine example projects, renamed or not, are left alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
@andeplane andeplane self-assigned this Oct 16, 2026
@andeplane
andeplane marked this pull request as ready for review October 16, 2026 06:45
Brings the #403 stale-duplicate migration up to date with main, which
split src/store/projects.ts into src/store/projects/ (#462).

Conflict resolution (src/store/projects.ts modify/delete): took main's
deletion and ported the PR's change onto the new modules:
- isStaleExampleCopy (+ COPY_DIR_NAME) moved to
  src/store/projects/helpers.ts, next to isScriptFile.
- The one-time source rewrite in openProject moved to
  src/store/projects/library.ts.
- src/store/projects.test.ts moved to src/store/projects/helpers.test.ts,
  importing from ./helpers.
src/store/projects.integration.test.ts auto-merged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HB39E3Y4jpon2ijSXT7emN
@andeplane
andeplane merged commit dd7a0ac into main Oct 16, 2026
3 checks passed
@andeplane
andeplane deleted the claude/project-thread-beoay2 branch October 16, 2026 14:00
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.

Fix stale example provenance on projects duplicated before #400

2 participants