cbe9e5b294
* chore(desktop): literal comments in the guide script and runbooks Comment-only change to onboarding-script.ts and setup-profile.ts. The module headers now state the purpose and the constraints that shaped each file. The notes beside the runbook strings keep one fact per sentence, or are deleted when the string beside them says the same thing. The runbook text, the persona, the option pills and the SOUL text are unchanged. Both versions transpile to identical output with comments removed. * chore(desktop): literal comments in the guide chat cards and stores Comment-only change to the guided chat's cards, directive dispatcher, option catalog, assembly module and chip. Metaphor and personification are replaced by the name of the atom, effect or CSS property they stood for. Comments that restate the code are deleted. Two stale facts are corrected in place: the mini layout trees point at app/contrib/layout-presets.ts, and the skip button sets the onboarding phase to skipped rather than done. One comment line in cards/frame.tsx from bb/connector-ui-e2e-v2 loses a metaphor and an em dash; its fact is unchanged. * chore(desktop): literal comments in the handoff and first build Comment-only change to the handoff wiring, the kickoff, the receipt store, the first-build check-ins, the handoff tour, the connector rows and the machine profile store. Every kept comment names the caller, the constraint or the defect it prevents. The claim that the tour never throws is removed: the function can reject and its caller does not catch. Five comment blocks in connector-tool.tsx written on bb/connector-ui-e2e-v2 lose personification, dramatic capitals and em dashes. Every fact in them stays, and no block moves. * chore(desktop): literal comments in the intro reveal Comment-only change to the intro reveal's clock, timeline, cube renderer, sound, scenes, store and README. Animation comments now name the actual ramp, easing or offset with its number. Four comments that contradicted the code are corrected: the first texture slot opens at 3700 ms, the tear settles from 1 to 0 over 460 ms, the typing weight delays the character it sits on, and INTRO_EXIT_MS is wall time in index.tsx but score time in the overlay. * chore(desktop): literal comments in the Electron onboarding windows Comment-only change to the window growth geometry and the two onboarding windows. The 768 px floor keeps its one fact: the floor uses Math.ceil where the deltas round, because rounding 906.24 DIP down leaves the media query false. The comment that placed the CSS-pixel to DIP conversion at getBounds now points at growWindowBounds, where it happens. * chore(gateway): literal docstrings in the onboarding RPCs and the tour tool Docstring and comment-only change. The module summaries state what each module does and where authorization comes from, without contrast pairs. The tool descriptions the model reads are unchanged. Two words in the tour tool's module docstring lose personification; the rest of that docstring is as it was. ast.dump of both versions, with docstrings stripped, is identical for all three files. * chore(desktop): literal punctuation in the relaunch and film-end notes Comment-only change to four lines that bb/connector-ui-e2e-v2 added to the boot gate, the gate store and the intro gate. Each em dash becomes a colon, a full stop or a pair of parentheses; one emphasis capital is lowercased. The facts in the notes are unchanged.
140 lines
3.6 KiB
TypeScript
140 lines
3.6 KiB
TypeScript
/** Machine facts load before the runbook is built so a new computer or a Spark can lead with machine setup as
|
|
* the first task. */
|
|
|
|
import { atom } from 'nanostores'
|
|
|
|
import type { DesktopMachineProfile } from '@/global'
|
|
|
|
/** 21 days leaves time to finish setup without counting a daily-use machine as new. */
|
|
const NEW_MACHINE_DAYS = 21
|
|
|
|
export const $machine = atom<DesktopMachineProfile | null>(null)
|
|
|
|
export async function loadMachineProfile(): Promise<void> {
|
|
if ($machine.get()) {
|
|
return
|
|
}
|
|
|
|
const profile = await window.hermesDesktop?.getMachineProfile?.().catch(() => null)
|
|
|
|
if (profile) {
|
|
$machine.set(profile)
|
|
}
|
|
}
|
|
|
|
/** An unknown age counts as not new. Machine setup is still offered; age makes it lead only when the age is
|
|
* known and within NEW_MACHINE_DAYS. */
|
|
export function machineLooksNew(): boolean {
|
|
const age = $machine.get()?.ageDays
|
|
|
|
return age != null && age <= NEW_MACHINE_DAYS
|
|
}
|
|
|
|
/** Generic login names that are not a person's name. A short handle such as 'akp' is still usable. */
|
|
const NON_NAME_USERNAMES = new Set([
|
|
'admin',
|
|
'administrator',
|
|
'default',
|
|
'guest',
|
|
'me',
|
|
'owner',
|
|
'root',
|
|
'test',
|
|
'user'
|
|
])
|
|
|
|
/** The login handle is only a suggestion; the user still chooses their name.
|
|
* Null means the guide asks without a default. */
|
|
export function machineUserName(): string | null {
|
|
const raw = ($machine.get()?.username ?? '').trim()
|
|
|
|
if (raw.length < 2 || raw.length > 20) {
|
|
return null
|
|
}
|
|
|
|
return NON_NAME_USERNAMES.has(raw.toLowerCase()) ? null : raw
|
|
}
|
|
|
|
/** Names the OS language for the model, independent of the UI's bundled locales. Returns null for English and
|
|
* for a missing or invalid tag, which need no language instruction. */
|
|
export function machineLanguageName(): string | null {
|
|
const tag = ($machine.get()?.locale ?? '').trim()
|
|
|
|
if (!tag || /^en\b/i.test(tag)) {
|
|
return null
|
|
}
|
|
|
|
try {
|
|
const name = new Intl.DisplayNames(['en'], { fallback: 'code', type: 'language' }).of(tag)
|
|
|
|
return name && name.toLowerCase() !== 'english' ? name : null
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
/** Recognize RTX Sparks by platform/architecture/GPU and DGX Sparks by model.
|
|
* Device-tree underscores separate words: real units report NVIDIA_DGX_Spark. */
|
|
export function machineIsSpark(): boolean {
|
|
const profile = $machine.get()
|
|
|
|
if (!profile) {
|
|
return false
|
|
}
|
|
|
|
const rtx = profile.platform === 'win32' && profile.arch === 'arm64' && profile.nvidia
|
|
const dgx = /\b(dgx|spark|gb10)\b/i.test(profile.model.replace(/_/g, ' '))
|
|
|
|
return rtx || dgx
|
|
}
|
|
|
|
/** True when machine setup should be the only first task shown, with the other options behind one more tap. */
|
|
export function machineSetupLeads(): boolean {
|
|
return machineIsSpark() || machineLooksNew()
|
|
}
|
|
|
|
export function machineKind(): string {
|
|
if (machineIsSpark()) {
|
|
return 'Spark'
|
|
}
|
|
|
|
switch ($machine.get()?.platform) {
|
|
case 'darwin':
|
|
return 'Mac'
|
|
|
|
case 'win32':
|
|
return 'PC'
|
|
|
|
default:
|
|
return 'computer'
|
|
}
|
|
}
|
|
|
|
/** The age comes first in the description because a new machine needs setup work that a daily-use machine may
|
|
* already have done. */
|
|
export function machineDescription(): string {
|
|
const profile = $machine.get()
|
|
|
|
if (!profile) {
|
|
return ''
|
|
}
|
|
|
|
return [
|
|
machineLooksNew() ? `set up ${daysAgo(profile.ageDays)}` : '',
|
|
machineIsSpark() ? 'an NVIDIA Spark' : profile.nvidia ? 'has an NVIDIA GPU' : '',
|
|
profile.model,
|
|
`${profile.platform} ${profile.release}`,
|
|
profile.arch
|
|
]
|
|
.filter(Boolean)
|
|
.join(', ')
|
|
}
|
|
|
|
function daysAgo(days: null | number): string {
|
|
if (days === 0) {
|
|
return 'today'
|
|
}
|
|
|
|
return days === 1 ? 'yesterday' : `${days} days ago`
|
|
}
|