feat(v0.3): add Projects filter to ListWorkspaces; fix last/delete

ListOpts gains a Projects bool that filters by EffectiveType.
Default behavior (Projects: false) now returns tasks only --
this is a deliberate semantic change that supports the new
'ctask list' (tasks) vs 'ctask list --projects' (projects)
spec.

The change silently regresses two cmd-level callers that scan
for "the most recently updated workspace": cmd/last.go (used by
'ctask last') and cmd/delete.go (used to print the "this was
your most recent workspace" note). Both are fixed by unioning a
tasks-scan with a projects-scan, so 'last' and 'delete' continue
to consider both types.

Test helper createTestWorkspaceTyped allows setting an explicit
type (or "" to simulate a v0.2 workspace with no type field).
This commit is contained in:
2026-04-10 14:43:28 -04:00
parent 84ca6a8d1c
commit bfe89d830c
5 changed files with 98 additions and 5 deletions
+9 -2
View File
@@ -70,11 +70,18 @@ func runDelete(cmd *cobra.Command, args []string) error {
fmt.Printf(" Workspace: %s\n", relPath)
fmt.Printf(" Files: %d (%s)\n", fileCount, formatSize(totalSize))
// Check if this is the most recently updated workspace
results, _ := workspace.ListWorkspaces(root, workspace.ListOpts{
// Check if this is the most recently updated workspace.
// v0.3: union tasks and projects so the "most recent" check spans both types.
tasks, _ := workspace.ListWorkspaces(root, workspace.ListOpts{
IncludeArchived: false,
Limit: 0,
})
projects, _ := workspace.ListWorkspaces(root, workspace.ListOpts{
IncludeArchived: false,
Projects: true,
Limit: 0,
})
results := append(tasks, projects...)
if len(results) > 0 {
best := results[0]
for _, r := range results[1:] {