Skip to content

fix(project): trim whitespace from project names - #9

Merged
baiirun merged 1 commit into
mainfrom
fix/trim-project-names
Sep 24, 2026
Merged

baiirun merged 1 commit into
mainfrom
fix/trim-project-names

Conversation

@baiirun

@baiirun baiirun commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Problem

Project names were stored exactly as given. A padded value such as -p " spindle" (for example from a shell variable that zsh didn't word-split) created a separate project that looks identical in prog show but never matches prog list -p spindle, because every filter compares names exactly. In practice, one epic and its tasks were split across " spindle" and spindle.

Change

  • model.NormalizeProject trims surrounding whitespace. It's applied on every write path: the CLI -p flag, prog project, CreateItem, SetProject, and EnsureProject.
  • Schema migration v4 trims existing names in items, learnings, labels, and concepts, and merges padded projects rows into the trimmed name. It runs once when prog next opens a database. Every statement can be re-run safely. A label or concept whose trimmed name already exists is left as is, so the migration doesn't fail on it.

Why a migration instead of whitespace-insensitive filtering

Loose matching would still leave duplicate projects, labels, and learnings under two spellings. Normalizing once at the storage layer keeps exact matching correct everywhere.

Testing

  • TestCreateItemNormalizesProjectForFiltering: a task created with " brandnew\t" is found by -p brandnew.
  • TestMigrateTrimsExistingProjectNames: seeds a mix of padded and clean rows at v3, migrates twice, and checks filtering and that no padded projects remain.
  • Both tests fail without the fix. go test ./... and go vet ./... pass.
  • Checked against a copy of a real database: list -p spindle went from 5 items to all 13, with a single spindle project and user_version 4.

🤖 Generated with Claude Code

Project names were stored verbatim, so -p " spindle" (e.g. from an unsplit shell variable) created a distinct, visually identical project that -p spindle never matched. Names are now trimmed on every write path (CLI -p, prog project, CreateItem, SetProject, EnsureProject), and schema migration v4 trims existing rows in items, learnings, labels, concepts, and projects, merging padded project rows into the trimmed name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@baiirun
baiirun merged commit 125e688 into main Sep 24, 2026
4 checks passed
@baiirun
baiirun deleted the fix/trim-project-names branch September 24, 2026 02:54
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