Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/components/settings/SettingsPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -980,6 +981,7 @@ export function GeneralSettingsPanel() {
/>
}
/>
<SidebarPullRequestsAndIssuesSetting />
</SettingsSection>

<SettingsSection id="confirmations" title={gt("Confirmations")}>
Expand Down
17 changes: 6 additions & 11 deletions apps/web/src/components/settings/settingsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand All @@ -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<Record<SettingsPath, string>> = {
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand All @@ -102,6 +102,6 @@ export function useAvailableSettingsSearchItems() {
hasTextGeneratorsEnvironment,
hasPrimaryEnvironment: primaryEnvironmentId !== null,
hasSecretProvidersEnvironment,
hasRightPanelMenu,
isBoardHost,
});
}
5 changes: 2 additions & 3 deletions apps/web/src/components/sidebar/SidebarChrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions apps/web/src/fork/boardHostSearch.test.ts
Original file line number Diff line number Diff line change
@@ -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");
});
});
22 changes: 22 additions & 0 deletions apps/web/src/fork/boardHostSearch.ts
Original file line number Diff line number Diff line change
@@ -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<SettingsSearchItem>;
10 changes: 10 additions & 0 deletions apps/web/src/fork/forkCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Partial<Record<string, string>>> = {
"rightPanel.toggle": "Right Panel: Toggle (Pull Requests and Issues)",
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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] ?? {}}
/>
))}
Expand Down
69 changes: 58 additions & 11 deletions apps/web/src/fork/rightPanelMenu/menu.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ const TODAY: ReadonlyArray<readonly [RightPanelMenuItemId, string]> = [
["whiteboard", "W"],
];

// A board host hides these until a layer shows them.
const DEVELOPER_ITEMS: ReadonlyArray<RightPanelMenuItemId> = [
"diff",
"pull-request",
"pull-requests",
"device",
];
const SHOW_DEVELOPER_ITEMS = Object.fromEntries(
DEVELOPER_ITEMS.map((id) => [id, { hidden: false }]),
);

const actions = (disabled: ReadonlyArray<RightPanelMenuItemId>) =>
TODAY.map(([id, shortcut]) => ({
id,
Expand All @@ -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",
Expand Down
17 changes: 16 additions & 1 deletion apps/web/src/fork/rightPanelMenu/menu.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ export type ArrangedAction<A> = { [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<RightPanelMenuItemId> = 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;
Expand All @@ -73,7 +88,7 @@ export function arrangeSurfaceActions<A extends MenuAction>(
browser: MenuLayer,
): Array<ArrangedAction<A>> {
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;
Expand Down
Loading
Loading