fix(project): trim whitespace from project names - #9
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inprog showbut never matchesprog list -p spindle, because every filter compares names exactly. In practice, one epic and its tasks were split across" spindle"andspindle.Change
model.NormalizeProjecttrims surrounding whitespace. It's applied on every write path: the CLI-pflag,prog project,CreateItem,SetProject, andEnsureProject.items,learnings,labels, andconcepts, and merges paddedprojectsrows 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.go test ./...andgo vet ./...pass.list -p spindlewent from 5 items to all 13, with a singlespindleproject anduser_version4.🤖 Generated with Claude Code