Skip to content

Commit abf74e4

Browse files
fix(pull-requests): review guides beta is a server setting
The beta gate was a client setting, so agents could write guides on a server whose users never opted in. It now lives in server settings: off hides the Guide tab in every client and the server refuses to write a guide. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7720c75 commit abf74e4

9 files changed

Lines changed: 72 additions & 27 deletions

File tree

‎apps/server/src/pullRequest/PullRequestReviewGuideService.test.ts‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ const makeLayer = (input: {
146146
readonly generate: TextGeneration.TextGeneration["Service"]["generateReviewGuide"];
147147
/** Completed when a run stores its guide, which is the last thing a run does but forget it. */
148148
readonly stored: Deferred.Deferred<void>;
149+
/** The server's beta switch; on unless a test is about it being off. */
150+
readonly enabled?: boolean;
149151
}) =>
150152
PullRequestReviewGuideService.layer.pipe(
151153
Layer.provide(
@@ -185,7 +187,7 @@ const makeLayer = (input: {
185187
generateReviewGuide: input.generate,
186188
} as unknown as TextGeneration.TextGeneration["Service"]),
187189
),
188-
Layer.provide(ServerSettings.layerTest()),
190+
Layer.provide(ServerSettings.layerTest({ reviewGuidesEnabled: input.enabled ?? true })),
189191
Layer.provide(ServerConfig.layerTest(input.root, { prefix: "t3-review-guide-config-" })),
190192
);
191193

@@ -323,4 +325,27 @@ it.layer(layerBase)("PullRequestReviewGuideService", (it) => {
323325
}),
324326
),
325327
);
328+
329+
it.effect("refuses to write a guide while the server has review guides off", () =>
330+
Effect.scoped(
331+
Effect.gen(function* () {
332+
const repositories = yield* makeRepositories;
333+
const stored = yield* Deferred.make<void>();
334+
const context = yield* Layer.build(
335+
makeLayer({
336+
...repositories,
337+
stored,
338+
enabled: false,
339+
generate: () => Effect.die("a guide must not be written while the beta is off"),
340+
}),
341+
);
342+
const service = Context.get(
343+
context,
344+
PullRequestReviewGuideService.PullRequestReviewGuideService,
345+
);
346+
const result = yield* Effect.flip(service.generate(reference));
347+
assert.include(result.message, "Review guides are off");
348+
}),
349+
),
350+
);
326351
});

‎apps/server/src/pullRequest/PullRequestReviewGuideService.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,23 @@ const make = Effect.gen(function* () {
294294
const generate: PullRequestReviewGuideService["Service"]["generate"] = Effect.fn(
295295
"PullRequestReviewGuideService.generate",
296296
)(function* (input) {
297+
// A beta the server owns, so every client and agent sees the same answer.
298+
const settings = yield* serverSettings.getSettings.pipe(
299+
Effect.mapError(
300+
(cause) =>
301+
new PullRequestOperationError({
302+
operation: "generateReviewGuide",
303+
detail: "Could not read the server settings.",
304+
cause,
305+
}),
306+
),
307+
);
308+
if (!settings.reviewGuidesEnabled) {
309+
return yield* new PullRequestOperationError({
310+
operation: "generateReviewGuide",
311+
detail: "Review guides are off. Turn them on in Settings → Source Control.",
312+
});
313+
}
297314
const { key, workspaceRoot } = yield* keyFor(input);
298315
const runKey = keyString(key);
299316
const [detail, stored] = yield* Effect.all([pullRequests.detail(input), readStored(key)], {

‎apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import {
6161

6262
import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
6363
import { useRightPanelStore } from "~/rightPanelStore";
64-
import { useClientSettings } from "~/hooks/useSettings";
64+
import { useEnvironmentSettings } from "~/hooks/useSettings";
6565
import { useNewThreadHandler } from "~/hooks/useHandleNewThread";
6666
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
6767
import { isCommandPaletteOpen } from "~/commandPaletteBus";
@@ -1550,8 +1550,11 @@ export function PullRequestDetailPanel({
15501550
// A host that cannot produce a patch has no Code tab to open. While detail is loading the ghost
15511551
// uses this optimistic tab set to reserve the same chrome; a host without a patch removes Code
15521552
// when its capabilities arrive.
1553-
// The Guide tab is a beta this device opts into in Settings → Source Control.
1554-
const reviewGuidesEnabled = useClientSettings((settings) => settings.reviewGuidesEnabled);
1553+
// The Guide tab is a beta the pull request's server opts into in Settings → Source Control.
1554+
const reviewGuidesEnabled = useEnvironmentSettings(
1555+
environmentId,
1556+
(settings) => settings.reviewGuidesEnabled,
1557+
);
15551558
const visibleTabs = TABS.filter(
15561559
(item) =>
15571560
(item.value !== "code" || detail === null || detail.capabilities.diff) &&

‎apps/web/src/components/pullRequest/guide/PullRequestGuideRunCoordinator.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useNavigate } from "@tanstack/react-router";
22
import { CircleAlertIcon, CircleCheckIcon } from "lucide-react";
33
import { useEffect, useRef } from "react";
44

5-
import { getClientSettings, useClientSettings } from "~/hooks/useSettings";
5+
import { getClientSettings } from "~/hooks/useSettings";
66
import { pullRequestEnvironment } from "~/state/pullRequests";
77
import { useEnvironmentQuery } from "~/state/query";
88
import {
@@ -26,9 +26,6 @@ const UNSEEN_RUN_MS = 60_000;
2626
*/
2727
export function PullRequestGuideRunCoordinator() {
2828
const watches = useGuideRunStore((state) => state.watches);
29-
// Nothing starts a run while the beta is off, but one started before it was turned off ends quietly.
30-
const enabled = useClientSettings((settings) => settings.reviewGuidesEnabled);
31-
if (!enabled) return null;
3229
return Object.entries(watches).map(([key, watch]) => (
3330
<GuideRunWatcher key={key} runKey={key} watch={watch} />
3431
));

‎apps/web/src/components/settings/SourceControlWritingSettings.test.tsx‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ vi.mock("./useScopedSettings", () => ({
1717
...DEFAULT_UNIFIED_SETTINGS,
1818
sourceControlWritingStyle: state.styles[0],
1919
}),
20-
useScopedSettingsMixed: () => JSON.stringify(state.styles[0]) !== JSON.stringify(state.styles[1]),
20+
// Review guides stay off and agreed here, so their rows do not render beside the style's.
21+
useScopedSettingsMixed: (keys: ReadonlyArray<string>) =>
22+
!keys.includes("reviewGuidesEnabled") &&
23+
JSON.stringify(state.styles[0]) !== JSON.stringify(state.styles[1]),
2124
useUpdateScopedSettings: () => state.updateSettings,
2225
}));
2326
vi.mock("./SettingsScopeContext", () => ({
@@ -35,12 +38,6 @@ vi.mock("./useScopedModelAvailability", () => ({
3538
}));
3639
vi.mock("../ui/toast", () => ({ toastManager: { add: vi.fn() } }));
3740
vi.mock("../../state/server", () => ({ EMPTY_SERVER_PROVIDERS: [] }));
38-
// Review guides are a beta that is off here; these tests cover the writing style.
39-
vi.mock("../../hooks/useSettings", () => ({
40-
useClientSettings: (select: (settings: { reviewGuidesEnabled: boolean }) => unknown) =>
41-
select({ reviewGuidesEnabled: false }),
42-
useUpdateClientSettings: () => vi.fn(),
43-
}));
4441
vi.mock("../chat/ProviderModelPicker", () => ({ ProviderModelPicker: () => null }));
4542
vi.mock("./settingsSearch", () => ({ searchableSetting: (id: string) => ({ id, title: id }) }));
4643
vi.mock("./settingsLayout", () => ({

‎apps/web/src/components/settings/SourceControlWritingSettings.tsx‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
getCustomModelOptionsByInstance,
2929
resolveAppModelSelectionState,
3030
} from "../../modelSelection";
31-
import { useClientSettings, useUpdateClientSettings } from "../../hooks/useSettings";
3231
import { EMPTY_SERVER_PROVIDERS } from "../../state/server";
3332
import { ProviderModelPicker } from "../chat/ProviderModelPicker";
3433
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
@@ -65,9 +64,7 @@ const MODE_OPTIONS: Record<SourceControlWritingStyleMode, { label: string; descr
6564
export function SourceControlWritingSettingsSection() {
6665
const settings = useScopedSettings();
6766
const updateSettings = useUpdateScopedSettings();
68-
// A beta: the Guide tab and its settings stay out of the way until this device opts in.
69-
const reviewGuidesEnabled = useClientSettings((client) => client.reviewGuidesEnabled);
70-
const updateClientSettings = useUpdateClientSettings();
67+
const mixedReviewGuidesEnabled = useScopedSettingsMixed(["reviewGuidesEnabled"]);
7168
const navigate = useNavigate();
7269
const { environment, connectedEnvironments, targets } = useSettingsScope();
7370
// The representative supplies the provider list; a model choice is checked
@@ -379,19 +376,24 @@ export function SourceControlWritingSettingsSection() {
379376
}
380377
/>
381378

379+
{/* A beta the server owns: off hides the Guide tab in every client and refuses agents. */}
382380
<SettingsRow
381+
serverScoped
382+
settingKeys={["reviewGuidesEnabled"]}
383+
mixed={mixedReviewGuidesEnabled}
383384
{...searchableSetting("review-guides")}
384-
description="Adds a Guide tab to pull requests: an agent writes a tour of the change, stop by stop, with the calls a maintainer should make. Applies to this device."
385+
description="Adds a Guide tab to pull requests: an agent writes a tour of the change, stop by stop, with the calls a maintainer should make."
385386
control={
386387
<Switch
387-
checked={reviewGuidesEnabled}
388-
onCheckedChange={(checked) => updateClientSettings({ reviewGuidesEnabled: checked })}
388+
mixed={mixedReviewGuidesEnabled}
389+
checked={mixedReviewGuidesEnabled ? false : settings.reviewGuidesEnabled}
390+
onCheckedChange={(checked) => updateSettings({ reviewGuidesEnabled: Boolean(checked) })}
389391
aria-label="Review guides"
390392
/>
391393
}
392394
/>
393395

394-
{reviewGuidesEnabled ? (
396+
{settings.reviewGuidesEnabled || mixedReviewGuidesEnabled ? (
395397
<>
396398
<SettingsRow
397399
serverScoped

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ export const SETTINGS_SEARCH_ITEMS = [
874874
title: "Review guides (beta)",
875875
to: "/settings/source-control",
876876
searchTerms: ["pull request pr guided review guide tour beta experimental"],
877+
environmentOnly: true,
877878
},
878879
{
879880
id: "review-guide-model",

‎docs/user/source-control.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ declined pull request.
188188
### Review guides
189189

190190
Review guides are in beta. Turn on **Review guides** in Settings → Source Control to add the
191-
**Guide** tab to pull requests on this device.
191+
**Guide** tab to pull requests on that server.
192192

193193
The **Guide** tab gives you a tour of a pull request without reading it line by line: stops
194194
through the change in reading order. Each stop points at the lines worth reading, and a stop marked

‎packages/contracts/src/settings.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,6 @@ export const ClientSettingsSchema = Schema.Struct({
304304
Schema.withDecodingDefault(Effect.succeed("off" as const)),
305305
),
306306
inAppNotificationsEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
307-
/** Beta: the Guide tab on pull requests, and writing guides from their menu. */
308-
reviewGuidesEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
309307
diffColorScheme: DiffColorScheme.pipe(
310308
Schema.withDecodingDefault(Effect.succeed("red-green" as const)),
311309
),
@@ -1243,6 +1241,11 @@ export const ServerSettings = Schema.Struct({
12431241
sourceControlWriterModelSelection: Schema.NullOr(ModelSelection).pipe(
12441242
Schema.withDecodingDefault(Effect.succeed(null)),
12451243
),
1244+
/**
1245+
* Beta: review guides on this server. Off hides the Guide tab in every client and refuses to
1246+
* write guides, for people and agents alike.
1247+
*/
1248+
reviewGuidesEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
12461249
/**
12471250
* The model that reads a pull request to write its review guide. It investigates a checkout
12481251
* over many turns, so it can want a stronger model than one-shot writing. `null` uses the
@@ -1513,6 +1516,7 @@ export const ServerSettingsPatch = Schema.Struct({
15131516
}),
15141517
),
15151518
sourceControlWriterModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
1519+
reviewGuidesEnabled: Schema.optionalKey(Schema.Boolean),
15161520
reviewGuideModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
15171521
reviewGuideInstructions: Schema.optionalKey(TrimmedString),
15181522
pullRequestMergeMethod: Schema.optionalKey(Schema.NullOr(PullRequestMergeMethod)),
@@ -1592,7 +1596,6 @@ export function requiredScopesForProjectMutation(
15921596
export const ClientSettingsPatch = Schema.Struct({
15931597
notificationMode: Schema.optionalKey(NotificationMode),
15941598
inAppNotificationsEnabled: Schema.optionalKey(Schema.Boolean),
1595-
reviewGuidesEnabled: Schema.optionalKey(Schema.Boolean),
15961599
diffColorScheme: Schema.optionalKey(DiffColorScheme),
15971600
chatWidth: Schema.optionalKey(ChatWidth),
15981601
loadBalancingEnabled: Schema.optionalKey(Schema.Boolean),

0 commit comments

Comments
 (0)