feat(web): setting to open pull request links on GitHub (#19719)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
45b5993a52
commit
cd34df59a1
7 files changed
+57
-2
No files matched your search
@@ -622,6 +622,35 @@ function BrowserLinkTargetSetting({ disabled }: { readonly disabled: boolean })
|
||||
);
|
||||
}
|
||||
|
||||
function PullRequestLinksOpenInAppSetting() {
|
||||
const openInApp = useClientSettings((settings) => settings.pullRequestLinksOpenInApp);
|
||||
const updateSettings = useUpdatePrimarySettings();
|
||||
|
||||
return (
|
||||
<SettingsRow
|
||||
{...searchableSetting("pull-request-links-open-in-app")}
|
||||
description="Clicking a pull request link opens it in T3 Code. Turn off to open pull request links like any other link, on GitHub or your git host."
|
||||
resetAction={
|
||||
openInApp ? null : (
|
||||
<SettingResetButton
|
||||
label="open pull requests in T3 Code"
|
||||
onClick={() => updateSettings({ pullRequestLinksOpenInApp: true })}
|
||||
/>
|
||||
)
|
||||
}
|
||||
control={
|
||||
<Switch
|
||||
checked={openInApp}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({ pullRequestLinksOpenInApp: Boolean(checked) })
|
||||
}
|
||||
aria-label="Open pull requests in T3 Code"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function DeviceIntegrationSettings() {
|
||||
const { search, environment: selected } = useSettingsScope();
|
||||
const settings = useScopedSettings();
|
||||
@@ -1545,6 +1574,7 @@ export function IntegrationsSettingsPanel() {
|
||||
) : (
|
||||
previewDefaults
|
||||
)}
|
||||
<PullRequestLinksOpenInAppSetting />
|
||||
</SettingsSection>
|
||||
<DeviceIntegrationSettings />
|
||||
</SettingsPageContainer>
|
||||
|
||||
@@ -242,6 +242,7 @@ describe("getChangedBrowserSettingLabels", () => {
|
||||
browserRecordingShowMousePresses: true,
|
||||
browserLinkTarget: "app",
|
||||
browserAutoShowFloatingPreview: !DEFAULT_UNIFIED_SETTINGS.browserAutoShowFloatingPreview,
|
||||
pullRequestLinksOpenInApp: false,
|
||||
}),
|
||||
).toEqual([
|
||||
"Browser viewport",
|
||||
@@ -252,6 +253,7 @@ describe("getChangedBrowserSettingLabels", () => {
|
||||
"Recording mouse presses",
|
||||
"Open links in",
|
||||
"Floating preview",
|
||||
"Open pull requests in T3 Code",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -118,6 +118,7 @@ export type BrowserDefaultSettings = Pick<
|
||||
| "browserRecordingShowMousePresses"
|
||||
| "browserLinkTarget"
|
||||
| "browserAutoShowFloatingPreview"
|
||||
| "pullRequestLinksOpenInApp"
|
||||
>;
|
||||
|
||||
/**
|
||||
@@ -166,6 +167,9 @@ export function getChangedBrowserSettingLabels(settings: BrowserDefaultSettings)
|
||||
DEFAULT_UNIFIED_SETTINGS.browserAutoShowFloatingPreview
|
||||
? ["Floating preview"]
|
||||
: []),
|
||||
...(settings.pullRequestLinksOpenInApp !== DEFAULT_UNIFIED_SETTINGS.pullRequestLinksOpenInApp
|
||||
? ["Open pull requests in T3 Code"]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -676,6 +676,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
settings.browserRecordingShowMousePresses,
|
||||
settings.browserLinkTarget,
|
||||
settings.browserAutoShowFloatingPreview,
|
||||
settings.pullRequestLinksOpenInApp,
|
||||
settings.appearanceContrast,
|
||||
settings.diffColorScheme,
|
||||
settings.chatWidth,
|
||||
@@ -855,6 +856,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
browserRecordingShowMousePresses: DEFAULT_UNIFIED_SETTINGS.browserRecordingShowMousePresses,
|
||||
browserLinkTarget: DEFAULT_UNIFIED_SETTINGS.browserLinkTarget,
|
||||
browserAutoShowFloatingPreview: DEFAULT_UNIFIED_SETTINGS.browserAutoShowFloatingPreview,
|
||||
pullRequestLinksOpenInApp: DEFAULT_UNIFIED_SETTINGS.pullRequestLinksOpenInApp,
|
||||
// Re-granted like any other default. The confirmation dialog lists it by
|
||||
// name, so a user restoring defaults is told the agent regains access
|
||||
// rather than discovering it later.
|
||||
|
||||
@@ -778,6 +778,12 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
to: "/settings/integrations",
|
||||
searchTerms: ["links default browser in-app browser external open"],
|
||||
},
|
||||
{
|
||||
id: "pull-request-links-open-in-app",
|
||||
title: "Open pull requests in T3 Code",
|
||||
to: "/settings/integrations",
|
||||
searchTerms: ["pr links github browser external click default pull request view panel"],
|
||||
},
|
||||
{
|
||||
id: "browser-auto-show-floating-preview",
|
||||
title: "Auto-show floating preview",
|
||||
|
||||
@@ -8,6 +8,7 @@ import { parseChangeRequestUrl, type ChangeRequestLink } from "@t3tools/shared/c
|
||||
import { sourceControlRepositorySelector } from "@t3tools/shared/sourceControl";
|
||||
|
||||
import { useOpenLink } from "../browser/useOpenLink";
|
||||
import { useClientSettings } from "../hooks/useSettings";
|
||||
import { stackedThreadToast, toastManager } from "../components/ui/toast";
|
||||
import { useRightPanelStore } from "../rightPanelStore";
|
||||
import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell";
|
||||
@@ -122,6 +123,8 @@ export function findProjectOnChangeRequestHost(
|
||||
* the pull requests page: a reader following a link the agent wrote is reading the thread, and
|
||||
* should still be reading it afterwards. Any change request opens there, not only the thread's
|
||||
* own, since the panel is told which one to show.
|
||||
*
|
||||
* With "Open pull requests in T3 Code" turned off, every link is left alone.
|
||||
*/
|
||||
export function shouldOpenPullRequestExternally(
|
||||
event: Pick<MouseEvent<HTMLElement>, "metaKey" | "ctrlKey">,
|
||||
@@ -145,9 +148,10 @@ export function useOpenChangeRequestLink(
|
||||
const allProjects = useProjects();
|
||||
const serverConfigs = useServerConfigs();
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
const openInApp = useClientSettings((settings) => settings.pullRequestLinksOpenInApp);
|
||||
return useCallback(
|
||||
(event, targetUrl, targetThreadRef, targetEnvironmentId) => {
|
||||
if (shouldOpenPullRequestExternally(event)) return false;
|
||||
if (!openInApp || shouldOpenPullRequestExternally(event)) return false;
|
||||
const resolvedThreadRef = targetThreadRef ?? threadRef;
|
||||
const resolvedPanelRef = panelRef ?? resolvedThreadRef;
|
||||
const parsed = parseChangeRequestUrl(targetUrl);
|
||||
@@ -243,7 +247,7 @@ export function useOpenChangeRequestLink(
|
||||
});
|
||||
return true;
|
||||
},
|
||||
[allProjects, navigate, panelRef, primaryEnvironmentId, serverConfigs, threadRef],
|
||||
[allProjects, navigate, openInApp, panelRef, primaryEnvironmentId, serverConfigs, threadRef],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -441,6 +441,12 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
TrimmedNonEmptyString,
|
||||
PullRequestMergeMethod,
|
||||
).pipe(Schema.withDecodingDefault(Effect.succeed({}))),
|
||||
/**
|
||||
* Whether clicking a pull request link opens T3 Code's pull request view.
|
||||
* When false, pull request links open like any other link, so they reach
|
||||
* GitHub or the repository's other host.
|
||||
*/
|
||||
pullRequestLinksOpenInApp: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
||||
// Legacy plan mode. The composer's Build/Plan toggle was removed from the
|
||||
// default UI; this beta flag restores it (plus the /plan and /default slash
|
||||
// commands) for users who still rely on the old workflow.
|
||||
@@ -1742,6 +1748,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
pullRequestMergeMethodOverrides: Schema.optionalKey(
|
||||
Schema.Record(TrimmedNonEmptyString, PullRequestMergeMethod),
|
||||
),
|
||||
pullRequestLinksOpenInApp: Schema.optionalKey(Schema.Boolean),
|
||||
planModeEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
contextWindowMeterEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
composerCollapseOnScroll: Schema.optionalKey(Schema.Boolean),
|
||||
|
||||
Reference in new issue
Block a user