feat(v0.5.3): shared workspace-entry helper; resume + last delegate; fresh_remote prompt

This commit is contained in:
2026-05-08 13:59:53 -04:00
parent 08fb5bb1c3
commit f5746df314
8 changed files with 447 additions and 25 deletions
+20 -20
View File
@@ -8,7 +8,6 @@ import (
"github.com/spf13/cobra"
"github.com/warrenronsiek/ctask/internal/config"
"github.com/warrenronsiek/ctask/internal/session"
"github.com/warrenronsiek/ctask/internal/shell"
"github.com/warrenronsiek/ctask/internal/workspace"
)
@@ -26,6 +25,7 @@ var (
resumeShell bool
resumeAgent string
resumeForce bool
resumeDirect bool
)
func init() {
@@ -33,26 +33,28 @@ func init() {
resumeCmd.Flags().BoolVar(&resumeShell, "shell", false, "Open shell instead of agent")
resumeCmd.Flags().StringVarP(&resumeAgent, "agent", "a", "", "Override agent command")
resumeCmd.Flags().BoolVar(&resumeForce, "force", false, "Skip active-session and stale-workspace warnings")
resumeCmd.Flags().BoolVar(&resumeDirect, "direct", false, "Bypass persistent session mode for this command")
resumeCmd.ValidArgsFunction = completeWorkspaces(completionActive)
rootCmd.AddCommand(resumeCmd)
}
func runResume(cmd *cobra.Command, args []string) error {
return doResume(args[0], resumeContainer, resumeShell, resumeForce, resumeAgent)
return doResume(args[0], resumeContainer, resumeShell, resumeForce, resumeAgent, resumeDirect)
}
// doResume is the shared resume logic used by both resume and last commands.
func doResume(query string, container, useShell, force bool, agentOverride string) error {
// doResume is the shared resume logic used by both `resume` and `last`.
// It preserves resume's existing archive-inclusive resolution and
// restore-hint behavior, then delegates to runWorkspaceEntry for the
// persistent-vs-direct decision and tmux dispatch.
func doResume(query string, container, useShell, force bool, agentOverride string, directFlag bool) error {
if container {
fmt.Println(shell.ContainerNotice())
return nil
}
roots := config.SearchRoots()
// v0.5.2: resolve archived-inclusive so we can give a helpful hint when
// the user resumes an archived workspace. resolveOne still handles
// not-found and ambiguity exactly as before — this only changes which
// workspaces are reachable, not how lookup failures are reported.
// resume resolves archived-inclusive so we can give a helpful hint when
// the user resumes an archived workspace (v0.5.2 behavior — preserved).
ws := resolveOne(roots, query, true)
if ws.Meta.Status == "archived" {
@@ -62,7 +64,7 @@ func doResume(query string, container, useShell, force bool, agentOverride strin
return fmt.Errorf("workspace archived")
}
// Update updated_at
// updated_at bump (existing v0.4 behavior).
now := time.Now().UTC().Truncate(time.Second)
ws.Meta.UpdatedAt = now
metaPath := filepath.Join(ws.Path, "task.yaml")
@@ -75,16 +77,14 @@ func doResume(query string, container, useShell, force bool, agentOverride strin
agent = ws.Meta.Agent
}
envVars := config.EnvVars(ws.Meta.Slug, ws.Meta.Mode, ws.Root, ws.Path, ws.Meta.Category, workspace.EffectiveType(ws.Meta), ws.Meta.LaunchDir)
return session.Run(session.LaunchOpts{
WsDir: ws.Path,
EnvVars: envVars,
Agent: agent,
Mode: ws.Meta.Mode,
Slug: ws.Meta.Slug,
Shell: useShell,
LaunchDir: ws.Meta.LaunchDir,
Force: force,
return runWorkspaceEntry(WorkspaceEntryOptions{
WsPath: ws.Path,
WsRoot: ws.Root,
WsMeta: ws.Meta,
Agent: agent,
Shell: useShell,
Force: force,
Direct: directFlag,
CommandName: "resume",
})
}