fix: address adversarial review findings for #3576

- Use `git reset --hard <sha>` for rollback instead of `git branch -f`
  which fails on checked-out branches and worktrees
- Clear pendingProviderRegistrations after preflush to prevent duplicate
  registration when bindCore() runs
- Process Ollama stream content on terminal `done:true` chunks to avoid
  truncating trailing assistant text
This commit is contained in:
Jeremy 2026-04-05 15:48:25 -05:00
parent 0d3ef6b545
commit ac20eab501
3 changed files with 7 additions and 18 deletions

View file

@ -221,9 +221,8 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
for (const { name, config } of extensionsForModelResolution.runtime.pendingProviderRegistrations) {
modelRegistry.registerProvider(name, config);
}
// Note: we do NOT clear pendingProviderRegistrations here — bindCore() will iterate
// an empty array harmlessly, and clearing here would require the runtime to track
// whether the flush already happened.
// Clear the queue so bindCore() doesn't re-register the same providers.
extensionsForModelResolution.runtime.pendingProviderRegistrations = [];
// If still no model, use findInitialModel (checks settings default, then provider defaults)
if (!model) {

View file

@ -72,20 +72,10 @@ export function rollbackToCheckpoint(
return false;
}
// Reset working tree
execFileSync("git", ["reset", "--hard"], {
cwd: basePath,
stdio: ["ignore", "pipe", "pipe"],
});
// Move branch pointer back to checkpoint
execFileSync("git", ["branch", "-f", branch, sha], {
cwd: basePath,
stdio: ["ignore", "pipe", "pipe"],
});
// Sync working tree with moved branch
execFileSync("git", ["reset", "--hard"], {
// Reset branch pointer and working tree to checkpoint SHA in one step.
// Using `git reset --hard <sha>` works on the currently checked-out branch
// (unlike `git branch -f` which is rejected for checked-out branches).
execFileSync("git", ["reset", "--hard", sha], {
cwd: basePath,
stdio: ["ignore", "pipe", "pipe"],
});

View file

@ -149,7 +149,7 @@ export function streamOllamaChat(
// Handle text content — process independently of tool_calls
// (a chunk may contain both content and tool_calls)
const content = chunk.message?.content ?? "";
if (content && !chunk.done) {
if (content) {
if (thinkParser) {
processChunks(thinkParser.push(content));
} else {