diff --git a/README.md b/README.md
index 9e02113baa114..5372ae1d18a67 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
This is a fork of T3 Code that integrates a few additional features, including:
- **Whiteboard:** A tldraw whiteboard that sits side-by-side with T3 Code, allowing users to interact with agents (or other users) by editing and pointing to the whiteboard. Both the user and the agents can conveniently write links that point to a rectangular region on the whiteboard. Agents can also draw Mermaid diagrams on it, such as flowcharts and statecharts.
- - When the whiteboard's config maps T3 Code's hostname to `"app"`, that hostname opens T3 Code itself, and the project's board opens as a Whiteboard tab in its right panel (+ → Whiteboard). There, Settings → Right panel lets each browser hide items of the + menu or change their letters, over machine defaults set in the whiteboard's config.
+ - When the whiteboard's config maps T3 Code's hostname to `"app"`, that hostname opens T3 Code itself, and the project's board opens as a Whiteboard tab in its right panel (+ → Whiteboard). There, the + menu hides Diff, Pull request, Linked items, and Device by default, and the sidebar hides its Pull requests and Issues buttons by default. In Settings → Right panel, each browser can show or hide + menu items and change their letters over machine defaults from the whiteboard's config. Each browser can show the Pull requests and Issues buttons from Settings → General → Sidebar.
- **Better support for manually switching accounts mid-session:**
- After hitting the usage limit of an account, the thread now retries after 2 minutes and 30 minutes in addition to the default retry behavior of T3 Code. This allows the thread to recover earlier if the user manually switches the account.
- New Codex/Antigravity logins are picked up mid-session without a full restart.
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index 3ad3e62fea0cc..ec05bfeca77fe 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -73,6 +73,7 @@ import {
COMPACT_WHEN_IDLE_LABEL,
FORK_SETTING_TITLES,
} from "~/fork/forkCopy";
+import { SidebarPullRequestsAndIssuesSetting } from "~/fork/sidebarLinks/sidebarLinks";
import { ProjectDefaultsSettings } from "./ProjectDefaultsSettings";
import { ThreadTitleInstructionsSettings } from "./ThreadTitleInstructionsSettings";
import { SnoozePresetsRow } from "./SnoozePresetsSettings";
@@ -980,6 +981,7 @@ export function GeneralSettingsPanel() {
/>
}
/>
+
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 13cf7a4885cb4..e06f4ee839125 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -12,6 +12,7 @@ import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
import * as Schema from "effect/Schema";
import { decodeMsg, msg, useMessages } from "gt-react";
import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts";
+import { BOARD_HOST_SEARCH_ITEMS } from "../../fork/boardHostSearch";
import { FORK_SETTING_TITLES } from "../../fork/forkCopy";
import { writeLocalStorageValue } from "../../hooks/useLocalStorage";
import type { MessageResolver } from "../../i18n/messages";
@@ -78,7 +79,7 @@ export interface SettingsSearchItem {
readonly reflinkWorktreesOnly?: boolean;
readonly agentFeedbackOnly?: boolean;
readonly textGeneratorsOnly?: boolean;
- readonly rightPanelMenuOnly?: boolean;
+ readonly boardHostOnly?: boolean;
readonly secondary?: boolean;
readonly requiresThreadAutoSettlement?: boolean;
}
@@ -100,8 +101,8 @@ export interface SettingsSearchAvailability {
readonly hasTextGeneratorsEnvironment?: boolean;
readonly hasPrimaryEnvironment?: boolean;
readonly hasSecretProvidersEnvironment?: boolean;
- /** A whiteboard board host, the only place the right panel's menu settings exist. */
- readonly hasRightPanelMenu?: boolean;
+ /** True on a whiteboard board host, where board-host-only settings are available. */
+ readonly isBoardHost?: boolean;
}
export const SETTINGS_SECTION_LABELS: Readonly> = {
@@ -1061,13 +1062,7 @@ export const SETTINGS_SEARCH_ITEMS = [
searchTerms: [msg("keyboard shortcuts hotkeys commands bindings json")],
},
...KEYBINDING_SEARCH_ITEMS,
- {
- id: "right-panel-menu",
- title: FORK_SETTING_TITLES.rightPanel,
- to: "/settings/right-panel",
- rightPanelMenuOnly: true,
- searchTerms: ["plus menu launcher surface whiteboard board hide show letter shortcut key"],
- },
+ ...BOARD_HOST_SEARCH_ITEMS,
{
id: "snap-shot-enabled",
title: msg("SnapShots"),
@@ -1727,7 +1722,7 @@ export function filterAvailableSettingsSearchItems(
(!item.agentFeedbackOnly || availability.hasAgentFeedbackEnvironment === true) &&
(!item.textGeneratorsOnly || availability.hasTextGeneratorsEnvironment === true) &&
(!item.secretProvidersOnly || availability.hasSecretProvidersEnvironment === true) &&
- (!item.rightPanelMenuOnly || availability.hasRightPanelMenu === true),
+ (!item.boardHostOnly || availability.isBoardHost === true),
);
}
diff --git a/apps/web/src/components/settings/useAvailableSettingsSearchItems.ts b/apps/web/src/components/settings/useAvailableSettingsSearchItems.ts
index c5fb1aaa7cdc4..aa15649e0a38f 100644
--- a/apps/web/src/components/settings/useAvailableSettingsSearchItems.ts
+++ b/apps/web/src/components/settings/useAvailableSettingsSearchItems.ts
@@ -5,7 +5,7 @@ import { AuthEnvironmentMaintainScope } from "@t3tools/contracts";
import { usePrimaryCloudLinkState } from "~/cloud/cloudLinkState";
import { hasCloudPublicConfig } from "~/cloud/publicConfig";
import { isElectron } from "~/env";
-import { useRightPanelSettingsOffered } from "~/fork/rightPanelMenu/rightPanelMenu";
+import { useIsBoardHost } from "~/fork/whiteboard/role";
import { isLocalEnvironmentDisabled } from "~/localEnvironment";
import { desktopWslStateAtom } from "~/state/desktopWslState";
import { useEnvironments, usePrimaryEnvironmentId } from "~/state/environments";
@@ -82,7 +82,7 @@ export function useAvailableSettingsSearchItems() {
useMessages(),
);
const cloudPublicConfig = hasCloudPublicConfig() === true;
- const hasRightPanelMenu = useRightPanelSettingsOffered();
+ const isBoardHost = useIsBoardHost();
const wslSettingsRowVisible =
isWslSettingsRowVisible({ state: desktopWsl.data, error: desktopWsl.error }) === true;
@@ -102,6 +102,6 @@ export function useAvailableSettingsSearchItems() {
hasTextGeneratorsEnvironment,
hasPrimaryEnvironment: primaryEnvironmentId !== null,
hasSecretProvidersEnvironment,
- hasRightPanelMenu,
+ isBoardHost,
});
}
diff --git a/apps/web/src/components/sidebar/SidebarChrome.tsx b/apps/web/src/components/sidebar/SidebarChrome.tsx
index 1dbc9b9fc6366..59b39e9da46bc 100644
--- a/apps/web/src/components/sidebar/SidebarChrome.tsx
+++ b/apps/web/src/components/sidebar/SidebarChrome.tsx
@@ -14,7 +14,7 @@ import {
} from "../../navigationHistory";
import { primaryServerKeybindingsAtom } from "../../state/server";
import { cn } from "../../lib/utils";
-import { useIssuesSupported, usePullRequestsSupported } from "../../state/environments";
+import { useSidebarUtilityLinks } from "../../fork/sidebarLinks/sidebarLinks";
import { T3Wordmark } from "../T3Wordmark";
import {
resolveEnvironmentIdentificationPillLabel,
@@ -233,8 +233,7 @@ const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
const isOnUtilityPage = useLocation({
select: (location) => isSidebarUtilityPage(location.pathname),
});
- const pullRequestsSupported = usePullRequestsSupported();
- const issuesSupported = useIssuesSupported();
+ const { pullRequests: pullRequestsSupported, issues: issuesSupported } = useSidebarUtilityLinks();
const closeMobileSidebar = () => {
if (isMobile) {
setOpenMobile(false);
diff --git a/apps/web/src/fork/boardHostSearch.test.ts b/apps/web/src/fork/boardHostSearch.test.ts
new file mode 100644
index 0000000000000..d557cf479fb5e
--- /dev/null
+++ b/apps/web/src/fork/boardHostSearch.test.ts
@@ -0,0 +1,33 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import {
+ filterAvailableSettingsSearchItems,
+ searchSettings,
+} from "../components/settings/settingsSearch";
+
+describe("board host settings search", () => {
+ it("finds the board host's settings only on a board host", () => {
+ const availability = {
+ hasCloudPublicConfig: false,
+ hasEnvironment: true,
+ hasProviderSettingsEnvironment: true,
+ canManageLocalBackend: false,
+ isWslSettingsRowVisible: false,
+ hasThreadAutoSettlement: false,
+ };
+ const ids = (query: string, isBoardHost?: boolean) =>
+ searchSettings(
+ query,
+ filterAvailableSettingsSearchItems({
+ ...availability,
+ ...(isBoardHost === undefined ? {} : { isBoardHost }),
+ }),
+ ).map((item) => item.id);
+ expect(ids("sidebar issues")).not.toContain("sidebar-pull-requests-issues");
+ expect(ids("linked items")).not.toContain("right-panel-menu");
+ expect(ids("sidebar issues", false)).not.toContain("sidebar-pull-requests-issues");
+ expect(ids("sidebar issues", true)).toContain("sidebar-pull-requests-issues");
+ expect(ids("linked items", false)).not.toContain("right-panel-menu");
+ expect(ids("linked items", true)).toContain("right-panel-menu");
+ });
+});
diff --git a/apps/web/src/fork/boardHostSearch.ts b/apps/web/src/fork/boardHostSearch.ts
new file mode 100644
index 0000000000000..edbbd56f506c8
--- /dev/null
+++ b/apps/web/src/fork/boardHostSearch.ts
@@ -0,0 +1,22 @@
+import type { SettingsSearchItem } from "../components/settings/settingsSearch";
+import { FORK_SETTING_TITLES, SIDEBAR_LINKS_COPY } from "./forkCopy";
+
+export const BOARD_HOST_SEARCH_ITEMS = [
+ {
+ id: "right-panel-menu",
+ title: FORK_SETTING_TITLES.rightPanel,
+ to: "/settings/right-panel",
+ boardHostOnly: true,
+ searchTerms: [
+ "plus menu launcher surface whiteboard board hide show letter shortcut key",
+ "diff pull request requests pr prs linked items device",
+ ],
+ },
+ {
+ id: "sidebar-pull-requests-issues",
+ title: SIDEBAR_LINKS_COPY.title,
+ to: "/settings/general",
+ boardHostOnly: true,
+ searchTerms: [SIDEBAR_LINKS_COPY.searchTerms],
+ },
+] as const satisfies ReadonlyArray;
diff --git a/apps/web/src/fork/forkCopy.ts b/apps/web/src/fork/forkCopy.ts
index ed36037bee065..5951a39ac29e6 100644
--- a/apps/web/src/fork/forkCopy.ts
+++ b/apps/web/src/fork/forkCopy.ts
@@ -29,6 +29,16 @@ export const RIGHT_PANEL_SETTINGS_COPY = {
letterOf: (label: string) => `${label}: menu letter`,
};
+export const SIDEBAR_LINKS_COPY = {
+ title: "Pull requests and Issues",
+ description:
+ "Show the Pull requests and Issues buttons in the sidebar for this browser only. You can still open both pages from the command palette.",
+ reset: "Reset Pull requests and Issues buttons to default",
+ switchLabel: "Show Pull requests and Issues sidebar buttons",
+ searchTerms:
+ "pull requests pr prs issues sidebar buttons links show hide hidden whiteboard board",
+};
+
// Keybinding labels for commands that act only on the pages named in them.
const COMMAND_LABELS: Readonly>> = {
"rightPanel.toggle": "Right Panel: Toggle (Pull Requests and Issues)",
diff --git a/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx b/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx
index d9fecd8e2d9b4..7a7d0a7172c81 100644
--- a/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx
+++ b/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx
@@ -27,6 +27,7 @@ import { FORK_SURFACES } from "../dashboard/dashboardSurface";
import { RIGHT_PANEL_SETTINGS_COPY as COPY } from "../forkCopy";
import { isBoardHost, useBoardHostRole } from "../whiteboard/role";
import {
+ hiddenByDefault,
parseMenuLayer,
RIGHT_PANEL_MENU_ITEM_IDS,
type RightPanelMenuItemId,
@@ -78,6 +79,7 @@ function writeChoice(id: RightPanelMenuItemId, choice: RightPanelMenuChoice) {
function MenuItemSettingsRow(props: {
readonly item: MenuItemRow;
readonly machine: RightPanelMenuChoice | undefined;
+ readonly hiddenByDefault: boolean;
readonly browser: RightPanelMenuChoice;
}) {
const { item, browser } = props;
@@ -90,7 +92,7 @@ function MenuItemSettingsRow(props: {
? COPY.hidden
: value === "shown"
? COPY.shown
- : COPY.byDefault(props.machine?.hidden === true ? COPY.hidden : COPY.shown);
+ : COPY.byDefault(props.hiddenByDefault ? COPY.hidden : COPY.shown);
const letterLabel = (value: string | null) =>
value === "none"
? COPY.noLetter
@@ -201,6 +203,7 @@ export function RightPanelMenuSettingsPanel() {
key={item.id}
item={item}
machine={machine[item.id]}
+ hiddenByDefault={hiddenByDefault(item.id, machine)}
browser={browser[item.id] ?? {}}
/>
))}
diff --git a/apps/web/src/fork/rightPanelMenu/menu.logic.test.ts b/apps/web/src/fork/rightPanelMenu/menu.logic.test.ts
index debc1dc2dacb1..3db2c36ebd7d8 100644
--- a/apps/web/src/fork/rightPanelMenu/menu.logic.test.ts
+++ b/apps/web/src/fork/rightPanelMenu/menu.logic.test.ts
@@ -22,6 +22,17 @@ const TODAY: ReadonlyArray = [
["whiteboard", "W"],
];
+// A board host hides these until a layer shows them.
+const DEVELOPER_ITEMS: ReadonlyArray = [
+ "diff",
+ "pull-request",
+ "pull-requests",
+ "device",
+];
+const SHOW_DEVELOPER_ITEMS = Object.fromEntries(
+ DEVELOPER_ITEMS.map((id) => [id, { hidden: false }]),
+);
+
const actions = (disabled: ReadonlyArray) =>
TODAY.map(([id, shortcut]) => ({
id,
@@ -41,71 +52,107 @@ describe("arrangeSurfaceActions", () => {
// The menu also offers the Chat action, as it does while the primary Chat is closed.
chat?: boolean;
}>([
- { name: "empty layers keep today's letters" },
{
- name: "empty layers keep today's letters on disabled items",
+ name: "empty layers hide Diff, Pull request, Linked items and Device",
+ hidden: DEVELOPER_ITEMS,
+ },
+ {
+ name: "a browser that shows them keeps today's letters",
+ browser: SHOW_DEVELOPER_ITEMS,
+ },
+ {
+ name: "a browser that shows Diff gets it back with its letter",
+ browser: { diff: { hidden: false } },
+ hidden: ["pull-request", "pull-requests", "device"],
+ },
+ {
+ name: "the machine shows Device for a browser with no choice",
+ machine: { device: { hidden: false } },
+ hidden: ["diff", "pull-request", "pull-requests"],
+ },
+ {
+ name: "a browser that hides Device beats the machine that shows it",
+ machine: { device: { hidden: false } },
+ browser: { device: { hidden: true } },
+ hidden: DEVELOPER_ITEMS,
+ },
+ {
+ name: "a browser letter alone leaves Diff hidden and its letter free",
+ browser: { diff: { key: "D" }, dashboard: { key: "D" } },
+ hidden: DEVELOPER_ITEMS,
+ letters: { dashboard: "D" },
+ },
+ {
+ name: "shown items keep today's letters on disabled items",
+ browser: SHOW_DEVELOPER_ITEMS,
disabled: ["browser", "diff", "side-chat", "whiteboard"],
},
{
name: "unknown ids and fields that do not parse change nothing",
machine: { future: { hidden: true, key: "B" }, files: "hidden", diff: [] },
- browser: { browser: { hidden: "yes", key: "BB" }, terminal: { key: "é" } },
+ browser: {
+ ...SHOW_DEVELOPER_ITEMS,
+ browser: { hidden: "yes", key: "BB" },
+ terminal: { key: "é" },
+ },
},
{
name: "the machine hides items and the browser shows one again",
machine: { files: { hidden: true }, diff: { hidden: true } },
- browser: { diff: { hidden: false } },
+ browser: SHOW_DEVELOPER_ITEMS,
hidden: ["files"],
},
{
name: "no letter is a choice, not inheritance",
machine: { terminal: { key: "X" } },
- browser: { terminal: { key: "" } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, terminal: { key: "" } },
letters: { terminal: "" },
},
{
name: "a browser letter, upper-cased, beats a built-in one",
- browser: { whiteboard: { key: "f" } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, whiteboard: { key: "f" } },
letters: { whiteboard: "F", files: "" },
},
{
name: "a machine letter beats a built-in one",
machine: { dashboard: { key: "B" } },
+ browser: SHOW_DEVELOPER_ITEMS,
letters: { dashboard: "B", browser: "" },
},
{
name: "a browser letter beats a machine one",
machine: { dashboard: { key: "Q" } },
- browser: { replies: { key: "Q" } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, replies: { key: "Q" } },
letters: { replies: "Q" },
},
{
name: "the earlier item wins a tie within a layer",
- browser: { dashboard: { key: "Q" }, replies: { key: "Q" } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, dashboard: { key: "Q" }, replies: { key: "Q" } },
letters: { replies: "Q" },
},
{
name: "an available item keeps its letter over a disabled item's browser choice",
- browser: { whiteboard: { key: "B" } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, whiteboard: { key: "B" } },
disabled: ["whiteboard"],
letters: { whiteboard: "" },
},
{
name: "among disabled items the layer that set the letter wins",
machine: { device: { key: "D" } },
+ browser: SHOW_DEVELOPER_ITEMS,
disabled: ["diff", "device"],
letters: { device: "D", diff: "" },
},
{
name: "an item gets its letter back where the winner is hidden",
- browser: { whiteboard: { key: "F", hidden: true } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, whiteboard: { key: "F", hidden: true } },
hidden: ["whiteboard"],
},
{
name: "the Chat action, which restores the primary Chat, ignores a choice to hide it",
chat: true,
machine: { chat: { hidden: true } },
- browser: { chat: { hidden: true } },
+ browser: { ...SHOW_DEVELOPER_ITEMS, chat: { hidden: true } },
},
{
name: "every item can be hidden",
diff --git a/apps/web/src/fork/rightPanelMenu/menu.logic.ts b/apps/web/src/fork/rightPanelMenu/menu.logic.ts
index b28ceebd9c368..9cc4d20d4f446 100644
--- a/apps/web/src/fork/rightPanelMenu/menu.logic.ts
+++ b/apps/web/src/fork/rightPanelMenu/menu.logic.ts
@@ -59,6 +59,21 @@ export type ArrangedAction = { [K in keyof A]: K extends "shortcut" ? string
// The action that restores the primary Chat; Settings offers no row to show it again.
const NEVER_HIDDEN: RightPanelMenuItemId = "chat";
+// Menu items hidden by default on a board host unless the machine config or browser shows them.
+const HIDDEN_BY_DEFAULT: ReadonlySet = new Set([
+ "diff",
+ "pull-request",
+ "pull-requests",
+ "device",
+]);
+
+/**
+ * Returns true if an item is hidden when this browser sets no override. Reads the machine config
+ * first, then falls back to `HIDDEN_BY_DEFAULT`.
+ */
+export const hiddenByDefault = (id: RightPanelMenuItemId, machine: MenuLayer): boolean =>
+ machine[id]?.hidden ?? HIDDEN_BY_DEFAULT.has(id);
+
const BUILT_IN = 0;
const MACHINE = 1;
const BROWSER = 2;
@@ -73,7 +88,7 @@ export function arrangeSurfaceActions(
browser: MenuLayer,
): Array> {
const shown = actions.flatMap((action, order) => {
- const hidden = browser[action.id]?.hidden ?? machine[action.id]?.hidden ?? false;
+ const hidden = browser[action.id]?.hidden ?? hiddenByDefault(action.id, machine);
if (hidden && action.id !== NEVER_HIDDEN) return [];
const browserKey = browser[action.id]?.key;
const machineKey = machine[action.id]?.key;
diff --git a/apps/web/src/fork/rightPanelMenu/rightPanelMenu.browser.test.tsx b/apps/web/src/fork/rightPanelMenu/rightPanelMenu.browser.test.tsx
new file mode 100644
index 0000000000000..12330d61e6fc1
--- /dev/null
+++ b/apps/web/src/fork/rightPanelMenu/rightPanelMenu.browser.test.tsx
@@ -0,0 +1,55 @@
+import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts";
+import { describe, expect, it, vi } from "vite-plus/test";
+
+import { render } from "../../../test/render";
+import { __setClientSettingsForTests } from "../../hooks/useSettings";
+import type { RightPanelMenuItemId } from "./menu.logic";
+import { useArrangedSurfaceActions } from "./rightPanelMenu";
+
+const host = vi.hoisted(() => ({
+ role: "off" as "off" | "unknown" | { readonly menu: Record },
+}));
+
+vi.mock("../whiteboard/role", async (importOriginal) => ({
+ ...(await importOriginal()),
+ useBoardHostRole: () => host.role,
+}));
+
+const ACTIONS = (["browser", "diff", "pull-request", "pull-requests", "device"] as const).map(
+ (id: RightPanelMenuItemId) => ({ id, shortcut: "", available: true }),
+);
+
+function Menu() {
+ const actions = useArrangedSurfaceActions(ACTIONS);
+ return ;
+}
+
+describe("useArrangedSurfaceActions", () => {
+ it.each<{ name: string; role: typeof host.role; shown: string }>([
+ {
+ name: "off a board host, lists every item",
+ role: "off",
+ shown: ACTIONS.map((a) => a.id).join(","),
+ },
+ {
+ name: "while the role is unknown, hides the default-hidden items",
+ role: "unknown",
+ shown: "browser",
+ },
+ {
+ name: "on a board host, hides the default-hidden items",
+ role: { menu: {} },
+ shown: "browser",
+ },
+ {
+ name: "on a board host, shows an item the machine shows",
+ role: { menu: { device: { hidden: false } } },
+ shown: "browser,device",
+ },
+ ])("$name", async ({ role, shown }) => {
+ host.role = role;
+ __setClientSettingsForTests(DEFAULT_CLIENT_SETTINGS);
+ await using screen = await render();
+ await expect.element(screen.getByRole("status")).toHaveTextContent(`[${shown}]`);
+ });
+});
diff --git a/apps/web/src/fork/rightPanelMenu/rightPanelMenu.tsx b/apps/web/src/fork/rightPanelMenu/rightPanelMenu.tsx
index 7b1582ef82aa4..2eee7da5824aa 100644
--- a/apps/web/src/fork/rightPanelMenu/rightPanelMenu.tsx
+++ b/apps/web/src/fork/rightPanelMenu/rightPanelMenu.tsx
@@ -4,7 +4,7 @@ import { Button } from "../../components/ui/button";
import { MenuItem } from "../../components/ui/menu";
import type { SettingsPath } from "../../components/settings/settingsSearch";
import { useClientSettings } from "../../hooks/useSettings";
-import { isBoardHost, useBoardHostRole } from "../whiteboard/role";
+import { isBoardHost, useBoardHostRole, useIsBoardHost } from "../whiteboard/role";
import {
type ArrangedAction,
arrangeSurfaceActions,
@@ -14,25 +14,27 @@ import {
const RIGHT_PANEL_SETTINGS_PATH = "/settings/right-panel" satisfies SettingsPath;
-/** The "+" menu or launcher items after the machine's and this browser's menu choices. */
+/**
+ * The "+" menu or launcher items after built-in defaults, the machine's choices, and this
+ * browser's choices. Off a board host, this hook returns upstream's list unchanged.
+ */
export function useArrangedSurfaceActions(
actions: ReadonlyArray,
): ReadonlyArray> {
const role = useBoardHostRole();
const browser = useClientSettings((settings) => settings.rightPanelMenuOverrides);
- // Off a board host the menu is exactly upstream's.
- if (!isBoardHost(role)) return actions as ReadonlyArray>;
- return arrangeSurfaceActions(actions, parseMenuLayer(role.menu), parseMenuLayer(browser));
+ // Off a board host, return the upstream list unchanged. While the role is unknown, apply
+ // the built-in defaults and browser choices with no machine layer.
+ if (role === "off") return actions as ReadonlyArray>;
+ const machine = isBoardHost(role) ? parseMenuLayer(role.menu) : {};
+ return arrangeSurfaceActions(actions, machine, parseMenuLayer(browser));
}
-/** Settings > Right panel exists only on a board host; its nav, search and palette entries too. */
-export const useRightPanelSettingsOffered = (): boolean => isBoardHost(useBoardHostRole());
-
/** The settings nav with Right panel after Keybindings, on a board host only. */
export function useForkSettingsNavGroups<
Group extends { readonly paths: ReadonlyArray },
>(groups: ReadonlyArray): ReadonlyArray {
- const offered = useRightPanelSettingsOffered();
+ const offered = useIsBoardHost();
if (!offered) return groups;
return groups.map((group) => ({
...group,
diff --git a/apps/web/src/fork/sidebarLinks/sidebarLinks.browser.test.tsx b/apps/web/src/fork/sidebarLinks/sidebarLinks.browser.test.tsx
new file mode 100644
index 0000000000000..1e86d7cacda9e
--- /dev/null
+++ b/apps/web/src/fork/sidebarLinks/sidebarLinks.browser.test.tsx
@@ -0,0 +1,94 @@
+import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts";
+import { describe, expect, it, vi } from "vite-plus/test";
+import { userEvent } from "vite-plus/test/browser";
+
+import "~/index.css";
+
+import { render } from "../../../test/render";
+import { SidebarChromeFooter } from "../../components/sidebar/SidebarChrome";
+import { SidebarProvider } from "../../components/ui/sidebar";
+import { __setClientSettingsForTests } from "../../hooks/useSettings";
+import { useIssuesSupported, usePullRequestsSupported } from "../../state/environments";
+import { SIDEBAR_LINKS_COPY } from "../forkCopy";
+import { SidebarPullRequestsAndIssuesSetting } from "./sidebarLinks";
+
+const host = vi.hoisted(() => ({ role: "off" as "off" | "unknown" | { readonly menu: object } }));
+
+vi.mock("../whiteboard/role", async (importOriginal) => ({
+ ...(await importOriginal()),
+ useBoardHostRole: () => host.role,
+}));
+vi.mock("../../state/environments", { spy: true });
+
+function setup(role: typeof host.role) {
+ host.role = role;
+ vi.mocked(usePullRequestsSupported).mockReturnValue(true);
+ vi.mocked(useIssuesSupported).mockReturnValue(true);
+ __setClientSettingsForTests(DEFAULT_CLIENT_SETTINGS);
+ return {
+ [Symbol.dispose]: () => __setClientSettingsForTests(DEFAULT_CLIENT_SETTINGS),
+ };
+}
+
+const renderSidebarAndSetting = () =>
+ render(
+
+
+
+ ,
+ );
+
+describe("sidebar Pull requests and Issues", () => {
+ it("are hidden on a board host until this browser turns them on", async () => {
+ using _settings = setup({ menu: {} });
+ await using screen = await renderSidebarAndSetting();
+
+ await expect.element(screen.getByRole("button", { name: "Settings" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Usage" })).toBeVisible();
+ await expect
+ .element(screen.getByRole("button", { name: "Pull requests" }))
+ .not.toBeInTheDocument();
+ await expect.element(screen.getByRole("button", { name: "Issues" })).not.toBeInTheDocument();
+
+ await userEvent.click(screen.getByRole("switch", { name: SIDEBAR_LINKS_COPY.switchLabel }));
+
+ await expect.element(screen.getByRole("button", { name: "Pull requests" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Issues" })).toBeVisible();
+ });
+
+ it.each([
+ { saved: false, shown: false },
+ { saved: true, shown: true },
+ ])(
+ "follow this browser's saved choice ($saved) while the board-host role is unknown",
+ async ({ saved, shown }) => {
+ using _settings = setup("unknown");
+ __setClientSettingsForTests({
+ ...DEFAULT_CLIENT_SETTINGS,
+ sidebarPullRequestsAndIssuesShown: saved,
+ });
+ await using screen = await render(
+
+
+ ,
+ );
+
+ await expect.element(screen.getByRole("button", { name: "Usage" })).toBeVisible();
+ for (const name of ["Pull requests", "Issues"]) {
+ const button = expect.element(screen.getByRole("button", { name }));
+ await (shown ? button.toBeVisible() : button.not.toBeInTheDocument());
+ }
+ },
+ );
+
+ it("show off a board host, which has no setting for them", async () => {
+ using _settings = setup("off");
+ await using screen = await renderSidebarAndSetting();
+
+ await expect.element(screen.getByRole("button", { name: "Pull requests" })).toBeVisible();
+ await expect.element(screen.getByRole("button", { name: "Issues" })).toBeVisible();
+ await expect
+ .element(screen.getByRole("switch", { name: SIDEBAR_LINKS_COPY.switchLabel }))
+ .not.toBeInTheDocument();
+ });
+});
diff --git a/apps/web/src/fork/sidebarLinks/sidebarLinks.tsx b/apps/web/src/fork/sidebarLinks/sidebarLinks.tsx
new file mode 100644
index 0000000000000..68f87f8fb605a
--- /dev/null
+++ b/apps/web/src/fork/sidebarLinks/sidebarLinks.tsx
@@ -0,0 +1,62 @@
+import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts";
+
+import { SettingResetButton, SettingsRow } from "~/components/settings/settingsLayout";
+import { useSearchableSetting } from "~/components/settings/settingsSearch";
+import { Switch } from "~/components/ui/switch";
+import { updateClientSettings, useClientSettings } from "~/hooks/useSettings";
+import { useIssuesSupported, usePullRequestsSupported } from "~/state/environments";
+
+import { SIDEBAR_LINKS_COPY as COPY } from "../forkCopy";
+import { isBoardHost, useBoardHostRole } from "../whiteboard/role";
+
+/**
+ * Returns whether each link is supported and shown. Supported links show when role is "off".
+ * On a board host or while "unknown" until server config loads, they follow this browser's switch.
+ */
+export function useSidebarUtilityLinks(): {
+ readonly pullRequests: boolean;
+ readonly issues: boolean;
+} {
+ const pullRequestsSupported = usePullRequestsSupported();
+ const issuesSupported = useIssuesSupported();
+ const role = useBoardHostRole();
+ const turnedOn = useClientSettings((settings) => settings.sidebarPullRequestsAndIssuesShown);
+ const shown = role === "off" || turnedOn;
+ return { pullRequests: pullRequestsSupported && shown, issues: issuesSupported && shown };
+}
+
+/** Settings > General > Sidebar switch for Pull requests and Issues. Renders only on a board host. */
+export function SidebarPullRequestsAndIssuesSetting() {
+ const setting = useSearchableSetting();
+ const role = useBoardHostRole();
+ const turnedOn = useClientSettings((settings) => settings.sidebarPullRequestsAndIssuesShown);
+ if (!isBoardHost(role)) return null;
+ return (
+
+ void updateClientSettings({
+ sidebarPullRequestsAndIssuesShown:
+ DEFAULT_CLIENT_SETTINGS.sidebarPullRequestsAndIssuesShown,
+ })
+ }
+ />
+ ) : null
+ }
+ control={
+
+ void updateClientSettings({ sidebarPullRequestsAndIssuesShown: Boolean(checked) })
+ }
+ aria-label={COPY.switchLabel}
+ />
+ }
+ />
+ );
+}
diff --git a/apps/web/src/fork/whiteboard/role.ts b/apps/web/src/fork/whiteboard/role.ts
index 4adc46054b63a..e02835887dd5e 100644
--- a/apps/web/src/fork/whiteboard/role.ts
+++ b/apps/web/src/fork/whiteboard/role.ts
@@ -36,6 +36,8 @@ const readBoardHostRole = (): BoardHostRole => appAtomRegistry.get(boardHostRole
export const isBoardHost = (role: BoardHostRole): role is { readonly menu: RightPanelMenuLayer } =>
typeof role === "object";
+export const useIsBoardHost = (): boolean => isBoardHost(useBoardHostRole());
+
/** False inside the board page's chat slot, where the board already sits beside the chat. */
export const isTopWindow = (): boolean => window.parent === window;
diff --git a/fork/whiteboard/run-t3.md b/fork/whiteboard/run-t3.md
index e7a355a1bba33..acbb1d8ec2d72 100644
--- a/fork/whiteboard/run-t3.md
+++ b/fork/whiteboard/run-t3.md
@@ -57,6 +57,6 @@ The fork's T3 Code differs from upstream in the points below for the whiteboard'
- Whiteboard links (every build). `board://` links in assistant markdown are allowed and rendered with hover and click handlers that reach the board through `apps/web/src/fork/whiteboard/boardChannel.ts`: inside the board page's chat slot as `wb-hover` and `wb-highlight` messages to the parent window, on a board host as messages to the Whiteboard tab's frame (next entry), and nowhere otherwise, and `[label](board://...)` mention chips in the composer show the label and report hover. Files: `apps/web/src/fork/whiteboard/markdown-whiteboard.ts` (with test), `apps/web/src/components/ChatMarkdown.tsx`, `packages/shared/src/markdownHast.ts` (`board` href protocol), `apps/web/src/markdown/wordsHast.ts` (calls `forkHast` in `apps/web/src/fork/forkMarkdown.ts`), `apps/web/src/fork/forkMarkdown.ts` (with test; `forkHast` links bare `board://` URLs through `linkBoardUrls` in `markdown-whiteboard.ts` when `boardLinks` is set, which only `ChatMarkdown.tsx` does, so this is chat only), `apps/web/src/components/ComposerPromptEditorTiptap.tsx`, `packages/shared/src/composerInlineTokens.ts` (board mention token, with test).
- Parent-window messages (whiteboard build, inside the iframe). The chat posts `wb-project` (workspace root and thread key) when the active thread changes, inserts a reference into the composer on a `wb-insert-ref` message, and follows the board panel's state: it asks with `wb-layout-get`, the parent answers with `wb-layout` (`boardHidden`), and while the board is collapsed a Board button before the sidebar trigger posts `wb-show-board`. Files: `apps/web/src/fork/whiteboard/useWhiteboardProject.ts` (called from `components/ChatView.tsx`), `useWhiteboardInsertRef.ts` (called from `components/chat/ChatComposer.tsx`), `WhiteboardSidebar.tsx` (hooks and Board button, used by `components/AppSidebarLayout.tsx`).
- Iframe layout (whiteboard build). The composer never switches to its mobile layout. Standalone, the sidebar starts open only when the window fits it beside the minimum thread width; inside the iframe it starts closed, unless the first `wb-layout` report says the board is hidden and the sidebar fits. The whiteboard build passes no `storageKey`, so upstream's stored sidebar state (#24202) is off and this start rule applies on every load. Files: `apps/web/src/components/chat/ChatComposer.tsx` (`isMobileViewport`), `apps/web/src/components/AppSidebarLayout.tsx` (`SidebarProvider` props), `apps/web/src/fork/whiteboard/WhiteboardSidebar.tsx` (`whiteboardSidebarProviderProps`).
-- Board as a right-panel tab (whiteboard build, top-level window). When some hostname in `openViews` maps to `"app"`, `run-t3.sh` exports `T3CODE_WHITEBOARD_PANEL` as `{"menu": }`; it leaves the variable unset otherwise, and also when the config cannot be read, which it reports in one line. The server parses the variable leniently and advertises it as the `whiteboardPanel` capability; without it the client is unchanged. With it, the right panel's menu offers a Whiteboard item that opens the board page's embed mode, `/?embed=panel&room=`, in an iframe, and Settings > Right panel lets each browser hide menu items or change their letters over the machine defaults. The board page in that iframe renders the board alone (`web/pageMode.ts` picks the mode, `web/panelHost.ts` bridges it): it posts `wb-ready` to the parent once the board can show a region and `wb-unload` when the page goes away, takes `wb-highlight`, `wb-hover` (with `origin` in the iframe's coordinates) and `wb-visible` (a hidden board stops drawing), and posts `wb-insert-ref`. Both sides accept messages only from their own origin and from the other window. `boardChannel.ts` keeps the iframe loaded while its tab is hidden: it owns one frame per board page and moves it with `Element.moveBefore` between the tab and a hidden holder, at most two per window, and unloads a board when no thread that showed it lists its tab; browsers without `moveBefore` reload it. Files: `apps/server/src/fork/whiteboardPanel.ts` (with test), `packages/contracts/src/fork/rightPanelMenu.ts` (with test), `apps/web/src/fork/whiteboard/` (`role.ts`, `WhiteboardPanel.tsx`, `boardChannel.ts`, `boardChannel.logic.ts` with test, `useWhiteboardInsertRef.ts`), `apps/web/src/fork/rightPanelMenu/` (resolver with test, the settings page, the nav, search and all-hidden hooks), `apps/web/src/fork/dashboard/dashboardSurface.ts` (the Whiteboard item beside Dashboard and Replies). Upstream hooks, each a few lines that call into those files: `apps/server/src/environment/ServerEnvironment.ts`, `packages/contracts/src/{environment,settings,index}.ts`, `apps/web/src/rightPanelStore.ts` and `closedViewStore.ts` (the `whiteboard` kind), `apps/web/src/components/RightPanelTabs.tsx` (an `id` on each menu item, the two `useArrangedSurfaceActions` wraps, the all-hidden hint, title and icon cases), `components/chat/RightPanelSurfaceContent.tsx` (the tab body), `components/ChatMarkdown.tsx` (the link click), `components/chat/ChatComposer.tsx` (the composer's insert hook), `components/settings/{settingsSearch.ts,useAvailableSettingsSearchItems.ts,SettingsSidebarNav.tsx,SettingsScopeSentence.tsx}` and `routes/_chat.settings.right-panel.tsx` (the page, its nav entry, its search gate). A merge that drops the `SettingsSidebarNav.tsx` or search hook still type-checks, so check the page's nav and search entries by hand. The settings page repeats the upstream items' built-in letters (`RightPanelMenuSettings.tsx`); when upstream changes a letter in `RightPanelTabs.tsx`, change it there too.
+- Board as a right-panel tab (whiteboard build, top-level window). When some hostname in `openViews` maps to `"app"`, `run-t3.sh` exports `T3CODE_WHITEBOARD_PANEL` as `{"menu": }`; it leaves the variable unset otherwise, and also when the config cannot be read, which it reports in one line. The server parses the variable leniently and advertises it as the `whiteboardPanel` capability; without it the client is unchanged. On a whiteboard build, while the board-host role is still unknown before the primary server config arrives, the built-in hidden defaults and this browser's choices apply to the menu and the sidebar buttons, and that temporary state ends once the config arrives. With it, the right panel's menu offers a Whiteboard item that opens the board page's embed mode, `/?embed=panel&room=`, in an iframe, and Settings > Right panel lets each browser hide menu items or change their letters over the machine defaults. In `apps/web/src/fork/rightPanelMenu/menu.logic.ts`, `hiddenByDefault` sets built-in defaults that hide `diff`, `pull-request`, `pull-requests`, and `device` under the machine and browser layers. On a board host, the sidebar's Pull requests and Issues buttons follow the client setting `sidebarPullRequestsAndIssuesShown` (default off) through `apps/web/src/fork/sidebarLinks/`, with a switch in Settings > General > Sidebar. The board page in that iframe renders the board alone (`web/pageMode.ts` picks the mode, `web/panelHost.ts` bridges it): it posts `wb-ready` to the parent once the board can show a region and `wb-unload` when the page goes away, takes `wb-highlight`, `wb-hover` (with `origin` in the iframe's coordinates) and `wb-visible` (a hidden board stops drawing), and posts `wb-insert-ref`. Both sides accept messages only from their own origin and from the other window. `boardChannel.ts` keeps the iframe loaded while its tab is hidden: it owns one frame per board page and moves it with `Element.moveBefore` between the tab and a hidden holder, at most two per window, and unloads a board when no thread that showed it lists its tab; browsers without `moveBefore` reload it. Files: `apps/server/src/fork/whiteboardPanel.ts` (with test), `packages/contracts/src/fork/rightPanelMenu.ts` (with test), `apps/web/src/fork/whiteboard/` (`role.ts`, `WhiteboardPanel.tsx`, `boardChannel.ts`, `boardChannel.logic.ts` with test, `useWhiteboardInsertRef.ts`), `apps/web/src/fork/rightPanelMenu/` (resolver with test, the settings page, the nav, search and all-hidden hooks), `apps/web/src/fork/dashboard/dashboardSurface.ts` (the Whiteboard item beside Dashboard and Replies), `apps/web/src/fork/sidebarLinks/` (the link hook and settings row, with browser test), `apps/web/src/fork/boardHostSearch.ts` (with test). Upstream hooks, each a few lines that call into those files: `apps/server/src/environment/ServerEnvironment.ts`, `packages/contracts/src/{environment,settings,index}.ts`, `apps/web/src/rightPanelStore.ts` and `closedViewStore.ts` (the `whiteboard` kind), `apps/web/src/components/RightPanelTabs.tsx` (an `id` on each menu item, the two `useArrangedSurfaceActions` wraps, the all-hidden hint, title and icon cases), `components/chat/RightPanelSurfaceContent.tsx` (the tab body), `components/ChatMarkdown.tsx` (the link click), `components/chat/ChatComposer.tsx` (the composer's insert hook), `apps/web/src/components/sidebar/SidebarChrome.tsx` (the sidebar buttons call `useSidebarUtilityLinks`), `components/settings/{settingsSearch.ts,useAvailableSettingsSearchItems.ts}` (`settingsSearch.ts` spreads the fork's board-host entries and `useAvailableSettingsSearchItems.ts` reads `useIsBoardHost` for the search gate), `components/settings/{SettingsSidebarNav.tsx,SettingsScopeSentence.tsx}` and `routes/_chat.settings.right-panel.tsx` (the page and its nav entry), `components/settings/SettingsPanels.tsx` (the General > Sidebar row). A merge that drops the `SettingsSidebarNav.tsx` or search hook still type-checks, so check the page's nav and search entries by hand. The settings page repeats the upstream items' built-in letters (`RightPanelMenuSettings.tsx`); when upstream changes a letter in `RightPanelTabs.tsx`, change it there too.
- New-thread landing. `run-t3.sh` sets `T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD=false` so each page load opens the new-thread page rather than the oldest thread of the project.
- Board of the calling chat. `run-t3.sh` exports `WB_CHAT_PID`, the server's own PID, which agents inherit. `wb` walks up its parent processes to the server's child, the agent, and uses that agent's working directory to pick the board.
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 6aac4bab3b11b..4915255896947 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -625,6 +625,10 @@ export const ClientSettingsSchema = Schema.Struct({
),
// Fork: how many path segments chat file links show in this browser.
fileLinkPathDepth: StoredFileLinkPathDepth,
+ // Fork: per-browser toggle to show the sidebar Pull requests and Issues buttons on a board host.
+ sidebarPullRequestsAndIssuesShown: Schema.Boolean.pipe(
+ Schema.withDecodingDefault(Effect.succeed(false)),
+ ),
});
export type ClientSettings = typeof ClientSettingsSchema.Type;
@@ -2215,5 +2219,6 @@ export const ClientSettingsPatch = Schema.Struct({
mathRenderingEnabled: Schema.optionalKey(Schema.Boolean),
rightPanelMenuOverrides: Schema.optionalKey(RightPanelMenuOverrides),
fileLinkPathDepth: Schema.optionalKey(FileLinkPathDepth),
+ sidebarPullRequestsAndIssuesShown: Schema.optionalKey(Schema.Boolean),
});
export type ClientSettingsPatch = typeof ClientSettingsPatch.Type;