Extend spool projects <query> resolution to match project display paths and session cwd#411
Conversation
3d40cc1 to
704b242
Compare
704b242 to
6664245
Compare
…Group lean
Address review feedback on the path/cwd matching change:
- project_groups_v stays the single definition of cross-source project
grouping. Instead of freezing it at its v6 migration-time definition
(and duplicating the SQL inline in groups.ts), the view is dropped and
recreated at the end of runMigrations on every launch, now including
the JSON_GROUP_ARRAY path/cwd aggregates. Old and new installs always
run the same definition, and listProjectGroups reads the view again.
- ProjectGroup goes back to its previous shape; the new displayPaths and
cwds fields move to ProjectGroupWithPaths, returned only by
listProjectGroups(db, { withPaths: true }). The app's four renderer
surfaces fetch groups over IPC on every sidebar refresh and never use
the paths, so the payload stays as it was; only the CLI query resolver
opts in.
- Add a regression test pinning the intentional resolution change: an
exact project-path basename now preempts what used to be a unique
display-name substring match.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks @AmagiDDmxh — the core of this PR is solid. The I've pushed a follow-up commit (721f392) directly to this branch addressing three review points, so you can see the reasoning in code rather than a back-and-forth:
Verification: With that, this looks good to merge from my side. |
Summary
spool projects <query>resolution to match project display paths and sessioncwdvalues in addition to display name and identity key.display_pathandcwdas SQLite JSON arrays instead of comma-delimitedGROUP_CONCATstrings.Notes
The
a,bpath was also valid because SQLiteGROUP_CONCATuses comma as its default delimiter, so a valid path like/Users/me/foo,barwould be split into/Users/me/fooandbar. The implementation now usesJSON_GROUP_ARRAY(DISTINCT ...) FILTER (...), then parses the JSON array in TypeScript, so commas and other normal path characters stay intact.JSON.parseshould not fail for values produced by SQLiteJSON_GROUP_ARRAY; it would only fail if the SQL expression stopped returning JSON or the DB engine lacked JSON aggregate support. The current migration/test path already exercises the function throughbetter-sqlite3.Verification
pnpm --filter @spool-lab/core exec vitest run src/projects/groups.test.tspnpm --filter @spool-lab/core run buildpnpm --filter @spool-lab/core testpnpm --filter @spool-lab/cli test