feat(worker): resume a task's claude session in a terminal
This commit is contained in:
@@ -7,6 +7,10 @@ public interface ITerminalLauncher
|
||||
{
|
||||
Task LaunchPlanningStartAsync(PlanningSessionStartContext ctx, CancellationToken cancellationToken);
|
||||
Task LaunchPlanningResumeAsync(PlanningSessionResumeContext ctx, CancellationToken cancellationToken);
|
||||
|
||||
// Resumes an arbitrary task's Claude session (--resume <id>) in a visible terminal so
|
||||
// the user can pick up the conversation by hand — the "pick up in terminal" action.
|
||||
Task LaunchResumeAsync(string workingDir, string claudeSessionId, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public sealed class TerminalLaunchException : Exception
|
||||
|
||||
@@ -88,6 +88,26 @@ public sealed class WindowsTerminalLauncher : ITerminalLauncher
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task LaunchResumeAsync(string workingDir, string claudeSessionId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!Directory.Exists(workingDir))
|
||||
throw new TerminalLaunchException($"Working directory does not exist: {workingDir}");
|
||||
|
||||
var resolvedWt = ResolveWtOrThrow();
|
||||
var resolvedClaude = ResolveClaudeOrThrow();
|
||||
|
||||
var command = BuildResumeCommand(resolvedClaude, claudeSessionId);
|
||||
|
||||
StartInWindowsTerminal(resolvedWt, workingDir, command, static _ => { });
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
// Resumes a session by id in default (interactive) permission mode: the user drives
|
||||
// tool approvals in the terminal, unlike planning which pins --permission-mode plan.
|
||||
internal static string BuildResumeCommand(string claudePath, string claudeSessionId) =>
|
||||
BuildPwshCommand(claudePath, new[] { "--resume", claudeSessionId });
|
||||
|
||||
// Builds the PowerShell command that launches an interactive planning session.
|
||||
// Arg order matters: variadic flags (--allowedTools, --add-dir) come first; the
|
||||
// single-line kickoff prompt is positional, so it must follow a single-value flag
|
||||
|
||||
Reference in New Issue
Block a user