Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

fix(console): balance Box detail layout and Terminal empty state (#3029)

Mandafd7cb7ab72d8
diff --git a/apps/dashboard/README.md b/apps/dashboard/README.md
index 87a407a89..a8871f3d2 100644
--- a/apps/dashboard/README.md
+++ b/apps/dashboard/README.md
@@ -1567,3 +1567,24 @@ Run the mock Dashboard and open `/dashboard/welcome?preview=trial-onboarding`. T
This entry requires development mode and `VITE_ENABLE_MOCKING=true`; the prototype module is excluded from production builds. It never invokes payment APIs or writes simulated subscription results to the Billing cache. Prices and plan concurrency reuse the current presentation source; no trial quota is inferred from bonus credits. Shipping this flow needs a server-confirmed eligibility/price quote and a mutation that rejects eligibility changes instead of silently charging. Registration/authentication and default Welcome remain unchanged.
The choice step also offers “Explore console — no card required”, completing Welcome without verifying a card or activating a plan. “Have a coupon? Redeem code” expands an independent form: use `ACME50` for simulated success, an empty code for required-field feedback, or another code for invalid/expired feedback. Successful trial confirmation and coupon redemption complete Welcome immediately and enter Quickstart, without a separate success screen or another click. Coupon balances are not persisted to the shared mock wallet. Both alternative paths use existing Welcome completion and lead to Quickstart.
+
+### Box detail workspace sizing
+
+Overview and Terminal share the available workspace width and page gutters, so
+the return link, title, actions and tabs stay anchored when switching views.
+Overview uses a responsive two-column grid with adjacent field labels and values.
+Only a running Box reserves a viewport-height terminal shell.
+The existing terminal ResizeObserver refits rows and columns without replacing
+the session, including when navigation is expanded or the viewport changes.
+
+A stopped Box shows a compact bordered panel with guidance and Start Box, replacing
+the header Start in this view. The action uses the existing permission check and
+start mutation. The action stays disabled through the post-start detail refresh; starting waits for the Box state, and
+a failed start retains a local notice alongside the existing API error notification.
+Startup progress uses a polite status region; failures use a separate alert.
+Read-only members receive permission guidance. Overview keeps its header Start.
+
+For mock layout review, open `/dashboard/boxes/mock-box-stopped` and its
+`/terminal` route. Compare desktop, ultrawide, narrow and zoom-equivalent CSS
+viewports with expanded and collapsed navigation. Mock fixtures verify layout
+and action wiring, not guest connectivity.
diff --git a/apps/dashboard/review-assets/bui-2035/README.md b/apps/dashboard/review-assets/bui-2035/README.md
new file mode 100644
index 000000000..4f8a0fd2f
--- /dev/null
+++ b/apps/dashboard/review-assets/bui-2035/README.md
@@ -0,0 +1,11 @@
+# Box detail layout review
+
+Synthetic mock fixtures captured at 2560 × 1440 (wide) and 390 × 900
+(narrow). These images verify layout, not guest terminal connectivity.
+
+- [Responsive Overview](overview-wide.png)
+- [Stopped Terminal with Start Box](terminal-stopped-wide.png)
+- [Narrow Terminal](terminal-narrow.png)
+
+See [workspace sizing](../../README.md#box-detail-workspace-sizing) for the
+behavior and mock routes.
diff --git a/apps/dashboard/review-assets/bui-2035/overview-wide.png b/apps/dashboard/review-assets/bui-2035/overview-wide.png
new file mode 100644
index 000000000..e1267df86
Binary files /dev/null and b/apps/dashboard/review-assets/bui-2035/overview-wide.png differ
diff --git a/apps/dashboard/review-assets/bui-2035/terminal-narrow.png b/apps/dashboard/review-assets/bui-2035/terminal-narrow.png
new file mode 100644
index 000000000..383bbc025
Binary files /dev/null and b/apps/dashboard/review-assets/bui-2035/terminal-narrow.png differ
diff --git a/apps/dashboard/review-assets/bui-2035/terminal-stopped-wide.png b/apps/dashboard/review-assets/bui-2035/terminal-stopped-wide.png
new file mode 100644
index 000000000..317f20bb4
Binary files /dev/null and b/apps/dashboard/review-assets/bui-2035/terminal-stopped-wide.png differ
diff --git a/apps/dashboard/src/components/boxes/BoxDetails.tsx b/apps/dashboard/src/components/boxes/BoxDetails.tsx
index f31802ea5..225ae4ca4 100644
--- a/apps/dashboard/src/components/boxes/BoxDetails.tsx
+++ b/apps/dashboard/src/components/boxes/BoxDetails.tsx
@@ -80,6 +80,8 @@ function BoxDetailsPage({ page }: { page: 'overview' | 'terminal' }) {
useSelectedOrganization()
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
+ const [startFailed, setStartFailed] = useState(false)
+ const [startInProgress, setStartInProgress] = useState(false)
const [onboardingProgress, setOnboardingProgress] = useState<OnboardingProgress>(() => readOnboardingProgress(userId))
const [copiedName, setCopiedName] = useState(false)
const [sshRefreshSignal, setSshRefreshSignal] = useState(0)
@@ -133,14 +135,20 @@ function BoxDetailsPage({ page }: { page: 'overview' | 'terminal' }) {
const transitioning = box ? isTransitioning(box) : false
const anyMutating =
startMutation.isPending || stopMutation.isPending || recoverMutation.isPending || deleteMutation.isPending
- const actionsDisabled = anyMutating || transitioning
+ const actionsDisabled = anyMutating || transitioning || startInProgress
+
+ useEffect(() => setStartFailed(false), [box?.state])
const handleStart = async () => {
- if (!box) return
+ if (!box || !writePermitted || !isStartable(box) || actionsDisabled) return
+ setStartFailed(false)
+ setStartInProgress(true)
try {
await startMutation.mutateAsync({ boxId: box.id, detailRef: boxId })
+ await refetch()
toast.success('Box started')
} catch (error) {
+ setStartFailed(true)
handleApiError(error, 'Failed to start box', {
action:
error instanceof OrganizationSuspendedError &&
@@ -151,6 +159,8 @@ function BoxDetailsPage({ page }: { page: 'overview' | 'terminal' }) {
</Button>
) : undefined,
})
+ } finally {
+ setStartInProgress(false)
}
}
@@ -210,8 +220,8 @@ function BoxDetailsPage({ page }: { page: 'overview' | 'terminal' }) {
return (
<div
className={cn(
- 'page-container flex max-w-[1232px] min-w-0 flex-col gap-3 pb-6 pt-4 font-sans text-body',
- page === 'terminal'
+ 'page-container flex min-w-0 flex-col gap-3 pb-6 pt-4 font-sans text-body',
+ page === 'terminal' && box && isStoppable(box)
? 'h-[var(--app-content-height,calc(100svh_-_60px))] min-h-[640px]'
: 'min-h-[var(--app-content-height,calc(100svh_-_60px))]',
)}
@@ -286,7 +296,7 @@ function BoxDetailsPage({ page }: { page: 'overview' | 'terminal' }) {
<RotateCcw className="size-[14px]" /> Recover
</Button>
)}
- {writePermitted && isStartable(box) && (
+ {page !== 'terminal' && writePermitted && isStartable(box) && (
<Button variant="outline" type="button" onClick={handleStart} disabled={actionsDisabled}>
<Play className="size-[14px]" /> Start
</Button>
@@ -354,8 +364,19 @@ function BoxDetailsPage({ page }: { page: 'overview' | 'terminal' }) {
<BoxPageNavigation boxId={boxId ?? box.id} current={page} />
{page === 'terminal' ? (
- <div className="flex min-h-[360px] min-w-0 flex-1 flex-col overflow-hidden border border-border/60">
- <BoxTerminalSession box={box} />
+ <div
+ className={cn(
+ 'flex min-w-0 flex-col',
+ isStoppable(box) && 'min-h-[360px] flex-1 overflow-hidden border border-border/60',
+ )}
+ >
+ <BoxTerminalSession
+ box={box}
+ onStart={handleStart}
+ startDisabled={actionsDisabled}
+ starting={startMutation.isPending || startInProgress}
+ startFailed={startFailed}
+ />
</div>
) : (
<BoxOverview box={box} canManage={writePermitted} sshStatusRef={setSshStatusContainer} />
diff --git a/apps/dashboard/src/components/boxes/BoxDetailsNavigation.test.tsx b/apps/dashboard/src/components/boxes/BoxDetailsNavigation.test.tsx
index cfe80d653..3dadb40ed 100644
--- a/apps/dashboard/src/components/boxes/BoxDetailsNavigation.test.tsx
+++ b/apps/dashboard/src/components/boxes/BoxDetailsNavigation.test.tsx
@@ -136,6 +136,7 @@ describe('BoxTerminal page', () => {
mocks.writable = true
mocks.pending = false
mocks.start.mockResolvedValue(undefined)
+ mocks.refetch.mockResolvedValue(undefined)
const host = document.createElement('div')
document.body.appendChild(host)
root = createRoot(host)
@@ -241,8 +242,9 @@ describe('BoxTerminal page', () => {
it('starts a stopped box through the existing mutation', async () => {
mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
await renderPage()
- const start = buttonNamed('Start')
+ const start = buttonNamed('Start Box')
await act(async () => start.click())
+ expect(start.closest('[data-slot="empty"]')).not.toBeNull()
expect(mocks.start).toHaveBeenCalledWith({ boxId: 'box-1', detailRef: 'box-1' })
expect(mocks.terminalMounts).not.toHaveBeenCalled()
})
@@ -251,12 +253,103 @@ describe('BoxTerminal page', () => {
mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
mocks.pending = true
await renderPage()
- const start = buttonNamed('Start')
+ const start = buttonNamed('Start Box')
expect(start.disabled).toBe(true)
await act(async () => start.click())
expect(mocks.start).not.toHaveBeenCalled()
})
+ it('keeps a failed start actionable and connects only after the Box is running', async () => {
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ mocks.start.mockRejectedValueOnce(new Error('Unavailable'))
+ await renderPage()
+ await act(async () => buttonNamed('Start Box').click())
+ expect(document.querySelector('[role="alert"]')?.textContent).toContain('Could not start')
+ expect(mocks.terminalMounts).not.toHaveBeenCalled()
+ await act(async () => buttonNamed('Start Box').click())
+ expect(mocks.start).toHaveBeenCalledTimes(2)
+ expect(document.querySelector('[role="alert"]')).toBeNull()
+ mocks.box = { ...mocks.box, state: BoxState.STARTING } as Box
+ await renderPage()
+ expect(document.body.textContent).toContain('Starting Box…')
+ expect(mocks.terminalMounts).not.toHaveBeenCalled()
+ mocks.box = { ...mocks.box, state: BoxState.STARTED } as Box
+ await renderPage()
+ expect(mocks.terminalMounts).toHaveBeenCalledOnce()
+ })
+
+ it.each([BoxState.STOPPING, BoxState.CREATING, BoxState.ERROR])(
+ 'keeps unavailable terminal states non-actionable: %s',
+ async (state) => {
+ mocks.box = { ...mocks.box, state } as Box
+ await renderPage()
+ expect(document.body.textContent).toContain('The terminal is available when this Box is running.')
+ expect(
+ [...document.querySelectorAll('button')].some((button) => button.textContent?.trim() === 'Start Box'),
+ ).toBe(false)
+ expect(mocks.start).not.toHaveBeenCalled()
+ expect(mocks.terminalMounts).not.toHaveBeenCalled()
+ },
+ )
+
+ it('clears a failed-start notice when an external state update starts the Box', async () => {
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ mocks.start.mockRejectedValueOnce(new Error('Unavailable'))
+ await renderPage()
+ await act(async () => buttonNamed('Start Box').click())
+ expect(document.querySelector('[role="alert"]')).not.toBeNull()
+ mocks.box = { ...mocks.box, state: BoxState.STARTING } as Box
+ await renderPage()
+ expect(document.querySelector('[role="alert"]')).toBeNull()
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ await renderPage()
+ expect(document.querySelector('[role="alert"]')).toBeNull()
+ expect(buttonNamed('Start Box').disabled).toBe(false)
+ })
+
+ it('announces terminal startup without a busy ancestor suppressing the status', async () => {
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ await renderPage()
+ const status = document.querySelector('[data-slot="empty-title"][role="status"]')
+ expect(status?.textContent).toBe('Box is not running')
+ mocks.pending = true
+ await renderPage()
+ expect(status?.textContent).toBe('Starting Box…')
+ expect(status?.closest('[aria-busy="true"]')).toBeNull()
+ expect(buttonNamed('Start Box').disabled).toBe(true)
+ })
+
+ it('keeps an accepted start pending until detail refresh completes', async () => {
+ let finishRefresh!: () => void
+ mocks.refetch.mockReturnValue(
+ new Promise<void>((resolve) => {
+ finishRefresh = resolve
+ }),
+ )
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ await renderPage()
+ await act(async () => buttonNamed('Start Box').click())
+ expect(mocks.pending).toBe(false)
+ expect(document.querySelector('[role="status"]')?.textContent).toBe('Starting Box…')
+ expect(buttonNamed('Start Box').disabled).toBe(true)
+ await act(async () => buttonNamed('Start Box').click())
+ expect(mocks.start).toHaveBeenCalledOnce()
+ expect(mocks.refetch).toHaveBeenCalledOnce()
+ mocks.box = { ...mocks.box, state: BoxState.STARTING } as Box
+ await act(async () => finishRefresh())
+ await renderPage()
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ await renderPage()
+ expect(buttonNamed('Start Box').disabled).toBe(false)
+ })
+
+ it('retains the Overview start action', async () => {
+ mocks.box = { ...mocks.box, state: BoxState.STOPPED } as Box
+ await renderPage('overview')
+ await act(async () => buttonNamed('Start').click())
+ expect(mocks.start).toHaveBeenCalledWith({ boxId: 'box-1', detailRef: 'box-1' })
+ })
+
it.each(['read-only', 'starting', 'loading', 'missing'] as const)(
'does not start a shell or offer Start for %s',
async (state) => {
@@ -272,9 +365,11 @@ describe('BoxTerminal page', () => {
}
await renderPage()
expect(mocks.terminalMounts).not.toHaveBeenCalled()
- expect([...document.querySelectorAll('button')].some((button) => button.textContent?.trim() === 'Start')).toBe(
- false,
- )
+ expect(
+ [...document.querySelectorAll('button')].some((button) =>
+ ['Start', 'Start Box'].includes(button.textContent?.trim() ?? ''),
+ ),
+ ).toBe(false)
if (state === 'loading' || state === 'missing') {
expect(document.querySelector('nav[aria-label="Box pages"]')).toBeNull()
} else {
diff --git a/apps/dashboard/src/components/boxes/BoxTerminalSession.tsx b/apps/dashboard/src/components/boxes/BoxTerminalSession.tsx
index 9e65693af..57e4e4abe 100644
--- a/apps/dashboard/src/components/boxes/BoxTerminalSession.tsx
+++ b/apps/dashboard/src/components/boxes/BoxTerminalSession.tsx
@@ -3,37 +3,65 @@
* SPDX-License-Identifier: AGPL-3.0
*/
+import { Button } from '@/components/ui/button'
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
import { useSelectedOrganization } from '@/hooks/useSelectedOrganization'
import { isStartable, isStoppable } from '@/lib/utils/box'
-import { Box, OrganizationRolePermissionsEnum } from '@boxlite-ai/api-client'
-import { TerminalSquare } from '@/components/ui/icon'
+import { Box, BoxState, OrganizationRolePermissionsEnum } from '@boxlite-ai/api-client'
+import { Play, RefreshCw, TerminalSquare } from '@/components/ui/icon'
import { BoxTerminal } from './BoxTerminal'
import { getBoxDisplayName } from '@/lib/box-identity'
-export function BoxTerminalSession({ box }: { box: Box }) {
+export function BoxTerminalSession({
+ box,
+ onStart,
+ startDisabled,
+ starting,
+ startFailed,
+}: {
+ box: Box
+ onStart: () => Promise<void>
+ startDisabled: boolean
+ starting: boolean
+ startFailed: boolean
+}) {
const running = isStoppable(box)
const { authenticatedUserHasPermission } = useSelectedOrganization()
const writePermitted = authenticatedUserHasPermission(OrganizationRolePermissionsEnum.WRITE_BOXES)
if (!running) {
+ const waitingForStart = starting || box.state === BoxState.STARTING
return (
- <div className="flex-1 flex flex-col p-2 sm:p-4">
- <div className="flex-1 min-h-0 flex">
- <Empty className="border-0 bg-transparent">
- <EmptyHeader>
- <EmptyMedia>
- <TerminalSquare className="size-9 text-muted-foreground" />
- </EmptyMedia>
- <EmptyTitle>Box is not running</EmptyTitle>
- <EmptyDescription>
- {writePermitted && isStartable(box)
- ? 'Use Start above to open a terminal.'
- : 'The terminal is available when this Box is running.'}
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- </div>
- </div>
+ <Empty className="flex-none border border-solid border-border/60 bg-background py-12">
+ <EmptyHeader>
+ <EmptyMedia>
+ {waitingForStart ? (
+ <RefreshCw className="size-9 animate-spin text-muted-foreground" />
+ ) : (
+ <TerminalSquare className="size-9 text-muted-foreground" />
+ )}
+ </EmptyMedia>
+ <EmptyTitle role="status">{waitingForStart ? 'Starting Box…' : 'Box is not running'}</EmptyTitle>
+ <EmptyDescription>
+ {waitingForStart
+ ? 'The terminal will connect when this Box is running.'
+ : isStartable(box)
+ ? writePermitted
+ ? 'Start this Box to use the terminal.'
+ : 'Ask an organization member with permission to start this Box.'
+ : 'The terminal is available when this Box is running.'}
+ </EmptyDescription>
+ </EmptyHeader>
+ {writePermitted && isStartable(box) && (
+ <Button onClick={onStart} disabled={startDisabled}>
+ <Play className="size-4" /> Start Box
+ </Button>
+ )}
+ {startFailed && !waitingForStart && (
+ <p role="alert" className="max-w-sm text-body text-destructive">
+ Could not start this Box. Check the error notification for details, then try again.
+ </p>
+ )}
+ </Empty>
)
}