Repository navigation
feat(pull-requests): manage GitHub maintainer edits #25588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 17 commits into
pingdotgg:main
from
Bil0000:t3/maintainer-edit-access
Oct 28, 2026
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a8749d7
feat(pr): add GitHub maintainer edit control
Bil0000 1ea7738
refactor(pr): move maintainer edits to menus
Bil0000 05ea166
fix(pr): hide maintainer edits on closed requests
Bil0000 ff02566
fix(mobile): use maintainer edit permission
Bil0000 d65b597
fix(pr): preserve pending maintainer edits on refresh
Bil0000 718327b
test(pull-requests): takeover tests for maintainer edits
juliusmarminge 8ed48fd
refactor(pull-requests): maintainer edits follow the existing action …
juliusmarminge 05d1a23
fix(pull-requests): a saved maintainer-edits choice no longer masks a…
juliusmarminge 4e848d5
Merge remote-tracking branch 'origin/main' into pr-25588
juliusmarminge c7eaa64
fix(pull-requests): a failed maintainer-edits save restores the previ…
juliusmarminge 375cc4c
Merge remote-tracking branch 'origin/main' into pr-25588
juliusmarminge 03ee95a
refactor(pull-requests): one pending-choice rule for maintainer edits…
juliusmarminge 238611f
Merge remote-tracking branch 'origin/main' into pr-25588
juliusmarminge affe7e2
test(pull-requests): cut the maintainer-edit takeover's tests to the …
juliusmarminge b4aaaee
fix(pull-requests): a saved maintainer-edits choice yields to the hos…
juliusmarminge 651dacf
Merge remote-tracking branch 'origin/main' into t3/maintainer-edit-ac…
Bil0000 cf247b9
fix(web): align maintainer edits with PR menu actions
Bil0000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
65 changes: 65 additions & 0 deletions
65
apps/mobile/src/features/pull-requests/usePullRequestMaintainerEdits.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { useAtomRefresh } from "@effect/atom-react"; | ||
| import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; | ||
| import type { PullRequestDetail } from "@t3tools/contracts"; | ||
| import { AsyncResult } from "effect/reactivity"; | ||
| import { useRef, useState } from "react"; | ||
| import * as Dialog from "../../components/ui/Dialog"; | ||
| import { composerPullRequests } from "../../state/pull-requests"; | ||
| import { useAtomCommand } from "../../state/use-atom-command"; | ||
| import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff"; | ||
| import { usePullRequestPermissions } from "./usePullRequestPermissions"; | ||
|
|
||
| export function usePullRequestMaintainerEdits( | ||
| params: PullRequestParams, | ||
| pr: PullRequestDetail | null, | ||
| ) { | ||
| const target = pullRequestTarget(params); | ||
| const permissions = usePullRequestPermissions(params, pr); | ||
| const update = useAtomCommand(composerPullRequests.update, { reportFailure: false }); | ||
| const refreshDetail = useAtomRefresh(composerPullRequests.detail(target)); | ||
| const pending = useRef(false); | ||
| const [saving, setSaving] = useState(false); | ||
| const [choice, setChoice] = useState<{ | ||
| readonly url: string; | ||
| readonly observed: boolean | undefined; | ||
| readonly value: boolean; | ||
| } | null>(null); | ||
| const observed = pr?.maintainerCanModify; | ||
| // A choice ends at the first host value that differs from the one it was made against, so a | ||
| // later change made elsewhere is never masked by it. | ||
| if (choice !== null && !saving && (choice.url !== pr?.url || choice.observed !== observed)) { | ||
| setChoice(null); | ||
| } | ||
| const value = choice !== null && choice.url === pr?.url ? choice.value : observed === true; | ||
| const save = async (next: boolean) => { | ||
| if (pending.current || pr === null || !permissions.canEditMaintainerEdits) return; | ||
| pending.current = true; | ||
| setSaving(true); | ||
| setChoice({ url: pr.url, observed, value: next }); | ||
| const response = await update({ | ||
| ...target, | ||
| input: { ...target.input, maintainerCanModify: next }, | ||
| }); | ||
| pending.current = false; | ||
| setSaving(false); | ||
| if (AsyncResult.isFailure(response)) { | ||
| setChoice(null); | ||
| const cause = squashAtomCommandFailure(response); | ||
| Dialog.alert( | ||
| "Could not save maintainer access", | ||
| cause instanceof Error ? cause.message : "Try again.", | ||
| ); | ||
| return; | ||
| } | ||
| refreshDetail(); | ||
| }; | ||
| return { | ||
| visible: permissions.canEditMaintainerEdits, | ||
| value, | ||
| saving, | ||
| subtitle: saving | ||
| ? "Saving…" | ||
| : "Maintainers can push to this branch and may get access to fork workflow secrets.", | ||
| toggle: () => void save(!value), | ||
| }; | ||
| } | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.