feat: first-boot compose discovery and adopt-first sidebar (#1600)

* feat: add compose discovery for setup preflight and sidebar empty state

Expose read-only compose discovery via GET /api/stacks/discovery and setup

diagnostics. Replace the blank sidebar with path-aware discovery and move

adopt into a dedicated dialog with a three-tab Create Stack flow.

* test: assert post-setup handoff via sessionStorage read-back

The Setup preflight test spied on Storage.prototype.setItem to check the
post-setup adopt handoff. When the jsdom storage probe fails and the test
harness swaps in its in-memory storage stub (which does not extend Storage),
that stub's setItem never touches Storage.prototype, so the spy records zero
calls and the assertion fails even though the component wrote the value.

Read the value back with sessionStorage.getItem instead, matching how every
other storage test in the suite asserts. This is robust to both the native
jsdom storage and the in-memory fallback.

* fix(setup): surface compose discovery as a preflight check row

Drop the Setup discovery banner and non-working Review button. Show

counts as a pass row in EnvironmentChecks (Setup only) and keep

Enter Sencho as the handoff that opens adopt when candidates exist.

* test(setup): cover zero-count discovery row omission

* fix(stacks): widen adopt scan to any yaml and rename into place

Homelab layouts often use nginx.yml or plex.yml. Surface those for
adopt (except overrides), rename to compose.yaml on move so stacks
register, and reset the confirm UI when a move fails.
This commit is contained in:
Anso
2026-07-10 08:42:52 -04:00
committed by GitHub
parent 7848ce339a
commit ba2e7bded9
26 changed files with 1490 additions and 130 deletions
@@ -1,5 +1,5 @@
import { useRef, useState, type FormEvent, type KeyboardEvent } from 'react';
import { Plus, GitBranch, FileCode2, FolderSearch, Loader2, type LucideIcon } from 'lucide-react';
import { Plus, GitBranch, FileCode2, Loader2, type LucideIcon } from 'lucide-react';
import { Modal, ModalHeader, ModalBody, ModalFooter } from '../ui/modal';
import { Button } from '../ui/button';
import { Input } from '../ui/input';
@@ -8,7 +8,6 @@ import { ScrollArea } from '../ui/scroll-area';
import { Checkbox } from '../ui/checkbox';
import { GitSourceFields, type ApplyMode } from '../stack/GitSourceFields';
import type { GitBrowseResult } from '../stack/GitComposeFilePicker';
import { ImportStackPanel } from './ImportStackPanel';
import { apiFetch } from '@/lib/api';
import { toast } from '@/components/ui/toast-store';
import { useNodes } from '@/context/NodeContext';
@@ -26,15 +25,13 @@ export interface CreateStackDialogProps {
meta?: { mode: CreateMode },
) => void | Promise<void>;
onStacksChanged: () => void | Promise<void>;
// Mode the dialog opens on. The empty-state entry opens directly on 'import';
// the toolbar Create button opens on 'empty'.
initialMode?: CreateMode;
onOpenAdopt?: () => void;
}
export type CreateMode = 'import' | 'empty' | 'git' | 'docker-run';
export type CreateMode = 'empty' | 'git' | 'docker-run';
const MODES: ReadonlyArray<{ id: CreateMode; label: string; icon: LucideIcon }> = [
{ id: 'import', label: 'Import', icon: FolderSearch },
{ id: 'empty', label: 'Empty', icon: Plus },
{ id: 'git', label: 'From Git', icon: GitBranch },
{ id: 'docker-run', label: 'From Docker Run', icon: FileCode2 },
@@ -43,7 +40,7 @@ const MODES: ReadonlyArray<{ id: CreateMode; label: string; icon: LucideIcon }>
const tabId = (m: CreateMode) => `create-stack-tab-${m}`;
const panelId = (m: CreateMode) => `create-stack-panel-${m}`;
export function CreateStackDialog({ open, onOpenChange, onStackCreated, onStacksChanged, initialMode = 'empty' }: CreateStackDialogProps) {
export function CreateStackDialog({ open, onOpenChange, onStackCreated, onStacksChanged, initialMode = 'empty', onOpenAdopt }: CreateStackDialogProps) {
const { activeNode } = useNodes();
const [createMode, setCreateMode] = useState<CreateMode>(initialMode);
// Reset to the requested starting mode each time the dialog opens (empty for
@@ -373,19 +370,10 @@ export function CreateStackDialog({ open, onOpenChange, onStackCreated, onStacks
<ModalHeader
kicker="STACKS · NEW"
title="New stack"
description="Import a compose file you already have, or create one: empty, cloned from a Git repository, or converted from a docker run command."
description="Create a stack from scratch, clone from a Git repository, or convert a docker run command."
/>
<ModeRail mode={createMode} onModeChange={setCreateMode} disabled={busy} />
{createMode === 'import' && (
<div role="tabpanel" id={panelId('import')} aria-labelledby={tabId('import')}>
<ImportStackPanel
onClose={() => onOpenChange(false)}
onImported={() => { void onStacksChanged(); }}
/>
</div>
)}
{createMode === 'empty' && (
<div role="tabpanel" id={panelId('empty')} aria-labelledby={tabId('empty')}>
<form onSubmit={handleEmptyFormSubmit}>
@@ -575,6 +563,20 @@ export function CreateStackDialog({ open, onOpenChange, onStackCreated, onStacks
/>
</div>
)}
{onOpenAdopt ? (
<div className="border-t border-card-border/60 px-4 py-2.5 text-center">
<button
type="button"
onClick={() => {
onOpenChange(false);
onOpenAdopt();
}}
className="font-mono text-[10px] uppercase tracking-[0.14em] text-brand hover:underline"
>
Adopt existing files instead
</button>
</div>
) : null}
</Modal>
);
}
@@ -620,7 +622,7 @@ function ModeRail({
<div
role="tablist"
aria-label="Stack source"
className="grid grid-cols-4 border-b border-card-border/60"
className="grid grid-cols-3 border-b border-card-border/60"
onKeyDown={handleKeyDown}
>
{MODES.map((m, i) => {