feat(settings): configurable branch prefix for PRs#2865
Open
MattPua wants to merge 6 commits into
Open
Conversation
Add a "Branch prefix" setting (Settings → General → Version control) so the posthog-code/ default can be customized. - New branchPrefix setting (default "posthog-code/"), persisted, with a normalizeBranchPrefix() helper in @posthog/shared - UI branch-name suggestions use the configured prefix - Local agent runs: prefix threaded through sessionService → agent.start / reconnect → workspace-server system prompt + Claude adapter branch-naming - Cloud runs: AgentServerConfig.branchPrefix + --branchPrefix CLI flag; cloud system prompt uses it; desktop sends branch_prefix in the create-run payload - Tests for the normalizer and custom-prefix branch derivation Generated-By: PostHog Code Task-Id: f55fc9d7-90a0-4dd8-adb9-5763d04cea62
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "feat(settings): configurable branch pref..." | Re-trigger Greptile |
Address review feedback on the branch-prefix setting: - Validate the prefix as it is actually used (in front of a slug) with validateBranchName, show an inline error, and never persist a value that would yield an invalid git ref. This guards the agent prompt and git_signed_commit paths, which have no downstream sanitization. - Add maxLength=100 to the input to match the workspace-server schema cap, so a long prefix can no longer break session start/reconnect with a ZodError. Generated-By: PostHog Code Task-Id: f55fc9d7-90a0-4dd8-adb9-5763d04cea62
normalizeBranchPrefix now guarantees exactly one trailing slash so the prefix is always a slash-terminated namespace (e.g. "team" -> "team/"), avoiding a run-together branch name like "teamfix-login-bug". Generated-By: PostHog Code Task-Id: f55fc9d7-90a0-4dd8-adb9-5763d04cea62
100 was an arbitrary guard, not a considered limit. A prefix is just a namespace (a GitHub username maxes at 39 chars, so `username/` fits in 40), while the descriptive slug is capped separately at 60 — so 40 keeps the full ref well under git's ~250-byte limit. Introduce a single MAX_BRANCH_PREFIX_LENGTH constant in @posthog/shared and use it for both the UI input maxLength and the workspace-server start/reconnect schemas, so they can no longer drift apart. Generated-By: PostHog Code Task-Id: f55fc9d7-90a0-4dd8-adb9-5763d04cea62
Replace the slash-trimming regexes (/\/+$/ etc., flagged by CodeQL as a
polynomial regular expression on uncontrolled input) with a linear
split("/")/filter(Boolean)/join — identical behavior, no backtracking.
Generated-By: PostHog Code
Task-Id: f55fc9d7-90a0-4dd8-adb9-5763d04cea62
- setBranchPrefix now normalizes and rejects any prefix that would yield an invalid git ref, so the stored value is always valid regardless of caller (the agent and cloud paths read it verbatim). validateBranchName owns the rules; @posthog/shared's normalizeBranchPrefix stays format-only because shared cannot depend on core. - Commit the prefix on blur instead of via a debounced effect, dropping the useDebounce dependency. The remaining effect only mirrors async persisted-state hydration back into the editable draft. Generated-By: PostHog Code Task-Id: f55fc9d7-90a0-4dd8-adb9-5763d04cea62
Contributor
|
Reviews (2): Last reviewed commit: "fix(settings): enforce valid branch pref..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
posthog-code/can be customized.posthog-code/; the value is normalized (normalizeBranchPrefixin@posthog/shared) and persisted.CleanShot.2026-06-23.at.13.23.21.mp4
What it affects
sessionService→agent.start/reconnect→ workspace-server system prompt + Claude adapter branch-naming guidance.AgentServerConfig.branchPrefix+--branchPrefixCLI flag; cloud system prompt uses it; desktop sendsbranch_prefixin the create-run payload (only when non-default).Notes
branch_prefixand pass it to the sandbox as--branchPrefix. Until then cloud defaults toposthog-code/(no regression — the field is only sent when customized).pnpm typecheckpasses across all packages; biome clean.