GeezerVison is showing github.com — Merge pull request 'feat(web): one fork-features flag gates Home, the… · yasinuslu/t3code@7b4e047
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/AppSidebarLayout.tsx +18-6Lines changed: 18 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import { useAtomValue } from "@effect/atom-react"; | 2 | 2 | import * as Schema from "effect/Schema"; | 3 | 3 | import { | 4 | 4 | useEffect, | | 5 | + useLayoutEffect, | 5 | 6 | useState, | 6 | 7 | useSyncExternalStore, | 7 | 8 | type CSSProperties, | @@ -25,15 +26,19 @@ import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../termina | 25 | 26 | import { resolveThreadRouteRef } from "../threadRoutes"; | 26 | 27 | import { cn, isMacPlatform } from "../lib/utils"; | 27 | 28 | import { primaryServerKeybindingsAtom } from "../state/server"; | 28 | | -import { useEnvironmentIdentificationMode, useLegacySidebarEnabled } from "../hooks/useSettings"; | | 29 | +import { | | 30 | + useEnvironmentIdentificationMode, | | 31 | + useForkFeatures, | | 32 | + useLegacySidebarEnabled, | | 33 | +} from "../hooks/useSettings"; | 29 | 34 | import { | 30 | 35 | PanelAnimationSuppressionProvider, | 31 | 36 | usePanelAnimationSettings, | 32 | 37 | usePanelNavigationSuppression, | 33 | 38 | } from "../panelAnimations"; | 34 | 39 | import { BrainstormHost } from "./brainstorm/BrainstormHost"; | 35 | 40 | import { HomeOverlay } from "./home/HomeOverlay"; | 36 | | -import { useHomeOverlayStore } from "../homeOverlayStore"; | | 41 | +import { setHomeOverlayEnabled, useHomeOverlayStore } from "../homeOverlayStore"; | 37 | 42 | import { ModeShortcuts, ModeSwitch } from "./ModeSwitch"; | 38 | 43 | import { PhoneTabBar } from "./PhoneTabBar"; | 39 | 44 | import LegacyThreadSidebar from "./LegacySidebar"; | @@ -229,6 +234,9 @@ function ProjectProjectionRetention() { | 229 | 234 | export function AppSidebarLayout({ children }: { children: ReactNode }) { | 230 | 235 | const navigate = useNavigate(); | 231 | 236 | const legacySidebarEnabled = useLegacySidebarEnabled(); | | 237 | + const forkFeatures = useForkFeatures(); | | 238 | + // Before first paint, so a reloaded Home never flashes while the flag is off. | | 239 | + useLayoutEffect(() => setHomeOverlayEnabled(forkFeatures), [forkFeatures]); | 232 | 240 | const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } = | 233 | 241 | usePanelAnimationSettings(); | 234 | 242 | // Settings routes show the settings nav in place of whichever thread | @@ -347,11 +355,15 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) { | 347 | 355 | <SidebarRail onDoubleClick={resetSidebarWidth} /> | 348 | 356 | </Sidebar> | 349 | 357 | {children} | 350 | | - <HomeOverlay /> | | 358 | + {forkFeatures ? <HomeOverlay /> : null} | 351 | 359 | <SidebarControl /> | 352 | | - <ModeSwitch /> | 353 | | - <PhoneTabBar /> | 354 | | - <ModeShortcuts /> | | 360 | + {forkFeatures ? ( | | 361 | + <> | | 362 | + <ModeSwitch /> | | 363 | + <PhoneTabBar /> | | 364 | + <ModeShortcuts /> | | 365 | + </> | | 366 | + ) : null} | 355 | 367 | <NavigationHistoryShortcuts /> | 356 | 368 | <MainAppLocationTracker /> | 357 | 369 | </SidebarProvider> | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/CommandPalette.tsx +30-27Lines changed: 30 additions & 27 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -89,7 +89,7 @@ import { useDesktopLocalBootstraps } from "../connection/useDesktopLocalBootstra | 89 | 89 | import { useHandleNewThread } from "../hooks/useHandleNewThread"; | 90 | 90 | import { useOpenPanelPullRequestUrl } from "../hooks/useOpenPanelPullRequestUrl"; | 91 | 91 | import { writeTextToClipboard } from "../hooks/useCopyToClipboard"; | 92 | | -import { useClientSettings } from "../hooks/useSettings"; | | 92 | +import { useClientSettings, useForkFeatures } from "../hooks/useSettings"; | 93 | 93 | import { useTheme } from "../hooks/useTheme"; | 94 | 94 | import { useCustomThemes } from "../hooks/useCustomThemes"; | 95 | 95 | import { useEnvironmentThemeDefinitions } from "../hooks/useEnvironmentTheme"; | @@ -729,6 +729,7 @@ function OpenCommandPaletteDialog(props: { | 729 | 729 | setHighlightedItemValue(null); | 730 | 730 | } | 731 | 731 | const clientSettings = useClientSettings(); | | 732 | + const forkFeatures = useForkFeatures(); | 732 | 733 | const createProject = useAtomCommand(projectEnvironment.create, { | 733 | 734 | reportFailure: false, | 734 | 735 | }); | @@ -2251,36 +2252,38 @@ function OpenCommandPaletteDialog(props: { | 2251 | 2252 | }); | 2252 | 2253 | } | 2253 | 2254 |
| 2254 | | - actionItems.push({ | 2255 | | - kind: "action", | 2256 | | - value: "action:manager", | 2257 | | - searchTerms: ["home", "manager", "dashboard", "work", "goals", "tasks", "status", "plan"], | 2258 | | - title: "Go home (manager and work)", | 2259 | | - icon: <CompassIcon className={ITEM_ICON_CLASS} />, | 2260 | | - shortcutCommand: "manager.open", | 2261 | | - run: async () => openManagerHome(), | 2262 | | - }); | 2263 | | - | 2264 | | - for (const entry of APP_MODES) { | | 2255 | + if (forkFeatures) { | 2265 | 2256 | actionItems.push({ | 2266 | 2257 | kind: "action", | 2267 | | - value: `action:mode-${entry.mode}`, | 2268 | | - searchTerms: [ | 2269 | | - "mode", | 2270 | | - "switch", | 2271 | | - "view", | 2272 | | - "grow", | 2273 | | - "manager", | 2274 | | - "classic", | 2275 | | - "normal", | 2276 | | - "threads", | 2277 | | - "t3", | 2278 | | - ], | 2279 | | - title: `Switch to ${entry.label} mode`, | | 2258 | + value: "action:manager", | | 2259 | + searchTerms: ["home", "manager", "dashboard", "work", "goals", "tasks", "status", "plan"], | | 2260 | + title: "Go home (manager and work)", | 2280 | 2261 | icon: <CompassIcon className={ITEM_ICON_CLASS} />, | 2281 | | - shortcutCommand: entry.command, | 2282 | | - run: async () => setAppMode(entry.mode), | | 2262 | + shortcutCommand: "manager.open", | | 2263 | + run: async () => openManagerHome(), | 2283 | 2264 | }); | | 2265 | + | | 2266 | + for (const entry of APP_MODES) { | | 2267 | + actionItems.push({ | | 2268 | + kind: "action", | | 2269 | + value: `action:mode-${entry.mode}`, | | 2270 | + searchTerms: [ | | 2271 | + "mode", | | 2272 | + "switch", | | 2273 | + "view", | | 2274 | + "grow", | | 2275 | + "manager", | | 2276 | + "classic", | | 2277 | + "normal", | | 2278 | + "threads", | | 2279 | + "t3", | | 2280 | + ], | | 2281 | + title: `Switch to ${entry.label} mode`, | | 2282 | + icon: <CompassIcon className={ITEM_ICON_CLASS} />, | | 2283 | + shortcutCommand: entry.command, | | 2284 | + run: async () => setAppMode(entry.mode), | | 2285 | + }); | | 2286 | + } | 2284 | 2287 | } | 2285 | 2288 |
| 2286 | 2289 | actionItems.push({ | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/SettingsPanels.tsx +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -587,6 +587,7 @@ export function useSettingsRestore(onRestored?: () => void) { | 587 | 587 | ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads | 588 | 588 | ? ["Snooze limited threads"] | 589 | 589 | : []), | | 590 | + ...(settings.forkFeatures !== DEFAULT_UNIFIED_SETTINGS.forkFeatures ? ["Fork features"] : []), | 590 | 591 | ...(settings.hostsManager !== DEFAULT_UNIFIED_SETTINGS.hostsManager | 591 | 592 | ? ["Host the manager"] | 592 | 593 | : []), | @@ -711,6 +712,7 @@ export function useSettingsRestore(onRestored?: () => void) { | 711 | 712 | settings.sidebarAutoSettleOnMerge, | 712 | 713 | settings.autoResumeLimitedThreads, | 713 | 714 | settings.snoozeLimitedThreads, | | 715 | + settings.forkFeatures, | 714 | 716 | settings.hostsManager, | 715 | 717 | settings.managerProfiles, | 716 | 718 | settings.sidebarProjectGroupingMode, | @@ -820,6 +822,7 @@ export function useSettingsRestore(onRestored?: () => void) { | 820 | 822 | sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge, | 821 | 823 | autoResumeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads, | 822 | 824 | snoozeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads, | | 825 | + forkFeatures: DEFAULT_UNIFIED_SETTINGS.forkFeatures, | 823 | 826 | hostsManager: DEFAULT_UNIFIED_SETTINGS.hostsManager, | 824 | 827 | managerProfiles: DEFAULT_UNIFIED_SETTINGS.managerProfiles, | 825 | 828 | responseStreamingMode: DEFAULT_UNIFIED_SETTINGS.responseStreamingMode, | @@ -2413,6 +2416,20 @@ export function GeneralSettingsPanel() { | 2413 | 2416 | /> | 2414 | 2417 | } | 2415 | 2418 | /> | | 2419 | + <SettingsRow | | 2420 | + serverScoped | | 2421 | + {...searchableSetting("fork-features")} | | 2422 | + description="Home with Grow and the Manager, the mode switch and its shortcuts. Turn off to use the app as upstream T3 Code ships it." | | 2423 | + settingKeys={["forkFeatures"]} | | 2424 | + control={ | | 2425 | + <ScopedSwitch | | 2426 | + settingKeys={["forkFeatures"]} | | 2427 | + checked={settings.forkFeatures} | | 2428 | + onCheckedChange={(checked) => updateSettings({ forkFeatures: Boolean(checked) })} | | 2429 | + aria-label="Fork features" | | 2430 | + /> | | 2431 | + } | | 2432 | + /> | 2416 | 2433 | <SettingsRow | 2417 | 2434 | serverScoped | 2418 | 2435 | {...searchableSetting("host-manager")} | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/settings/settingsSearch.ts +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -292,6 +292,12 @@ export const SETTINGS_SEARCH_ITEMS = [ | 292 | 292 | to: "/settings/general", | 293 | 293 | searchTerms: ["usage quota rate limit reset wake recover continue"], | 294 | 294 | }, | | 295 | + { | | 296 | + id: "fork-features", | | 297 | + title: "Fork features", | | 298 | + to: "/settings/general", | | 299 | + searchTerms: ["grow manager home mode upstream fork flag switch"], | | 300 | + }, | 295 | 301 | { | 296 | 302 | id: "host-manager", | 297 | 303 | title: "Host the manager", | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/sidebar/SidebarHomeEntry.tsx +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { | 11 | 11 | } from "../../brainstormStore"; | 12 | 12 | import { openManagerHome, useOpenManagerThreadPage } from "../brainstorm/useOpenManagerThread"; | 13 | 13 | import { useMediaQuery } from "../../hooks/useMediaQuery"; | | 14 | +import { useForkFeatures } from "../../hooks/useSettings"; | 14 | 15 | import { shortcutLabelForCommand } from "../../keybindings"; | 15 | 16 | import { useAtomValue } from "@effect/atom-react"; | 16 | 17 | import { primaryServerKeybindingsAtom } from "../../state/server"; | @@ -24,6 +25,10 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; | 24 | 25 | * the active profile's manager thread. | 25 | 26 | */ | 26 | 27 | export const SidebarHomeEntry = memo(function SidebarHomeEntry() { | | 28 | + return useForkFeatures() ? <HomeEntry /> : null; | | 29 | +}); | | 30 | + | | 31 | +function HomeEntry() { | 27 | 32 | const keybindings = useAtomValue(primaryServerKeybindingsAtom); | 28 | 33 | const managerKeys = useManagerThreadKeys(); | 29 | 34 | const allThreads = useThreadShellsWithoutBrainstorms(); | @@ -89,4 +94,4 @@ export const SidebarHomeEntry = memo(function SidebarHomeEntry() { | 89 | 94 | </Tooltip> | 90 | 95 | </div> | 91 | 96 | ); | 92 | | -}); | | 97 | +} |
Collapse file Copy file name to clipboard +35Lines changed: 35 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { afterEach, describe, expect, it } from "vitest"; | | 2 | + | | 3 | +import { | | 4 | + closeHomeOverlay, | | 5 | + openHomeOverlay, | | 6 | + setHomeOverlayEnabled, | | 7 | + toggleHomeOverlay, | | 8 | + useHomeOverlayStore, | | 9 | +} from "./homeOverlayStore"; | | 10 | + | | 11 | +describe("Home while the fork features are off", () => { | | 12 | + afterEach(() => { | | 13 | + setHomeOverlayEnabled(true); | | 14 | + closeHomeOverlay(); | | 15 | + }); | | 16 | + | | 17 | + it("closes an open Home and refuses to open it again", () => { | | 18 | + openHomeOverlay(); | | 19 | + expect(useHomeOverlayStore.getState().open).toBe(true); | | 20 | + | | 21 | + setHomeOverlayEnabled(false); | | 22 | + expect(useHomeOverlayStore.getState().open).toBe(false); | | 23 | + | | 24 | + openHomeOverlay(); | | 25 | + toggleHomeOverlay(); | | 26 | + expect(useHomeOverlayStore.getState().open).toBe(false); | | 27 | + }); | | 28 | + | | 29 | + it("opens again once the features are back on", () => { | | 30 | + setHomeOverlayEnabled(false); | | 31 | + setHomeOverlayEnabled(true); | | 32 | + openHomeOverlay(); | | 33 | + expect(useHomeOverlayStore.getState().open).toBe(true); | | 34 | + }); | | 35 | +}); |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/homeOverlayStore.ts +11-2Lines changed: 11 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,12 +34,21 @@ const lastWasClosed = () => { | 34 | 34 | } | 35 | 35 | }; | 36 | 36 |
| | 37 | +// Home belongs to the fork features: while they are off, nothing can open it. | | 38 | +let homeEnabled = true; | | 39 | + | 37 | 40 | export const useHomeOverlayStore = create<HomeOverlayStore>()((set) => ({ | 38 | 41 | open: reopened, | 39 | | - setOpen: (open) => set({ open }), | 40 | | - toggle: () => set((state) => ({ open: !state.open })), | | 42 | + setOpen: (open) => set({ open: open && homeEnabled }), | | 43 | + toggle: () => set((state) => ({ open: !state.open && homeEnabled })), | 41 | 44 | })); | 42 | 45 |
| | 46 | +/** Called by the app shell with the `forkFeatures` setting; turning it off closes Home. */ | | 47 | +export function setHomeOverlayEnabled(enabled: boolean) { | | 48 | + homeEnabled = enabled; | | 49 | + if (!enabled) useHomeOverlayStore.setState({ open: false }); | | 50 | +} | | 51 | + | 43 | 52 | export const openHomeOverlay = () => useHomeOverlayStore.getState().setOpen(true); | 44 | 53 |
| 45 | 54 | let openedOnStartup = reopened; | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/hooks/useSettings.ts +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -380,6 +380,15 @@ export function useLegacySidebarEnabled(): boolean { | 380 | 380 | return settingsHydrated && legacySidebarEnabled; | 381 | 381 | } | 382 | 382 |
| | 383 | +/** | | 384 | + * Whether the fork's additions are on (`forkFeatures`), read from the primary | | 385 | + * environment. Chrome that only exists in this fork asks this; it is on while | | 386 | + * the settings are still loading and in the hosted app, which has no primary. | | 387 | + */ | | 388 | +export function useForkFeatures(): boolean { | | 389 | + return useAtomValue(primaryServerSettingsAtom).forkFeatures; | | 390 | +} | | 391 | + | 383 | 392 | /** Read current settings for one environment, merged with client-local preferences. */ | 384 | 393 | export function useEnvironmentSettings<T = UnifiedSettings>( | 385 | 394 | environmentId: EnvironmentId, | |
Collapse file Copy file name to clipboardExpand all lines: packages/contracts/src/settings.ts +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1353,6 +1353,12 @@ export const ServerSettings = Schema.Struct({ | 1353 | 1353 | * that sets this, else on their primary one. | 1354 | 1354 | */ | 1355 | 1355 | hostsManager: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))), | | 1356 | + /** | | 1357 | + * The master switch for everything this fork adds on top of upstream T3 Code | | 1358 | + * (Home with Grow and the Manager, the mode switch and its shortcuts, and | | 1359 | + * whatever gets gated behind it next). Off, the app behaves like upstream. | | 1360 | + */ | | 1361 | + forkFeatures: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))), | 1356 | 1362 | /** | 1357 | 1363 | * Code profiles whose managers this server runs, so each profile's manager | 1358 | 1364 | * can live on the machine that does that profile's work. A server that | @@ -1731,6 +1737,7 @@ export const ServerSettingsPatch = Schema.Struct({ | 1731 | 1737 | autoResumeLimitedThreads: Schema.optionalKey(Schema.Boolean), | 1732 | 1738 | snoozeLimitedThreads: Schema.optionalKey(Schema.Boolean), | 1733 | 1739 | hostsManager: Schema.optionalKey(Schema.Boolean), | | 1740 | + forkFeatures: Schema.optionalKey(Schema.Boolean), | 1734 | 1741 | managerProfiles: Schema.optionalKey(Schema.Array(TrimmedNonEmptyString)), | 1735 | 1742 | backgroundActivity: Schema.optionalKey( | 1736 | 1743 | Schema.Struct({ | |
|