diff --git a/cmd/delete.go b/cmd/delete.go index 28f561d..3e0d727 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -70,20 +70,9 @@ 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. - // Spans both tasks and projects via Type=TypeAny. - results, _ := workspace.ListWorkspaces(root, workspace.ListOpts{ - IncludeArchived: false, - Limit: 0, - Type: workspace.TypeAny, - }) - if len(results) > 0 { - best := results[0] - for _, r := range results[1:] { - if r.Meta.UpdatedAt.After(best.Meta.UpdatedAt) { - best = r - } - } + // Check if this is the most recently updated workspace across both + // tasks and projects. + if best, _ := workspace.MostRecentActive(root); best != nil { absBest, _ := filepath.Abs(best.Path) if strings.EqualFold(absTarget, absBest) { fmt.Println() diff --git a/cmd/last.go b/cmd/last.go index 096d742..e1a0bbc 100644 --- a/cmd/last.go +++ b/cmd/last.go @@ -11,7 +11,7 @@ import ( var lastCmd = &cobra.Command{ Use: "last", - Short: "Resume the most recently updated workspace", + Short: "Resume the most recently updated workspace (task or project)", Args: cobra.NoArgs, SilenceUsage: true, RunE: runLast, @@ -31,30 +31,14 @@ func init() { func runLast(cmd *cobra.Command, args []string) error { root := config.ResolveRoot() - // Scan all non-archived workspaces (tasks AND projects) and find the most - // recently updated. - results, err := workspace.ListWorkspaces(root, workspace.ListOpts{ - IncludeArchived: false, - Limit: 0, - Type: workspace.TypeAny, - }) + best, err := workspace.MostRecentActive(root) if err != nil { return err } - - if len(results) == 0 { + if best == nil { fmt.Fprintln(os.Stderr, "No active workspaces found.") os.Exit(1) } - // Find the one with the most recent updated_at - best := results[0] - for _, r := range results[1:] { - if r.Meta.UpdatedAt.After(best.Meta.UpdatedAt) { - best = r - } - } - - // Delegate to resume logic using the slug return doResume(best.Meta.Slug, false, lastShell, lastAgent) }