fix(worker): prefix broadcast lines with [stdout] so UI parser routes them
This commit is contained in:
@@ -82,13 +82,7 @@ public sealed class TaskRunner
|
|||||||
Directory.CreateDirectory(runDir);
|
Directory.CreateDirectory(runDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve config: task overrides > list config > null.
|
var resolvedConfig = await ResolveConfigAsync(task, listConfig, null, ct);
|
||||||
var resolvedConfig = new ClaudeRunConfig(
|
|
||||||
Model: task.Model ?? listConfig?.Model ?? "claude-sonnet-4-6",
|
|
||||||
SystemPrompt: task.SystemPrompt ?? listConfig?.SystemPrompt,
|
|
||||||
AgentPath: task.AgentPath ?? listConfig?.AgentPath,
|
|
||||||
ResumeSessionId: null
|
|
||||||
);
|
|
||||||
|
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
using (var context = _dbFactory.CreateDbContext())
|
using (var context = _dbFactory.CreateDbContext())
|
||||||
@@ -186,12 +180,7 @@ public sealed class TaskRunner
|
|||||||
worktree = await wtRepo.GetByTaskIdAsync(taskId, ct);
|
worktree = await wtRepo.GetByTaskIdAsync(taskId, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
var resolvedConfig = new ClaudeRunConfig(
|
var resolvedConfig = await ResolveConfigAsync(task, listConfig, lastRun.SessionId, ct);
|
||||||
Model: task.Model ?? listConfig?.Model,
|
|
||||||
SystemPrompt: task.SystemPrompt ?? listConfig?.SystemPrompt,
|
|
||||||
AgentPath: task.AgentPath ?? listConfig?.AgentPath,
|
|
||||||
ResumeSessionId: lastRun.SessionId
|
|
||||||
);
|
|
||||||
|
|
||||||
// Determine run directory from existing worktree or sandbox.
|
// Determine run directory from existing worktree or sandbox.
|
||||||
string runDir;
|
string runDir;
|
||||||
@@ -268,7 +257,7 @@ public sealed class TaskRunner
|
|||||||
async line =>
|
async line =>
|
||||||
{
|
{
|
||||||
await logWriter.WriteLineAsync(line, ct);
|
await logWriter.WriteLineAsync(line, ct);
|
||||||
await _broadcaster.TaskMessage(taskId, line);
|
await _broadcaster.TaskMessage(taskId, "[stdout] " + line);
|
||||||
},
|
},
|
||||||
ct);
|
ct);
|
||||||
|
|
||||||
@@ -372,4 +361,35 @@ public sealed class TaskRunner
|
|||||||
_logger.LogError(ex, "Failed to mark task {TaskId} as failed", taskId);
|
_logger.LogError(ex, "Failed to mark task {TaskId} as failed", taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<ClaudeRunConfig> ResolveConfigAsync(
|
||||||
|
TaskEntity task, ListConfigEntity? listConfig, string? resumeSessionId, CancellationToken ct)
|
||||||
|
{
|
||||||
|
AppSettingsEntity global;
|
||||||
|
using (var ctx = _dbFactory.CreateDbContext())
|
||||||
|
{
|
||||||
|
var settingsRepo = new AppSettingsRepository(ctx);
|
||||||
|
global = await settingsRepo.GetAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
var instructions = MergeInstructions(
|
||||||
|
global.DefaultClaudeInstructions, listConfig?.SystemPrompt, task.SystemPrompt);
|
||||||
|
|
||||||
|
return new ClaudeRunConfig(
|
||||||
|
Model: task.Model ?? listConfig?.Model ?? global.DefaultModel,
|
||||||
|
SystemPrompt: string.IsNullOrWhiteSpace(instructions) ? null : instructions,
|
||||||
|
AgentPath: task.AgentPath ?? listConfig?.AgentPath,
|
||||||
|
ResumeSessionId: resumeSessionId,
|
||||||
|
MaxTurns: global.DefaultMaxTurns,
|
||||||
|
PermissionMode: global.DefaultPermissionMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string MergeInstructions(string? global, string? list, string? task)
|
||||||
|
{
|
||||||
|
var parts = new List<string>(3);
|
||||||
|
if (!string.IsNullOrWhiteSpace(global)) parts.Add(global.Trim());
|
||||||
|
if (!string.IsNullOrWhiteSpace(list)) parts.Add(list.Trim());
|
||||||
|
if (!string.IsNullOrWhiteSpace(task)) parts.Add(task.Trim());
|
||||||
|
return string.Join("\n\n", parts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user