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

open1
main
GitHub fork: fix/scheduled-non-git-workspaces
opened1d agobySsaphid
View on GitHubTwo-way sync enabledPR last imported 1d ago

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; explicitly unbinding 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. That PR remains open with conflicts against current main, and its contributor branch is not writable from this account. This continuation targets current main; it does not close the original PR.

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 and the preparation-status reporting in #19774 remain separate.

Verification

  • 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:
text
1plain folder, run 1: strategy=root; startedAt set; completed; worktreePath=null
2plain folder, run 2: same thread; startedAt set; completed; worktreePath=null
3Git repository: strategy=worktree, origin/main, startFromOrigin=true;
4 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.

Checks

20 successful · 11 skipped
All checks passed
1c93eda
Synced from GitHub

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.

Synced from GitHub

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.

Added 1 commit

  • fix(server): run non-Git scheduled tasks in the project folder1c93eda
Synced from GitHub

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

External image Run configuration

External image Commits

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

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

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: External image Minimal · previous review 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.
Description checkPassedThe description covers the problem, change, scope and approval rationale, and detailed verification. It meets the template’s main requirements.
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.
Finishing Touches

Generate unit tests (beta)

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

External image Run configuration

External image Commits

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

External image 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.