Skip to content

feat(web,mobile): per-project default base branch for new worktrees - #21

Merged
Fryuni merged 1 commit into
mainfrom
t3code/f0d55035
Sep 18, 2026
Merged

Fryuni merged 1 commit into
mainfrom
t3code/f0d55035

Conversation

@Fryuni

@Fryuni Fryuni commented Sep 18, 2026

Copy link
Copy Markdown
Owner

What Changed

Adds a project-only defaultThreadBaseBranch setting that controls the base branch used for automatic new worktree threads.

  • packages/contracts: extends project settings overrides with defaultThreadBaseBranch.
  • Web: new "Default base branch" row in Settings → Project defaults → Source control (project scope only), the branch toolbar's worktree base candidate, and new-thread draft creation now honor the override. Explicit branch choices always win.
  • Mobile: the same field under Settings → Source control → Worktrees when a project is selected, with save/clear preserving sibling project overrides.
  • Both clients retain a configured branch name even when it is missing from the loaded refs list, so creation surfaces the normal git error instead of silently falling back to another branch.
  • docs/user/project-settings.md documents the new setting.

Why

Teams work from different base branches per project (e.g. develop), but new worktree threads always started from the repository's default branch or the current checkout. A per-project override lets each project declare its base once, while keeping the existing git-default → current-checkout fallback when unset.

The setting is project-only by design: it is not an inheritable environment default, and writes merge into the project's existing overrides so sibling keys are never dropped.

UI Changes

  • Web: new "Default base branch" text row with reset button under Source Control project defaults.
  • Mobile: new "Default base branch" input with Save action in the Worktrees section of Source Control settings when a project is selected.

Screenshots/video to be attached.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

- Add defaultThreadBaseBranch project override, editable in source control settings
- Automatic worktree drafts prefer the override, then the repo default, then the current branch
- Mobile settings gains the field and honors it in the new task flow
Copilot AI lite review requested due to automatic review settings September 18, 2026 18:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T18:17:15.019908Z b7c4f41 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7c4f413e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +90 to +93
if (
target.projectId === null ||
target.environment.serverConfig.environment.capabilities.projectSettingsOverrides !== true
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Gate default-branch writes on a versioned capability

When an updated mobile or web client connects to a pre-change server, that server still advertises the generic projectSettingsOverrides capability even though its nested settings schema does not know defaultThreadBaseBranch. These writes therefore appear supported and successful, but the old decoder strips the new field, so the value immediately disappears; mixed-version environments can also save it on only some machines without reporting a partial failure. Add a capability specifically covering this field and hide or disable the control unless every write target advertises it.

AGENTS.md reference: AGENTS.md:L74-L74

Useful? React with 👍 / 👎.

Comment on lines +84 to +86
const defaultThreadBaseBranch = isProjectScope
? (target?.overrides.defaultThreadBaseBranch ?? "")
: "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Represent mixed base-branch overrides in the web control

For a logical project present on multiple connected environments with different overrides, this derives the field solely from the representative target, so the web UI presents one branch as though it applied everywhere. This is especially problematic because DraftInput does not commit an unchanged value: if the representative says dev and another machine says release, entering dev cannot fan that choice out, and if the representative is unset the reset action is also absent. Derive and display a mixed state from all targets, as the adjacent scoped settings do.

AGENTS.md reference: AGENTS.md:L74-L74

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The web settings row mishandles mixed project overrides and remains editable when no connected target can accept the write.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a project-only default base branch for new worktree threads across web and mobile, including persistence, UI, fallback behavior, tests, and documentation.

Changes:

  • Extends project override contracts and preservation logic.
  • Applies the setting to web/mobile worktree draft creation and branch selection.
  • Adds web/mobile settings controls and documentation.
File summaries
File Description
packages/shared/src/projectSettings.ts Supports clearing project-only overrides.
packages/shared/src/projectSettings.test.ts Tests persistence and clearing.
packages/contracts/src/settings.ts Adds the override schema field.
packages/contracts/src/settings.test.ts Tests validation and round-tripping.
docs/user/project-settings.md Documents the setting.
apps/web/src/hooks/useHandleNewThread.ts Applies the branch default to drafts.
apps/web/src/hooks/useHandleNewThread.test.ts Tests default and explicit branch precedence.
apps/web/src/components/settings/useScopedSettings.ts Adds the project branch update hook.
apps/web/src/components/settings/scopedSettings.ts Plans merged project override writes.
apps/web/src/components/settings/scopedSettings.test.ts Tests sibling preservation.
apps/web/src/components/settings/ProjectDefaultsSettings.tsx Adds the web settings row.
apps/web/src/components/BranchToolbarBranchSelector.tsx Uses the project branch candidate.
apps/web/src/components/BranchToolbar.logic.ts Defines branch fallback precedence.
apps/web/src/components/BranchToolbar.logic.test.ts Tests branch precedence and missing refs.
apps/mobile/src/features/threads/new-task-flow-provider.tsx Applies the mobile branch default.
apps/mobile/src/features/threads/new-task-branch-default.ts Resolves configured and fallback branches.
apps/mobile/src/features/threads/new-task-branch-default.test.ts Tests mobile branch resolution.
apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx Adds mobile editing and clearing UI.
apps/mobile/src/features/settings/settings-scoped-server.ts Plans mobile override writes.
apps/mobile/src/features/settings/settings-scoped-server.test.ts Tests mobile preservation and clearing.
Review details

Suppressed comments (1)

apps/web/src/components/settings/ProjectDefaultsSettings.tsx:365

  • When a project is selected but none of its environments is connected, target is null and the planner cannot produce a write, yet this input remains editable because it is not marked unavailable. Blurring it only discards the value after showing a warning, unlike the other server-backed rows; disable the control while unavailable (or route it through the same inert-control handling).
                <DraftInput
                  size="sm"
                  className="w-44 font-mono"
                  aria-label="Default base branch"
                  placeholder="Repository default"
  • Files reviewed: 20/20 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +84 to +86
const defaultThreadBaseBranch = isProjectScope
? (target?.overrides.defaultThreadBaseBranch ?? "")
: "";
@Fryuni
Fryuni merged commit 3e24caf into main Sep 18, 2026
9 checks passed
@Fryuni
Fryuni deleted the t3code/f0d55035 branch September 18, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants