Skip to content

Commit f67eb5b

Browse files
aorwallclaude
andauthored
refactor(web): host the sandbox control in the right panel (pingdotgg#37)
The control landed in the sidebar footer, which pins it to the bottom of the screen — far from the surfaces whose availability it governs. Move it into the right panel's tab bar, beside the tab list, where it sits next to the "Sandbox required" state it resolves. `SandboxedRightPanelTabs` already resolves availability for the surface gating, so it feeds the same `status` view to a `SandboxStatusControl` passed down as `RightPanelTabs`' new `sandboxControl` slot — one query, one atom, no extra RPC. `SidebarSandboxStatus` and its route/draft thread resolution are deleted; the panel is only rendered for an active thread, so there is no threadless case left to guard. The sheet variant of the panel can be as narrow as 20rem, where the pill plus the layout toggles would leave the tab list nothing. `compact` drops the status text there — the indicator, the action and the hover title carry it — and `aria-live` still announces the full label. Co-authored-by: Claude Opus 5 <[email protected]>
1 parent 1d19ca7 commit f67eb5b

5 files changed

Lines changed: 35 additions & 44 deletions

File tree

‎apps/web/src/components/RightPanelTabs.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface RightPanelTabsProps {
5151
filesAvailable: boolean;
5252
surfaceDisabled?: boolean | undefined;
5353
surfaceDisabledReason?: string | undefined;
54+
sandboxControl?: ReactNode;
5455
children: ReactNode;
5556
}
5657

@@ -500,6 +501,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
500501
) : null}
501502
</div>
502503
</ScrollArea>
504+
{props.sandboxControl}
503505
{props.layoutControls}
504506
</div>
505507
<div className="flex min-h-0 flex-1 flex-col">

‎apps/web/src/components/SandboxStatusControl.tsx‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ interface SandboxStatusControlProps {
4545
readonly threadRef: ScopedThreadRef;
4646
readonly status: EnvironmentQueryView<SandboxStatusResult>;
4747
readonly className?: string | undefined;
48+
/**
49+
* Drop the status text and keep only the indicator and its action, for hosts
50+
* too narrow to spare the width. The text moves to the hover title.
51+
*/
52+
readonly compact?: boolean | undefined;
4853
}
4954

5055
function failureMessage(error: unknown): string {
@@ -53,7 +58,12 @@ function failureMessage(error: unknown): string {
5358
: "The sandbox request failed.";
5459
}
5560

56-
export function SandboxStatusControl({ threadRef, status, className }: SandboxStatusControlProps) {
61+
export function SandboxStatusControl({
62+
threadRef,
63+
status,
64+
className,
65+
compact,
66+
}: SandboxStatusControlProps) {
5767
const startSandbox = useAtomCommand(sandboxEnvironment.start, { reportFailure: false });
5868
const stopSandbox = useAtomCommand(sandboxEnvironment.stop, { reportFailure: false });
5969
const [pendingAction, setPendingAction] = useState<"start" | "stop" | null>(null);
@@ -114,6 +124,7 @@ export function SandboxStatusControl({ threadRef, status, className }: SandboxSt
114124
return (
115125
<div
116126
aria-live="polite"
127+
title={compact ? label : undefined}
117128
className={cn(
118129
"flex min-w-0 shrink-0 items-center gap-2 rounded-md border border-border/70 bg-background px-2 py-1 shadow-xs",
119130
tone === "error" && "border-destructive/35 bg-destructive/5",
@@ -129,7 +140,14 @@ export function SandboxStatusControl({ threadRef, status, className }: SandboxSt
129140
) : (
130141
<span className="size-2 shrink-0 rounded-full bg-warning" />
131142
)}
132-
<div className="min-w-0 truncate text-xs font-medium text-foreground">{label}</div>
143+
<div
144+
className={cn(
145+
"min-w-0 truncate text-xs font-medium text-foreground",
146+
compact && "sr-only",
147+
)}
148+
>
149+
{label}
150+
</div>
133151
</div>
134152
{showRetry ? (
135153
<Button size="xs" variant="outline" onClick={status.refresh}>

‎apps/web/src/components/SandboxedRightPanelTabs.tsx‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import type { ScopedThreadRef } from "@t3tools/contracts";
22
import type { ComponentProps } from "react";
33

4+
import { SandboxStatusControl } from "./SandboxStatusControl";
45
import { useSandboxAvailability } from "./sandbox/useSandboxAvailability";
56
import { RightPanelTabs } from "./RightPanelTabs";
67

7-
type SandboxedRightPanelTabsProps = ComponentProps<typeof RightPanelTabs> & {
8+
type SandboxedRightPanelTabsProps = Omit<
9+
ComponentProps<typeof RightPanelTabs>,
10+
"sandboxControl" | "surfaceDisabled" | "surfaceDisabledReason"
11+
> & {
812
readonly threadRef: ScopedThreadRef;
913
};
1014

@@ -16,6 +20,14 @@ export function SandboxedRightPanelTabs({ threadRef, ...props }: SandboxedRightP
1620
{...props}
1721
surfaceDisabled={sandboxAvailability.surfaceDisabled}
1822
surfaceDisabledReason={sandboxAvailability.surfaceDisabledReason}
23+
sandboxControl={
24+
<SandboxStatusControl
25+
threadRef={threadRef}
26+
status={sandboxAvailability.status}
27+
// The sheet is the narrow-viewport panel — the tab list needs the width more.
28+
compact={props.mode === "sheet"}
29+
/>
30+
}
1931
/>
2032
);
2133
}

‎apps/web/src/components/sandbox/SidebarSandboxStatus.tsx‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎apps/web/src/components/sidebar/SidebarChrome.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
SidebarStageBackdrop,
1212
useEnvironmentStageLabel,
1313
} from "../SidebarStageBackdrop";
14-
import { SidebarSandboxStatus } from "../sandbox/SidebarSandboxStatus";
1514
import { Badge } from "../ui/badge";
1615
import {
1716
SidebarFooter,
@@ -98,7 +97,6 @@ export const SidebarChromeFooter = memo(function SidebarChromeFooter() {
9897

9998
return (
10099
<SidebarFooter className="p-[var(--sidebar-content-inset)]">
101-
<SidebarSandboxStatus />
102100
<SidebarProviderUpdatePill />
103101
<SidebarUpdatePill />
104102
<SidebarMenu>

0 commit comments

Comments
 (0)