diff --git a/README.md b/README.md index 4ff4bb6eb64cc..a81ac365918b1 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,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. +- **Zulip tab:** When the machine sets `T3CODE_ZULIP_PANEL_URL` to a Zulip page, the right panel offers that page as a Zulip tab (+ → Zulip). Each person signs in to Zulip in their own browser. The tab shows only when T3 Code is opened from a sibling hostname of that page (such as `t3.example.com` beside `zulip.example.com`), and the page must allow T3 Code to frame it, which a stock Zulip server does not. - **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/server/src/environment/ServerEnvironment.ts b/apps/server/src/environment/ServerEnvironment.ts index 4cb94fadc9d6b..ac355cb5e72e8 100644 --- a/apps/server/src/environment/ServerEnvironment.ts +++ b/apps/server/src/environment/ServerEnvironment.ts @@ -25,6 +25,7 @@ import * as ProcessRunner from "../processRunner.ts"; import { isSpeechPlatformSupported } from "../speech/platform.ts"; import { fastCheckoutCapabilities } from "../fork/reflinkWorktrees/fastCheckoutSetting.ts"; import { whiteboardPanelCapabilities } from "../fork/whiteboardPanel.ts"; +import { zulipPanelCapabilities } from "../fork/zulipPanel.ts"; import { resolveServerEnvironmentLabel } from "./ServerEnvironmentLabel.ts"; import { detectServerEnvironmentMachineKind } from "./ServerEnvironmentMachine.ts"; @@ -305,6 +306,7 @@ export const make = Effect.gen(function* () { shellThreadFamilies: true, shellOlderSettled: true, ...(yield* whiteboardPanelCapabilities()), + ...(yield* zulipPanelCapabilities()), }, }; diff --git a/apps/server/src/fork/zulipPanel.ts b/apps/server/src/fork/zulipPanel.ts new file mode 100644 index 0000000000000..fc60bf9875eb6 --- /dev/null +++ b/apps/server/src/fork/zulipPanel.ts @@ -0,0 +1,17 @@ +import { parseZulipPanelUrl } from "@t3tools/contracts"; +import * as HostProcess from "@t3tools/shared/HostProcess"; +import * as Effect from "effect/Effect"; + +// The warning names the variable only, never its value. +export const zulipPanelCapabilities = Effect.fn("zulipPanel.capabilities")(function* () { + const raw = (yield* HostProcess.Environment).T3CODE_ZULIP_PANEL_URL; + if (raw === undefined) return {}; + const url = parseZulipPanelUrl(raw); + if (url === undefined) { + yield* Effect.logWarning( + "T3CODE_ZULIP_PANEL_URL is not an https URL (or http on loopback); the Zulip tab is off", + ); + return {}; + } + return { zulipPanel: { url } }; +}); diff --git a/apps/web/src/closedViewStore.ts b/apps/web/src/closedViewStore.ts index 1e9e7dabf5422..2d385f591c575 100644 --- a/apps/web/src/closedViewStore.ts +++ b/apps/web/src/closedViewStore.ts @@ -66,6 +66,7 @@ const isClosedViewEntry = (entry: unknown): entry is ClosedViewEntry => { case "dashboard": case "replies": case "whiteboard": + case "zulip": return surface.id === surface.kind; case "preview": return surface.resourceId === null || typeof surface.resourceId === "string"; diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsx index f6734ad67a883..ef92773f84117 100644 --- a/apps/web/src/components/RightPanelTabs.tsx +++ b/apps/web/src/components/RightPanelTabs.tsx @@ -641,6 +641,7 @@ function surfaceTitle( case "dashboard": case "replies": case "whiteboard": + case "zulip": return modeSurfaceLabel(surface.kind); case "preview": { const snapshot = surface.resourceId ? sessions[surface.resourceId] : null; @@ -737,6 +738,7 @@ function SurfaceIcon({ case "dashboard": case "replies": case "whiteboard": + case "zulip": return ; case "device": return surface.target?.platform === "ios" ? ( diff --git a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx index 93c63812375f5..44448f458e7c3 100644 --- a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx +++ b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx @@ -17,6 +17,7 @@ import { ThreadDashboardPanel } from "../../fork/dashboard/ThreadDashboardPanel" import type { CiteAssistantText } from "../../fork/dashboard/dashboardCitation"; import { SubThreadsPanel } from "../../fork/subThreads/SubThreadsPanel"; import { WhiteboardPanel } from "../../fork/whiteboard/WhiteboardPanel"; +import { ZulipPanel } from "../../fork/zulip/ZulipPanel"; import type { ComposerImageAttachment, DraftId } from "../../composerDraftStore"; import type { ShortcutMatchContext } from "../../keybindings"; import type { SideChatParentPanel } from "../../lib/sideChatPane"; @@ -236,6 +237,8 @@ export function RightPanelSurfaceContent(props: { ); case "whiteboard": return ; + case "zulip": + return ; case "side-chat": // Not lazy: revealing a suspended tiptap editor tears down its view and crashes the composer. return ( diff --git a/apps/web/src/fork/dashboard/dashboardSurface.ts b/apps/web/src/fork/dashboard/dashboardSurface.ts index aad0f3c71a595..fad64fa8d913a 100644 --- a/apps/web/src/fork/dashboard/dashboardSurface.ts +++ b/apps/web/src/fork/dashboard/dashboardSurface.ts @@ -1,5 +1,5 @@ import type { ScopedThreadRef } from "@t3tools/contracts"; -import { LayoutDashboard, MessageSquareReply, Presentation } from "lucide-react"; +import { LayoutDashboard, MessageSquareReply, MessageSquareText, Presentation } from "lucide-react"; import { createElement } from "react"; import { useStableCallback } from "../../hooks/useStableCallback"; @@ -19,13 +19,15 @@ import { useBoardOfferedFor, useThreadProjectRoot, } from "../whiteboard/role"; +import { isZulipPanelOffered, readZulipPanelOffered, useZulipPanelRole } from "../zulip/zulipPanel"; /** The fork's right-panel tabs. `shortcut` is the built-in menu letter; "" is none. */ export const FORK_SURFACES = { dashboard: { label: "Dashboard", icon: LayoutDashboard, shortcut: "" }, replies: { label: "Replies", icon: MessageSquareReply, shortcut: "" }, whiteboard: { label: "Whiteboard", icon: Presentation, shortcut: "W" }, -} as const satisfies Record; + zulip: { label: "Zulip", icon: MessageSquareText, shortcut: "Z" }, +} as const satisfies Record; type ForkSurfaceKind = keyof typeof FORK_SURFACES; @@ -50,11 +52,12 @@ export const ModeSurfaceIcon = (props: { readonly kind: ForkSurfaceKind }) => /** Whether the thread offers the tab `kind`, read outside React. Upstream tabs always pass. */ export function threadHasModeSurface(threadRef: ScopedThreadRef, kind: string): boolean { if (kind === "whiteboard") return boardOfferedFor(threadRef, readThreadProjectRoot(threadRef)); + if (kind === "zulip") return readZulipPanelOffered(); if (!(kind in FORK_SURFACES)) return true; return modeSurfaces(readThreadDisplay(threadRef)).some((surface) => surface === kind); } -/** The fork's "+" items: the display's Replies and Dashboard, then Whiteboard on a board host. */ +/** The fork's "+" items: the display's Replies and Dashboard, then Whiteboard and Zulip where offered. */ export function useModeSurfaceActions( threadRef: ScopedThreadRef | null, ): ReadonlyArray { @@ -62,6 +65,7 @@ export function useModeSurfaceActions( const boardPanel = isBoardHost(useBoardHostRole()) && isTopWindow(); const projectRoot = useThreadProjectRoot(boardPanel ? threadRef : null); const boardOffered = useBoardOfferedFor(threadRef, projectRoot); + const zulipOffered = isZulipPanelOffered(useZulipPanelRole()); const open = useStableCallback((kind: ForkSurfaceKind) => { if (threadRef !== null) useRightPanelStore.getState().open(threadRef, kind); }); @@ -70,5 +74,6 @@ export function useModeSurfaceActions( ...(boardPanel ? [forkSurfaceAction("whiteboard", boardOffered, () => open("whiteboard"))] : []), + ...(zulipOffered ? [forkSurfaceAction("zulip", true, () => open("zulip"))] : []), ]; } diff --git a/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx b/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx index b01ea066094a6..0efbc84702a1f 100644 --- a/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx +++ b/apps/web/src/fork/rightPanelMenu/RightPanelMenuSettings.tsx @@ -26,6 +26,7 @@ import { import { FORK_SURFACES } from "../dashboard/dashboardSurface"; import { RIGHT_PANEL_SETTINGS_COPY as COPY } from "../forkCopy"; import { isBoardHost, useBoardHostRole } from "../whiteboard/role"; +import { isZulipPanelOffered, useZulipPanelRole } from "../zulip/zulipPanel"; import { parseMenuLayer, RIGHT_PANEL_MENU_ITEM_IDS, @@ -60,6 +61,7 @@ const MENU_ITEM_ROWS = { replies: forkRow("replies"), dashboard: forkRow("dashboard"), whiteboard: forkRow("whiteboard"), + zulip: forkRow("zulip"), } satisfies Record>; const MENU_ITEMS: ReadonlyArray = RIGHT_PANEL_MENU_ITEM_IDS.map((id) => ({ @@ -174,6 +176,7 @@ function MenuItemSettingsRow(props: { export function RightPanelMenuSettingsPanel() { const role = useBoardHostRole(); + const zulipOffered = isZulipPanelOffered(useZulipPanelRole()); const overrides = useClientSettings((settings) => settings.rightPanelMenuOverrides); if (role === "unknown") return null; if (!isBoardHost(role)) return ; @@ -196,7 +199,7 @@ export function RightPanelMenuSettingsPanel() { } > - {MENU_ITEMS.map((item) => ( + {MENU_ITEMS.filter((item) => item.id !== "zulip" || zulipOffered).map((item) => ( Zulip is not available here.

+ ); + } + return ; +} + +function ZulipFrame(props: { readonly url: string }) { + const [generation, setGeneration] = useState(0); + return ( +
+
+ + setGeneration((current) => current + 1)} + /> + } + > + + + {RELOAD} + + + } + /> + } + > + + + {OPEN_IN_NEW_TAB} + +
+