mirror of
https://github.com/hanzo-inc/tabs.git
synced 2026-11-10 03:09:32 +00:00
`Tabs` is the fleet read with the host's bearer, nothing drawn before the registry answers, then the workspace with the plan's stream count. tabs.hanzo.ai draws it, and so do the app at hanzo.ai/tabs and platform.hanzo.ai/tabs; the app's copy rendered the workspace before the first read, so a reader with no saved layout got no pane, and it never passed the stream count. - `useFleet` takes the bearer or a reader of it, asked on every poll and mint, so a session renewed in storage is used without a re-render. - `Workspace` takes `at`, a machine named by the host's address: a pane on it is focused, or a shell on it opens beside the rest. - `createSandbox` read the running sandboxes from api.hanzo.ai whatever origin it was given. - CI runs on GitHub, where hanzo-inc has runners: the checks, the site, and an npm publish when package.json is ahead of the registry.
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
'use client';
|
|
|
|
/**
|
|
* Tabs, whole: the reader's machines read with their token and tiled.
|
|
*
|
|
* Every host draws this and nothing else — tabs.hanzo.ai, the app at
|
|
* hanzo.ai/tabs, platform.hanzo.ai/tabs — so the three agree on when the
|
|
* workspace may open (once the registry has answered, never on an empty list
|
|
* that only means "not read yet"), on what a failed read says, and on the plan's
|
|
* stream count. A host supplies the bearer, where its cloud is, and the ends of
|
|
* the action row.
|
|
*/
|
|
import type { ReactNode } from 'react';
|
|
import { useI18n } from '@hanzo/i18n/react';
|
|
import { SizableText, YStack } from '@hanzo/ui';
|
|
|
|
import { AMBER } from '../lib/panes';
|
|
import { type Token, useFleet } from '../lib/fleet';
|
|
import { Workspace } from './workspace';
|
|
|
|
export function Tabs({
|
|
token,
|
|
origin,
|
|
at,
|
|
start,
|
|
end,
|
|
}: {
|
|
/** The bearer, or how to read it (`useFleet`). */
|
|
token: Token;
|
|
/** The cloud's origin; api.hanzo.ai when not given. */
|
|
origin?: string;
|
|
/** A machine to show, from the host's address. */
|
|
at?: string | null;
|
|
/** The ends of the action row: the host's name for the place, its way out. */
|
|
start?: ReactNode;
|
|
end?: ReactNode;
|
|
}) {
|
|
const { t } = useI18n();
|
|
const fleet = useFleet(token, origin);
|
|
|
|
if (!fleet.read) {
|
|
return (
|
|
<YStack flex={1} minH={0} items="center" justify="center" px="$5" data-slot="tabs">
|
|
<SizableText size="$2" text="center" color={fleet.error ? AMBER : 'var(--text-disabled)'} role={fleet.error ? 'alert' : undefined}>
|
|
{fleet.error
|
|
? t('Your machines could not be read: {why}', { why: fleet.error })
|
|
: t('Reading your machines…')}
|
|
</SizableText>
|
|
</YStack>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<YStack flex={1} minH={0} minW={0} data-slot="tabs">
|
|
<Workspace
|
|
hosts={fleet.hosts}
|
|
mint={fleet.mint}
|
|
streams={fleet.streams}
|
|
onLaunch={fleet.launch}
|
|
at={at}
|
|
start={start}
|
|
end={
|
|
<>
|
|
{fleet.error ? (
|
|
<SizableText size="$1" color={AMBER} numberOfLines={1} ellipsis role="alert">
|
|
{fleet.error}
|
|
</SizableText>
|
|
) : null}
|
|
{end}
|
|
</>
|
|
}
|
|
/>
|
|
</YStack>
|
|
);
|
|
}
|