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 (codex): repair bot branches in a throwaway worktree, and give GitLab its own commands

[._.]/ Adam Eivya127b2950295
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 33e0f0ba0f..686121b24d 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -60,7 +60,7 @@
## Chief of Staff
- **"Try again shortly" no longer hides a forge CLI that will never work again on its own.** Running a perpetual task like claim-issue when its `gh` probe fails always toasted "couldn't complete the check just now (a transient forge/network issue) — try again shortly", which is only true for a momentary blip. A `gh` that isn't installed, isn't authenticated, or is blocked outbound by a local firewall fails identically on every future tick, so the advice sent you in a loop with nothing naming the actual fault — the firewall case is the worst of the three, since a denied `connect()` surfaces as "bad file descriptor" and reads like a local bug rather than a network block. The work detector already knew which CLI it ran and how the call failed, but a transient skip deliberately doesn't park, so that verdict had nowhere to go and was dropped at a debug log. It now travels the same route the park reason already does, and when the failing CLI is `gh` the toast reports its health with the remedy ("allow the gh binary to reach api.github.com", "run `gh auth login`", "install the GitHub CLI"). Attribution comes from the CLI that actually failed rather than the task-type name — `claim-work` picks its forge internally, and branch-reconcile and quota-burn go transient over git and provider faults with no forge involved, so a name-based guess would have told a GitLab or Ollama user to install the GitHub CLI. A blip where `gh` itself is fine still gets the original wording.
-- **The weekly dependency-updates task now clears out open Dependabot PRs before bumping anything itself.** The prompt went straight to `npm audit` / `npm outdated`, so on a repo where Dependabot had already opened five PRs the agent re-did that work by hand — duplicate bumps that conflicted with the bot branches, and a growing pile of stale bot PRs nobody ever closed or merged. It now runs a triage phase first: list the automated PRs (Dependabot or Renovate, GitHub or GitLab), gather the evidence for each one — version jump, release notes checked against what this repo actually calls, CI logs for a failure, whether the diff is manifest-and-lockfile-only — and take a single verdict. A clean patch/minor gets merged; a stuck-but-wanted PR gets fixed (ask the bot to rebase a conflict, or push the smallest adapting change for a genuine breakage) and then merged; a superseded one is closed with a reason; a major that needs a real migration is left open with a comment and recorded in the repo's tracker. Only then does it look for updates the bots missed, skipping any package whose bump a bot PR already owns. Existing installs on the previous default upgrade automatically.
+- **The weekly dependency-updates task now clears out open Dependabot PRs before bumping anything itself.** The prompt went straight to `npm audit` / `npm outdated`, so on a repo where Dependabot had already opened five PRs the agent re-did that work by hand — duplicate bumps that conflicted with the bot branches, and a growing pile of stale bot PRs nobody ever closed or merged. It now runs a triage phase first: list the automated PRs (Dependabot or Renovate, GitHub or GitLab), gather the evidence for each one — version jump, release notes checked against what this repo actually calls, CI logs for a failure, whether the diff is manifest-and-lockfile-only — and take a single verdict. A clean patch/minor gets merged; a stuck-but-wanted PR gets fixed (ask the bot to rebase a conflict, or push the smallest adapting change for a genuine breakage) and then merged; a superseded one is closed with a reason; a major that needs a real migration is left open with a comment and recorded in the repo's tracker. Repairs happen in a throwaway worktree rather than by checking the bot branch out in the app's live tree — this task runs in the working copy you use, so a checkout there would hijack whatever branch you were on — and a rebased bot branch is pushed with a lease instead of being unpushable. GitLab repos get `glab` commands throughout instead of `gh` ones aimed at whatever GitHub repo happened to be configured. Only then does it look for updates the bots missed, skipping any package whose bump a bot PR already owns. Existing installs on the previous default upgrade automatically.
- **Run-history row actions and screenshot-remove buttons are now visible when you tab to them.** The view-logs, resume and delete buttons on a run-history row — and the remove-screenshot buttons on the task form and the resume-agent dialog — were revealed only on mouse hover. On a tablet, which has no hover state, they were undiscoverable; for anyone navigating by keyboard they could be focused but never seen, so you could tab onto a delete button with nothing on screen telling you so. They now appear on keyboard focus as well as hover.
diff --git a/server/services/taskPromptDefaults.test.js b/server/services/taskPromptDefaults.test.js
index 5e6e040efd..af24b354dc 100644
--- a/server/services/taskPromptDefaults.test.js
+++ b/server/services/taskPromptDefaults.test.js
@@ -125,6 +125,13 @@ describe('taskPromptDefaults integrity snapshot', () => {
expect(current).toContain('FIX-THEN-MERGE');
// Phase 2 must not re-bump a package a bot PR already owns.
expect(current).toContain('that PR owns the bump');
+ // The task runs in the app's LIVE checkout (no useWorktree default), so repairing a
+ // bot branch has to happen in a throwaway worktree — a bare `gh pr checkout` there
+ // hijacks whatever branch the user is on.
+ expect(current).toContain('{worktreesRoot}/dep-pr-<n>');
+ expect(current).toContain('THROWAWAY WORKTREE');
+ // Rebasing the bot branch rewrites its commits, so the push needs a lease, not a ban.
+ expect(current).toContain('--force-with-lease');
expect(PROMPT_VERSIONS['dependency-updates']).toBe(3);
const previous = PREVIOUS_DEFAULT_PROMPTS['dependency-updates'];
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index e6bc8bf162..e459edde73 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -6,7 +6,7 @@
"performance": "672bd3958b12afb0f382bcebb6dc3b33",
"accessibility": "372916803f32b82da38a5b2130a54baf",
"console-errors": "2b6ed595287f0742bed9ecba6788afe6",
- "dependency-updates": "326988a4fb0ea3fa8391717a0176c049",
+ "dependency-updates": "1ade18016f71bbe2291c8a3ef70a6a84",
"documentation": "74aa8433896647e7815f9d6d9e4a56c8",
"ui-bugs": "def9ad96bd74ab397233f234d79a1974",
"mobile-responsive": "16d8e7f63a673a2de48994c0ac08ef3d",
diff --git a/server/services/taskPromptDefaults/prompts.js b/server/services/taskPromptDefaults/prompts.js
index a23ac08c78..492b246bf6 100644
--- a/server/services/taskPromptDefaults/prompts.js
+++ b/server/services/taskPromptDefaults/prompts.js
@@ -157,7 +157,12 @@ branch and leaves a stale PR behind. Finish Phase 1 before you touch a manifest.
## Phase 1 — Land or resolve open automated dependency PRs
-1. List the open PRs. If the repo has no GitHub/GitLab remote, or \`gh\`/\`glab\` is
+This phase talks to the repo's forge. Use \`gh\` on GitHub and \`glab\` on GitLab —
+the command pairs are given below, and every \`gh pr <verb> <n>\` has a \`glab mr <verb> <n>\`
+equivalent. Run the right one for this repo's origin; never run \`gh\` against a GitLab
+repo (a globally-configured \`gh\` will silently target an unrelated GitHub repository).
+
+1. List the open PRs. If the repo has no GitHub/GitLab remote, or the matching CLI is
unavailable or unauthenticated, say so and skip straight to Phase 2:
\`gh pr list --state open --limit 50 --json number,title,headRefName,author,mergeable,mergeStateStatus\`
(GitLab: \`glab mr list --state opened\`.)
@@ -165,16 +170,17 @@ branch and leaves a stale PR behind. Finish Phase 1 before you touch a manifest.
\`renovate[bot]\`, or whose head branch starts with \`dependabot/\` or \`renovate/\`.
2. For EACH one, gather evidence before deciding:
- - The version jump: patch, minor, or major (\`gh pr view <n>\`)
+ - The version jump: patch, minor, or major (\`gh pr view <n>\` / \`glab mr view <n>\`)
- For a major (or a minor from a package that breaks on minors): read the release
notes in the PR body, then grep this codebase for the APIs that changed. A breaking
change the repo never calls is not a blocker.
- - CI status: \`gh pr checks <n>\`. For a failure, read the actual log
- (\`gh run view <run-id> --log-failed\`) and identify the root cause — a real
- incompatibility, a flaky test, or an unrelated pre-existing failure on the
- default branch (check that before blaming the bump).
- - Mergeability: \`CONFLICTING\` almost always means lockfile/manifest drift from
- another dependency PR that already merged.
+ - CI status: \`gh pr checks <n>\` (GitLab: \`glab ci status --branch <headRefName>\`).
+ For a failure, read the actual log (\`gh run view <run-id> --log-failed\` /
+ \`glab ci trace <job-id>\`) and identify the root cause — a real incompatibility, a
+ flaky test, or an unrelated pre-existing failure on the default branch (check that
+ before blaming the bump).
+ - Mergeability: \`CONFLICTING\` (GitLab: \`cannot_be_merged\`) almost always means
+ lockfile/manifest drift from another dependency PR that already merged.
- Diff sanity: the diff should be manifest + lockfile only. Source-file edits, a new
postinstall/prepare script, or a changed registry URL in a bot PR is a red flag —
do not merge it; comment what you found and leave it open.
@@ -182,17 +188,31 @@ branch and leaves a stale PR behind. Finish Phase 1 before you touch a manifest.
3. Then take exactly ONE verdict per PR:
- MERGE — patch/minor, CI green, not conflicting, diff is clean, nothing in the
release notes affects how this repo uses the package. Merge it, matching the repo's
- documented merge method (\`gh pr merge <n> --merge\` unless the repo says otherwise).
+ documented merge method (\`gh pr merge <n> --merge\` / \`glab mr merge <n> --yes\`
+ unless the repo says otherwise).
- FIX-THEN-MERGE — the bump is wanted but the PR is stuck. Fix it:
* Conflicts only: ask the bot to redo it first — comment \`@dependabot rebase\`
(Renovate: tick the PR's rebase checkbox), move on, and re-check at the end of
- the phase. If the bot doesn't respond, resolve it yourself: \`gh pr checkout <n>\`,
- rebase onto the default branch, regenerate the lockfile with the package manager
- (\`npm install\` — never hand-edit a lockfile), run the tests, push.
+ the phase. If the bot doesn't respond, resolve it yourself.
* Build/test failure caused by the new version (renamed export, changed default,
dropped Node/engine support): make the SMALLEST adapting code change on the PR
- branch, run the tests, push. Keep it scoped to the breakage — never bundle
- unrelated work onto a bot branch, and never force-push over the bot's history.
+ branch. Keep it scoped to the breakage — never bundle unrelated work onto a
+ bot branch.
+ * Either way, work on the bot branch in a THROWAWAY WORKTREE, never by checking
+ it out in {repoPath} — this task usually runs in the app's live checkout, so a
+ \`gh pr checkout\` there hijacks whatever branch the user is on and fails outright
+ on their uncommitted work:
+ \`git -C {repoPath} fetch origin <headRefName>\`
+ \`git -C {repoPath} worktree add {worktreesRoot}/dep-pr-<n> <headRefName>\`
+ Do the work in \`{worktreesRoot}/dep-pr-<n>\`: rebase onto the default branch if
+ it was conflicting, regenerate the lockfile with the package manager
+ (\`npm install\` — never hand-edit a lockfile), run the tests, push. Remove the
+ worktree when you're done with that PR
+ (\`git -C {repoPath} worktree remove {worktreesRoot}/dep-pr-<n>\`).
+ * Pushing a rebase rewrites the bot's commits, so a plain push is rejected — use
+ \`git push --force-with-lease\` (which refuses if the bot pushed again while you
+ worked, so you never clobber a newer version of its branch). Never a bare
+ \`--force\`. A push you did NOT rebase needs no force at all.
* Merge once it is green.
- CLOSE — the PR is superseded (a newer bot PR bumps the same package further) or
targets a dependency this repo no longer uses. Close it with a comment saying why.