polish(v0.5.4): suppress Cobra duplicate Error on archived resume

ctask resume <archived-workspace> printed both the helpful [ctask]
diagnostic + restore hint AND a redundant trailing "Error: workspace
archived" line from Cobra's default error rendering. Cosmetic but
unprofessional.

Add an errArchivedWorkspace sentinel and have runResume flip
SilenceErrors only when the inner error is that sentinel. All other
resume errors (lookup failure, metadata write failure, etc.) continue
to flow through Cobra's default rendering unchanged — we only silence
the case where we have already printed an equivalent diagnostic
ourselves.

Verified end-to-end through Cobra Execute (not just runResume direct
invocation) so the SilenceErrors-flip-from-RunE timing is exercised.
This commit is contained in:
2026-05-14 20:01:19 -04:00
parent 4fd0befee1
commit ae9bfafb1f
2 changed files with 133 additions and 2 deletions
+16 -2
View File
@@ -1,6 +1,7 @@
package cmd
import (
"errors"
"fmt"
"os"
"path/filepath"
@@ -38,8 +39,21 @@ func init() {
rootCmd.AddCommand(resumeCmd)
}
// errArchivedWorkspace is the sentinel doResume returns when the user
// asks to resume an archived workspace. doResume already prints the
// full [ctask] diagnostic + restore hint to stderr, so the cmd-layer
// wrapper flips SilenceErrors to suppress Cobra's redundant trailing
// "Error: workspace archived" line. All other errors (lookup failure,
// metadata write failure, etc.) flow through Cobra's default
// rendering unchanged.
var errArchivedWorkspace = errors.New("workspace archived")
func runResume(cmd *cobra.Command, args []string) error {
return doResume(args[0], resumeContainer, resumeShell, resumeForce, resumeAgent, resumeDirect)
err := doResume(args[0], resumeContainer, resumeShell, resumeForce, resumeAgent, resumeDirect)
if errors.Is(err, errArchivedWorkspace) {
cmd.SilenceErrors = true
}
return err
}
// doResume is the shared resume logic used by both `resume` and `last`.
@@ -59,7 +73,7 @@ func doResume(query string, container, useShell, force bool, agentOverride strin
if ws.Meta.Status == "archived" {
fmt.Fprint(os.Stderr, formatResumeRestoreHint(query))
return fmt.Errorf("workspace archived")
return errArchivedWorkspace
}
// updated_at bump (existing v0.4 behavior).