Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): run non-Git scheduled tasks in the project folder #33594

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/33594/headopened View on GitHub

saphid(GitHub profile, opens in a new tab)commented

Problem

An agent-created schedule that starts without a bound thread always requests a Git worktree. In a project folder that is not a Git repository, every run fails during workspace preparation before the provider starts.

Change

Use the existing Git driver to probe the project folder. Choose the project root only when Git confirms not_a_repository; Git projects and unrelated Git errors retain the existing worktree strategy. The same helper handles task creation and explicit unbinding.

Existing saved tasks are not migrated. An ordinary edit preserves their strategy; a bound-to-unbound transition recalculates it. Queue holds after failed preparation and reporting launch acceptance as schedule success are separate behavior; this change leaves them alone.

Scope and approval

This is a small, focused fix of the obvious non-Git workspace failure, continued from #18583. A maintainer has since closed that predecessor in favour of this continuation. The published branch now conflicts with main; the refreshed merge described below remains unpublished.

Credit to Laurenz Seifried for the original diagnosis and implementation, Julius Marminge for the narrower Git-error handling, and Maria for the earlier conflict-resolution work. The commit retains the original author's credit and relevant coauthor trailers.

The broader default-workspace request in #32491 is now closed. #32494 preserves saved workspaces when the binding does not change; the refreshed candidate keeps that behavior. Preparation-status reporting in #19774 remains separate.

Human approval for this change to the default execution location remains pending; the code reviews below do not satisfy that policy gate.

Unpublished maintenance candidate

Publication is on hold while maintainer #34995 addresses the same ordinary non-Git scheduling failure. No branch update, closure or merge has been published by this maintenance pass.

Main at b68aedf is merged locally into published 1c93eda, staged as tree 4252aad. One conflict comment was resolved and the unbinding fixture now starts from a bound task, preserving the unchanged-binding rule from main. Supplied Boat checks on this candidate pass: 72 service tests, server typecheck, and check:changed (80 tests, three typechecked packages). Full local/Boat tree and changed-file hashes match. Fresh independent GPT-6.1 Sol/high review through Codex/T3 completed with no actionable findings (task 40e017de-11cb-43be-8faf-4263f72faa8a); the reviewer ran no repository tests. These results do not cover the published head or constitute candidate CI.

The candidate forces LC_ALL=C for its repository probe. The overlapping remote-resolution path inherits locale, while Git failure classification recognizes English diagnostics; translated non-repository diagnostics may therefore fall through to worktree selection there. This distinction was traced in source, not reproduced end to end on a translated Git installation. Stable diagnostics should be retained in whichever implementation is selected.

Verification on the published pre-merge revision

  • Added the regression first on unchanged main: the confirmed non-repository case failed because creation and explicit unbinding both saved worktree instead of root. The unclassified Git-error case retained worktree as expected.
  • Five focused MCP suites: 91 tests passed.
  • vp run check:changed: all stages passed, including format, lint, both knip passes, generated GraphQL checks, affected-package typechecks, and 69 tests.
  • Through an isolated running server's HTTP MCP schedule_task, created disabled schedules for a plain folder and a Git fixture with a local origin. Invoked them through scheduledTasks.runNow and awaited actual completion through MCP t3_thread_wait, using the free Replay provider. Read-only persistence checks confirmed:
plain folder, run 1: strategy=root; startedAt set; completed; worktreePath=null
plain folder, run 2: same thread; startedAt set; completed; worktreePath=null
Git repository: strategy=worktree, origin/main, startFromOrigin=true;
                startedAt set; completed; own worktree and branch

Fixture schedules were deleted, temporary credentials revoked, and the isolated server stopped. No live userdata writes or paid provider turns. This server-only change has no visible surface for screenshots; the regression and runtime transcript are its proof. Native Windows/Linux Git execution was not exercised.

Independent review through T3 delegate_task completed on Claude Opus 5.5 (claudeAgent, high): APPROVE, no actionable findings. One optional comment clarification was applied afterward.

Ported and verified with GPT-6.1 Sol in the Codex harness through T3 Code; independent review by Claude Opus 5.5 in the Claude Code harness through T3. Original contribution credited above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — Non-Git scheduled tasks will automatically run in the project folder, while Git projects retain worktree execution. Human review is required for this change to the default execution location, where tasks can directly modify project files.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Note

      🤖 GPT-6.1 Sol responding on behalf of saphid

      The execution-location change is intentional for confirmed non-Git projects: their requested worktree cannot be created, so every scheduled run currently fails before the provider starts. Git projects retain worktree execution, and unrelated Git probe failures retain the existing strategy rather than selecting root. Existing saved tasks are not migrated, and permission modes are unchanged.

      The PR includes the failing-first regression and an isolated runtime transcript showing two completed root runs plus a completed Git worktree run. The human-review flag from .macroscope/approvability.md is acknowledged; this PR will remain open and unmerged for maintainer review.

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Scheduled-task workspace selection now probes for a Git repository. Confirmed non-repositories use a root workspace strategy; repositories continue to use a worktree strategy. Tests cover scheduling and unbinding for these cases and for other Git errors.

      Changes: Scheduled-task workspace selection

      Layer / File(s)Summary
      Workspace strategy and behavior tests
      apps/server/src/mcp/OrchestratorMcpService.ts, apps/server/src/mcp/OrchestratorMcpService.test.ts
      The service probes the project workspace with git rev-parse --git-dir. It uses a root strategy when Git reports not_a_repository, preserves other Git errors, and continues to select a worktree strategy for repositories. Tests cover scheduling and unbinding outcomes. The update comment describes unbound tasks in Git projects as using a worktree.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Possibly related issues

      • pingdotgg/t3code#16183: This change selects the project root for non-Git projects, addressing the reported workspace preparation failure. It does not address the issue’s separate Git-project default-branch failure.
      • pingdotgg/t3code#32491: This change selects the project root for non-Git projects. It does not make Git-project tasks follow the configured default or preserve a manually selected strategy on unbinding.

      Possibly related PRs

      • pingdotgg/t3code#22801: Both PRs change workspace strategy selection for scheduled tasks when created or explicitly unbound.

      Suggested labels: bugfix, size:S

      Suggested reviewers: maria-rcks, juliusmarminge, tuanvumaihuynh

      Merge Risk: Minimal · up to ab689

      Plain folders use the project root, while Git projects retain worktree scheduling. No actionable issue remains before merge.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title clearly summarizes the main change: non-Git scheduled tasks run in the project folder.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Description checkPassedThe description follows the repository template and covers Problem, Change, Scope, and Verification. It states the bug, the Git-probe fix, and the tests run, with runtime checks on a plain folder and …
      Full details: Description check

      Explanation

      The description follows the repository template and covers Problem, Change, Scope, and Verification. It states the bug, the Git-probe fix, and the tests run, with runtime checks on a plain folder and a Git repository. It is long and includes unpublished-candidate and maintenance-pass material that does not belong in the PR description, and it does not state the reproduction environment as a concise list. It also contains a conventional-commit title check issue: the title is not in the description, so it cannot be verified here. Overall the core template sections are substantively filled.

      Finishing Touches

      Generate unit tests (beta)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between ff7aa5ace311c70587631dcedb43f1d92068c342 and ab689fb4403deb881161162f518f3d6041bec6af.

      Files selected for processing: 2

      • apps/server/src/mcp/OrchestratorMcpService.test.ts
      • apps/server/src/mcp/OrchestratorMcpService.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    5. tanstack-source added labelsbug

    6. Thanks for this. #34995 makes the same change and is the one being kept.

      #34995 addresses the same non-Git scheduling failure through the existing Git lookup, avoiding an additional repository probe. It also preserves the current rule that an unchanged binding keeps its saved workspace, so it is the smaller implementation to carry forward.

      Your explicit use of stable Git diagnostics remains valuable: the replacement's lookup inherits the server locale and can miss translated non-repository errors. That detail should be carried into the replacement during review.

      Closing as a duplicate.

    7. juliusmarminge closed this

Sign in to join this conversation.