Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review: include linkToPipeline in rollback + preserve chosen model

[._.]/ Adam Eivy6f095635079a
diff --git a/server/services/taskEnhancer.js b/server/services/taskEnhancer.js
index 6fb059e36d..ee5af41309 100644
--- a/server/services/taskEnhancer.js
+++ b/server/services/taskEnhancer.js
@@ -107,7 +107,11 @@ export async function enhanceTaskPrompt(description, context = '') {
const { text, model: effectiveModel } = await runPromptThroughProvider({
provider, prompt: fullPrompt, source: 'task-enhancement', model,
});
- model = effectiveModel;
+ // Keep the caller's chosen model (or provider default) when the runner
+ // resolves to a null effectiveModel — overwriting unconditionally would
+ // report `model: null` in logs + return values even though we explicitly
+ // chose one upstream.
+ model = effectiveModel || model || provider.defaultModel || null;
// Clean up the response - remove any leading/trailing whitespace and common prefixes
let enhancedDescription = text.trim();
diff --git a/server/services/writersRoom/promoteToPipeline.js b/server/services/writersRoom/promoteToPipeline.js
index 61067cd899..d09d7936c5 100644
--- a/server/services/writersRoom/promoteToPipeline.js
+++ b/server/services/writersRoom/promoteToPipeline.js
@@ -112,12 +112,16 @@ export async function promoteWorkToPipeline(workId, { force = false } = {}) {
objects,
});
- // Roll back the universe + (partial) series if any downstream write fails —
- // otherwise a series/issue validation error would leave an orphan universe
- // record with no series linked and the manifest still unlinked, with no
- // path back to it from the writers-room UI. Try/catch is appropriate here
- // (multi-step write that needs atomic-ish rollback, not error swallowing —
- // we re-throw after cleanup so the caller still sees the original error).
+ // Roll back the universe + (partial) series + issue if ANY downstream
+ // write fails — otherwise a series/issue/link error would leave an orphan
+ // record set with the manifest still unlinked, and the next promote
+ // (which only consults manifest ids for the idempotent fast-path) would
+ // create duplicates with no path back to the originals. Try/catch is
+ // appropriate here (multi-step write that needs atomic-ish rollback, not
+ // error swallowing — we re-throw after cleanup so the caller still sees
+ // the original error). linkToPipeline is INSIDE the try block because
+ // its failure leaves exactly the same orphan state as a createIssue
+ // failure: a universe + series + issue with no manifest link.
let series = null;
let issue = null;
try {
@@ -144,16 +148,19 @@ export async function promoteWorkToPipeline(workId, { force = false } = {}) {
: { status: 'empty' },
},
});
+
+ await wrLocal.linkToPipeline(workId, { seriesId: series.id, issueId: issue.id });
} catch (err) {
// Best-effort cleanup; swallow cleanup errors so the original cause
// (validation failure, etc.) reaches the caller instead of a misleading
- // delete-failed message.
+ // delete-failed message. Cleanup in reverse dependency order: issue
+ // first (depends on series), then series (depends on universe), then
+ // universe.
+ if (issue) await issuesSvc.deleteIssue(issue.id).catch(() => {});
if (series) await seriesSvc.deleteSeries(series.id).catch(() => {});
await deleteUniverse(universe.id).catch(() => {});
throw err;
}
- await wrLocal.linkToPipeline(workId, { seriesId: series.id, issueId: issue.id });
-
return { series, issue, reused: false };
}