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
44 changes: 42 additions & 2 deletions apps/web/src/components/AppSidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type ReactNode,
} from "react";
import { useLocation, useNavigate, useParams } from "@tanstack/react-router";
import { PresentationIcon } from "lucide-react";

import { isElectron } from "../env";
import { getLocalStorageItem, removeLocalStorageItem } from "../hooks/useLocalStorage";
Expand Down Expand Up @@ -55,6 +56,7 @@ import {
useSidebar,
useSidebarVisibility,
} from "./ui/sidebar";
import { Button } from "./ui/button";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";

const MACOS_TRAFFIC_LIGHTS_LEFT_INSET = "var(--desktop-window-controls-inset, 90px)";
Expand All @@ -80,7 +82,25 @@ function readInitialThreadSidebarWidth(): number {
}
}

function SidebarControl() {
// The whiteboard parent page reports whether its board panel is collapsed; asking on mount
// covers the report it sent before this listener existed.
function useWhiteboardBoardHidden() {
const [boardHidden, setBoardHidden] = useState(false);
useEffect(() => {
if (window.parent === window) return;
const receive = (event: MessageEvent) => {
if (event.source === window.parent && event.data?.type === "wb-layout") {
setBoardHidden(event.data.boardHidden === true);
}
};
window.addEventListener("message", receive);
window.parent.postMessage({ type: "wb-layout-get" }, "*");
Comment on lines +92 to +97

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the embedding protocol checklist

The existing run-t3.md embedding checklist says it must remain current for upstream ports, but its parent-window entry still enumerates only wb-project and wb-insert-ref. Without recording the new wb-layout, wb-layout-get, and wb-show-board protocol and collapsed-board control in the affected bullets, a future routine update can silently omit this cross-repository behavior; update the existing documentation rather than leaving the contract discoverable only in this component.

AGENTS.md reference: AGENTS.md:L123-L124

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2d8fcc7: the parent-window bullet in run-t3.md now lists wb-layout-get, wb-layout and wb-show-board, and names AppSidebarLayout.tsx.

return () => window.removeEventListener("message", receive);
}, []);
return boardHidden;
}

function SidebarControl({ boardHidden }: { boardHidden: boolean }) {
const usagePageOpen = useLocation({ select: (location) => location.pathname === "/usage" });
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
const { toggleSidebar } = useSidebar();
Expand Down Expand Up @@ -142,6 +162,18 @@ function SidebarControl() {
className="pointer-events-none fixed left-[var(--workspace-controls-left)] top-[var(--workspace-controls-top)] z-50 ml-px flex h-[var(--workspace-topbar-height)] items-center"
data-sidebar-control=""
>
{boardHidden && (
<div className="pointer-events-auto mr-2 w-18">
<Button
size="sm"
variant="ghost"
onClick={() => window.parent.postMessage({ type: "wb-show-board" }, "*")}
>
<PresentationIcon />
Board
</Button>
</div>
)}
<Tooltip>
<TooltipTrigger
render={
Expand Down Expand Up @@ -238,6 +270,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
const isOnSettings = pathname === "/settings" || pathname.startsWith("/settings/");
const isMacosDesktop = isElectron && isMacPlatform(navigator.platform);
const [sidebarWidth, setSidebarWidth] = useState(readInitialThreadSidebarWidth);
const boardHidden = useWhiteboardBoardHidden();
// Subscribed rather than read once: the clamp must track live window size,
// and a clamped drag ends with an unchanged width, which skips the re-render
// that would otherwise refresh a render-time snapshot.
Expand Down Expand Up @@ -265,6 +298,13 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
...(isMacosDesktop && !isWindowFullscreen
? { "--workspace-controls-left": MACOS_TRAFFIC_LIGHTS_LEFT_INSET }
: {}),
// Header content clears the Board button (w-18 plus mr-2) placed before the sidebar trigger.
...(boardHidden
? {
"--workspace-titlebar-content-left":
"calc(var(--workspace-controls-left) + var(--workspace-titlebar-control-size) + var(--workspace-titlebar-control-gap) + 5rem)",
}
: {}),
} as CSSProperties;

useEffect(() => {
Expand Down Expand Up @@ -344,7 +384,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
<SidebarRail onDoubleClick={resetSidebarWidth} />
</Sidebar>
{children}
<SidebarControl />
<SidebarControl boardHidden={boardHidden} />
<NavigationHistoryShortcuts />
<MainAppLocationTracker />
</SidebarProvider>
Expand Down
2 changes: 1 addition & 1 deletion run-t3.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ This copy differs from upstream T3 Code in the points below. Keep this list curr
- Whiteboard skills for agents. `T3CODE_CLAUDE_PLUGIN_ROOT` is loaded as a local Claude plugin; `T3CODE_CODEX_SKILL_ROOT` is registered with each Codex app-server through `skills/extraRoots/set`. Files: `apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts` (`makeClaudeQueryOptions`, with test), `CodexAdapterV2.ts` (after `initialize`), `apps/server/src/provider/codexLaunchArgs.ts` (`resolveCodexSkillRoot`), `apps/server/src/provider/CodexProvider.ts` (probe client). `run-t3.sh` sets both variables, puts `tools/bin` on `PATH`, and sets `BASH_ENV` to `tools/agent-env.sh`.
- Served under `/chat/`. Files: `apps/web/vite.config.ts` (`base: "/chat/"`), `apps/web/src/router.ts` (`basepath: "/chat"`).
- Whiteboard links. `board://` links in assistant markdown are allowed, rendered with hover and click messages to the parent window (`wb-hover`, `wb-highlight`), and `[label](board://...)` mention chips in the composer show the label and report hover. Files: `apps/web/src/markdown-whiteboard.ts` (with test), `apps/web/src/components/ChatMarkdown.tsx`, `packages/shared/src/markdownPipeline.ts` (`board` href protocol), `apps/web/src/components/ComposerPromptEditorTiptap.tsx`, `packages/shared/src/composerInlineTokens.ts` (board mention token).
- Parent-window messages. The chat posts `wb-project` (workspace root and thread key) when the active thread changes, and inserts a reference into the composer on a `wb-insert-ref` message. The composer never switches to its mobile layout inside the iframe. Files: `apps/web/src/components/ChatView.tsx`, `apps/web/src/components/chat/ChatComposer.tsx`.
- Parent-window messages. 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`. The composer never switches to its mobile layout inside the iframe. Files: `apps/web/src/components/ChatView.tsx`, `apps/web/src/components/chat/ChatComposer.tsx`, `apps/web/src/components/AppSidebarLayout.tsx` (Board button).
- Iframe layout. The sidebar starts closed, and neither the provider-update launch notification nor the nightly mobile beta notice is rendered. Files: `apps/web/src/components/AppSidebarLayout.tsx`, `apps/web/src/routes/__root.tsx`.
- Light by default. Without a stored theme preference the chat starts light instead of following the OS appearance. Files: `apps/web/index.html` (boot script), `apps/web/src/hooks/useTheme.ts` (`DEFAULT_THEME_SNAPSHOT`), with the mirrored tests.
- 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.
Loading