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
+13 -2
View File
@@ -31,14 +31,25 @@ func init() {
func runLast(cmd *cobra.Command, args []string) error {
root := config.ResolveRoot()
// Scan all non-archived workspaces and find the most recently updated
results, err := workspace.ListWorkspaces(root, workspace.ListOpts{
// Scan all non-archived workspaces (tasks AND projects) and find the most
// recently updated. v0.3: ListWorkspaces filters by type, so we union the
// two type buckets here so `last` keeps working for both.
tasks, err := workspace.ListWorkspaces(root, workspace.ListOpts{
IncludeArchived: false,
Limit: 0,
})
if err != nil {
return err
}
projects, err := workspace.ListWorkspaces(root, workspace.ListOpts{
IncludeArchived: false,
Projects: true,
Limit: 0,
})
if err != nil {
return err
}
results := append(tasks, projects...)
if len(results) == 0 {
fmt.Fprintln(os.Stderr, "No active workspaces found.")