mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
The sandbox toggle and resources dialog were only reachable from the mobile composer menu. Add SessionSandboxMenu next to the permission toggle on desktop and share the sandbox menu items with the mobile menu.
24 lines
861 B
TypeScript
24 lines
861 B
TypeScript
import type { SessionSandboxResources } from '@opencode-manager/shared/schemas'
|
|
import type { useSandboxToggle } from '@/hooks/useSandboxToggle'
|
|
|
|
export type SandboxToggleState = ReturnType<typeof useSandboxToggle>
|
|
|
|
export function shouldShowSandboxResources(sandbox: SandboxToggleState): boolean {
|
|
return (
|
|
sandbox.available &&
|
|
sandbox.isSandboxed &&
|
|
sandbox.lockedReason !== 'child' &&
|
|
sandbox.effectiveResources !== undefined
|
|
)
|
|
}
|
|
|
|
export function formatSandboxMemory(memoryMib: number): string {
|
|
const gib = memoryMib / 1024
|
|
return Number.isInteger(gib) ? String(gib) : String(Number(gib.toFixed(1)))
|
|
}
|
|
|
|
export function formatSandboxResources(resources: SessionSandboxResources): string {
|
|
const cpus = `${resources.cpus} CPU${resources.cpus === 1 ? '' : 's'}`
|
|
return `${cpus} · ${formatSandboxMemory(resources.memoryMib)} GiB`
|
|
}
|