Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Get started: bring your bots, and import several files at once (#449)

Oleksandr Ivanchenkoc57ad14a497e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fe2a1ad2..3cbeb450 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## Unreleased
+### Added
+- **Get started offers to bring your bots.** Step 3, "Pick a team", has a new "Bring your bots" tile next to "Keep the starter bots". It opens the same importer as Space settings › Import bots, so you can bring a bot from Grok Bot, ChatGPT or Claude, or from a file, and check a preview first. A finished import completes step 3. Closing the importer without importing leaves step 3 as it was.
+- **Import several bots at once.** The importer's "Upload a file" now takes several files in one pick or drop, for example every Grok Bot export you have. You don't need to zip them yourself. kwant packs them into one zip in your browser and shows one preview with every bot, plus the names of any files it couldn't read. Picks are limited to 500 files and 20 MB in all, and a zip can only be imported on its own.
+
### Changed
- **Dev mode reviews only fresh work.** A branch or PR gets a review card only if it moved in the last 7 days, so old branches no longer fill the desk or spend model calls. Cards on branches that went quiet go stale, and a new push brings a branch back. The newest branches are reviewed first, and Dev mode's status says how many old ones it skipped. A card that couldn't read a file now says "Couldn't read N files (no diff available)" instead of "(no diff from GitHub)". A type change (a symlink turned into a file) no longer leaves every file in the change unread.
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index a6830c44..5780efb4 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -3396,6 +3396,14 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
teams: teams.length,
started: getStartedWasStarted(space.id),
});
+ // New bots, teams and their team chats after an import (Space settings or Get started).
+ const reloadAfterImport = () => {
+ refreshRoster();
+ fetch('/api/channels')
+ .then((r) => (r.ok ? r.json() : null))
+ .then((c) => Array.isArray(c) && setChannels(c))
+ .catch(() => undefined);
+ };
const getStartedCard =
loaded && (!openCtx || messagesLoadedFor === openCtx) && kwants.length > 0 && isGeneral && getStartedEligible ? (
<GetStarted
@@ -3404,6 +3412,8 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
engines={engines.engines}
reloadEngines={engines.reload}
onDismissed={() => undefined}
+ spaceName={space.name}
+ onImported={reloadAfterImport}
/>
) : null;
const setupChecklist = (
@@ -4097,14 +4107,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
routineFocus={routineFocus}
isPhone={isPhone}
onApprovalsChanged={refreshRoster}
- onImported={() => {
- // New bots, teams and their team chats.
- refreshRoster();
- fetch('/api/channels')
- .then((r) => (r.ok ? r.json() : null))
- .then((c) => Array.isArray(c) && setChannels(c))
- .catch(() => undefined);
- }}
+ onImported={reloadAfterImport}
/>
)}
diff --git a/frontend/src/components/GetStarted.tsx b/frontend/src/components/GetStarted.tsx
index 5aee52b9..fda705ef 100644
--- a/frontend/src/components/GetStarted.tsx
+++ b/frontend/src/components/GetStarted.tsx
@@ -8,6 +8,7 @@ import { ModernAvatar } from './ModernAvatar';
import { TemplateGlyph } from './TeamPreviewSheet';
import { NewKeyAccountForm } from './EngineAccounts';
import { useReadyTeams } from './ReadyTeams';
+import { ImportDialog } from './ImportDialog';
import type { WelcomeBot } from './FirstRunWelcome';
import { useMedia } from '../useMedia';
import { PHONE_QUERY } from '../layout';
@@ -34,6 +35,7 @@ import {
heroText,
installFailView,
installable,
+ isImported,
isKept,
isLive,
isSignInUrl,
@@ -750,8 +752,26 @@ const KeyPanel: React.FC<{ phone: boolean; onAdded: () => void }> = ({ phone, on
// ------------------------------------------------------------------ step 3: pick a team
-const TeamStep: React.FC<{ phone: boolean; onKeep: () => void; onPicked: () => void }> = ({ phone, onKeep, onPicked }) => {
+const TeamStep: React.FC<{
+ phone: boolean;
+ spaceName: string;
+ onKeep: () => void;
+ onPicked: () => void;
+ /** After the import dialog closes with at least one import done: step 3 is done. */
+ onImported: () => void;
+ /** Each Import or Undo inside the dialog, so the sidebar loads the new bots. */
+ onImportChanged?: () => void;
+}> = ({ phone, spaceName, onKeep, onPicked, onImported, onImportChanged }) => {
const rt = useReadyTeams();
+ const [importing, setImporting] = useState(false);
+ const imported = useRef(false);
+ const importTile = useRef<HTMLButtonElement>(null);
+ const closeImport = () => {
+ setImporting(false);
+ // An import that went in (even if undone in the dialog) counts; Cancel or Close leaves step 3 as it was.
+ if (imported.current) onImported();
+ else window.setTimeout(() => importTile.current?.focus(), 0);
+ };
const templates = rt?.available ? (rt.templates ?? []) : [];
const tile = `w-full rounded-xl border text-left ${phone ? 'min-h-16 p-3' : 'p-3'} ${FOCUS}`;
return (
@@ -795,7 +815,37 @@ const TeamStep: React.FC<{ phone: boolean; onKeep: () => void; onPicked: () => v
</span>
</button>
</li>
+ <li>
+ <button
+ ref={importTile}
+ type="button"
+ data-import-bots
+ aria-haspopup="dialog"
+ aria-label="Bring your bots: from Grok Bot, ChatGPT or Claude, or from a file. You check a preview first. Import"
+ onClick={() => {
+ imported.current = false;
+ setImporting(true);
+ }}
+ className={`${tile} h-full flex flex-col gap-1 border-dashed border-zinc-600 bg-transparent hover:border-zinc-500`}
+ >
+ <span className="text-sm font-semibold text-zinc-100">Bring your bots</span>
+ <span className="text-[12.5px] leading-[18px] text-zinc-300">From Grok Bot, ChatGPT or Claude, or from a file. You check a preview first.</span>
+ <span className="mt-auto text-right text-xs text-sky-300" aria-hidden="true">
+ Import ›
+ </span>
+ </button>
+ </li>
</ul>
+ {importing && (
+ <ImportDialog
+ spaceName={spaceName}
+ onClose={closeImport}
+ onChanged={() => {
+ imported.current = true;
+ onImportChanged?.();
+ }}
+ />
+ )}
</div>
);
};
@@ -813,9 +863,13 @@ export interface GetStartedProps {
loginApiOverride?: LoginApi;
/** For tests and shots: the address it's opened on. */
hostOverride?: string | null;
+ /** The space's name, for the import dialog's title. */
+ spaceName?: string;
+ /** After an Import or Undo from "Bring your bots": new bots, teams and team chats. */
+ onImported?: () => void;
}
-export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, reloadEngines, onDismissed, loginApiOverride, hostOverride }) => {
+export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, reloadEngines, onDismissed, loginApiOverride, hostOverride, spaceName, onImported }) => {
const api = loginApiOverride ?? defaultLoginApi;
const phone = useMedia(PHONE_QUERY);
useStartVersion();
@@ -831,6 +885,7 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
const [resumed] = useState(() => !!chosen && !(engines && tileStatus(engines, chosen) === 'signed_in'));
const v: StepsView = stepsView({ engines, chosen, teamEarly, changing });
const kept = isKept(space);
+ const importedHere = isImported(space);
const titleId = useId();
const stepIds = [useId(), useId(), useId()];
const cardRef = useRef<HTMLElement>(null);
@@ -892,6 +947,13 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
onDismissed();
} else markStarted(space, 'kept');
};
+ // "Bring your bots": like Keep, the card goes once step 2 is done; before that step 3 reads done.
+ const importedBots = () => {
+ if (v.done2) {
+ dismiss(space);
+ onDismissed();
+ } else markStarted(space, 'imported');
+ };
// §13: focus doesn't jump unless it was inside the step that closed; then it goes to the new heading.
const lastOpen = useRef(v.open);
@@ -906,7 +968,7 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
const name = choice ? choiceName(choice) : '';
const stepTitle2 = choice === 'key' ? 'Add your key' : 'Sign in';
const slow = !!track && track.state === 'running' && Date.now() - track.startedAt >= SLOW_S * 1000;
- const done3 = kept;
+ const done3 = kept || importedHere;
const row = phone ? 'px-3.5 py-3' : 'px-[18px] py-3.5';
const body = phone ? 'pt-2.5' : 'pl-[33px] pt-2.5';
const engineOf = (id: string) => engines?.find((e) => e.id === id);
@@ -1035,7 +1097,7 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
3,
'Pick a team',
v.open === 3 && !done3 ? 'open' : done3 ? 'done' : 'todo',
- done3 ? 'Starter bots' : undefined,
+ done3 ? (importedHere ? 'Your imported bots' : 'Starter bots') : undefined,
v.open === 2 && slow && !done3 ? (
<Btn phone={phone} kind="link" className="ml-auto shrink-0" onClick={() => setTeamEarly(true)}>
Open
@@ -1044,7 +1106,7 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
)}
{v.open === 3 && !done3 ? (
<div className={`${body} gs-open`}>
- <TeamStep phone={phone} onKeep={keep} onPicked={() => undefined} />
+ <TeamStep phone={phone} spaceName={spaceName ?? 'this space'} onKeep={keep} onPicked={() => undefined} onImported={importedBots} onImportChanged={onImported} />
</div>
) : null}
</div>
diff --git a/frontend/src/components/ImportDialog.tsx b/frontend/src/components/ImportDialog.tsx
index 897145fb..fd6b9fc2 100644
--- a/frontend/src/components/ImportDialog.tsx
+++ b/frontend/src/components/ImportDialog.tsx
@@ -20,6 +20,7 @@ import {
trapFocusTarget,
} from '../imports';
import { useEscapeLayer } from '../escape';
+import { pickProblem, uploadFor } from '../importZip';
const btn =
'flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium text-zinc-300 border border-zinc-700/60 bg-zinc-800/60 hover:bg-zinc-700/70 hover:text-zinc-100 transition-colors disabled:opacity-50';
@@ -95,7 +96,7 @@ export const SourceList: React.FC<{
<FileUp size={18} className="text-zinc-400 shrink-0" aria-hidden="true" />
<span className="flex-1 min-w-0">
<span className="block text-sm font-medium text-zinc-100">Upload a file</span>
- <span className="block text-[11px] text-zinc-500">A Claude Code subagent or SKILL.md, a character card, or a Grok Bot, OpenMausBot or .kwant.json export</span>
+ <span className="block text-[11px] text-zinc-500">One or several files: Claude Code subagents or SKILL.md, character cards, or Grok Bot, OpenMausBot or .kwant.json exports</span>
</span>
<ChevronRight size={16} className="text-zinc-500 shrink-0" aria-hidden="true" />
</button>
@@ -148,8 +149,21 @@ export const PromptStep: React.FC<{
</div>
);
-export const UploadStep: React.FC<{ file: File | null; onFile: (f: File | null) => void; inputRef: React.RefObject<HTMLInputElement> }> = ({ file, onFile, inputRef }) => {
+/** A short label for what's picked: the file's name, or "3 files: a.json, b.json and c.md". */
+export function pickedLabel(files: ReadonlyArray<{ name: string }>): string {
+ if (files.length === 0) return '';
+ if (files.length === 1) return files[0].name;
+ const names = files.map((f) => f.name);
+ const shown = names.slice(0, 3);
+ const rest = names.length - shown.length;
+ const list = rest > 0 ? `${shown.join(', ')} and ${rest} more` : `${shown.slice(0, -1).join(', ')} and ${shown[shown.length - 1]}`;
+ return `${files.length} files: ${list}`;
+}
+
+export const UploadStep: React.FC<{ files: File[]; onFiles: (f: File[]) => void; inputRef: React.RefObject<HTMLInputElement> }> = ({ files, onFiles, inputRef }) => {
const [over, setOver] = useState(false);
+ const one = files.length === 1 ? files[0] : null;
+ const problem = pickProblem(files);
return (
<div className="space-y-3">
<div
@@ -161,23 +175,29 @@ export const UploadStep: React.FC<{ file: File | null; onFile: (f: File | null)
onDrop={(e) => {
e.preventDefault();
setOver(false);
- onFile(e.dataTransfer.files?.[0] ?? null);
+ onFiles([...(e.dataTransfer.files ?? [])]);
}}
className={`rounded-xl border-2 border-dashed p-6 text-center space-y-2 ${over ? 'border-sky-500 bg-sky-500/5' : 'border-zinc-700'}`}
>
<Upload size={22} className="mx-auto text-zinc-500" aria-hidden="true" />
- <p className="text-xs text-zinc-300">{file ? file.name : 'Drop a file here, or'}</p>
+ <p className="text-xs text-zinc-300 break-words" data-picked>{files.length ? pickedLabel(files) : 'Drop one or more files here, or'}</p>
<label className={`${btn} inline-flex cursor-pointer`}>
- {file ? 'Choose another file' : 'Choose a file'}
- <input ref={inputRef} type="file" accept={IMPORT_ACCEPT} className="sr-only" onChange={(e) => onFile(e.target.files?.[0] ?? null)} />
+ {files.length ? 'Choose other files' : 'Choose files'}
+ <input ref={inputRef} type="file" multiple accept={IMPORT_ACCEPT} className="sr-only" onChange={(e) => onFiles([...(e.target.files ?? [])])} />
</label>
- {file && fileTooBig(file.size) && <p className="text-[11px] text-rose-300">That file is over 20 MB, so it can’t be imported.</p>}
+ {one && fileTooBig(one.size) && <p className="text-[11px] text-rose-300">That file is over 20 MB, so it can’t be imported.</p>}
+ {problem && (
+ <p className="text-[11px] text-rose-300" role="alert">
+ {problem}
+ </p>
+ )}
</div>
<ul className="text-[11px] text-zinc-500 space-y-0.5 list-disc pl-5">
<li>Claude Code subagent (.md) or a SKILL.md</li>
<li>Character card (.json or .png)</li>
<li>Grok Bot or OpenMausBot export (.json)</li>
<li>A .kwant.json file exported from here</li>
+ <li>Several of these at once: pick or drop them together, no need to zip them</li>
<li>A .zip of any of these. Chat history inside is skipped.</li>
</ul>
</div>
@@ -239,13 +259,20 @@ const Notes: React.FC<{ items: string[]; tone: 'warn' | 'drop' | 'problem'; labe
);
/** What the import will create. Each bot can be left out. */
-export const PreviewView: React.FC<{ preview: Preview; skip: ReadonlySet<string>; onToggle: (ref: string) => void }> = ({ preview, skip, onToggle }) => {
+export const PreviewView: React.FC<{
+ preview: Preview;
+ skip: ReadonlySet<string>;
+ onToggle: (ref: string) => void;
+ /** Several picked files went up as one zip: say "from N files", not "from a zip". */
+ pickedFiles?: number;
+}> = ({ preview, skip, onToggle, pickedFiles = 0 }) => {
const { bots, general } = previewRows(preview);
const teams = preview.bundle.teams ?? [];
const shared = preview.bundle.skills ?? [];
- const omitted = preview.bundle.omitted ?? [];
+ const packed = pickedFiles > 1;
+ const omitted = (preview.bundle.omitted ?? []).map((t) => (packed ? t.replace(/^Files in the zip that weren't read:/, "Files that weren't read:") : t));
const kept = bots.filter((b) => !skip.has(b.ref)).length;
- const from = sourceName(preview.bundle.source.kind);
+ const from = packed ? `${pickedFiles} files` : sourceName(preview.bundle.source.kind);
return (
<div className="space-y-3">
<p className="text-xs text-zinc-300">
@@ -378,7 +405,7 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged })
const [promptsError, setPromptsError] = useState<unknown>(null);
const [reply, setReply] = useState('');
const [copied, setCopied] = useState(false);
- const [file, setFile] = useState<File | null>(null);
+ const [files, setFiles] = useState<File[]>([]);
const [preview, setPreview] = useState<Preview | null>(null);
const [skip, setSkip] = useState<Set<string>>(new Set());
const [busy, setBusy] = useState(false);
@@ -442,7 +469,13 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged })
// From the preview ("Check again" after a name was taken), read the same input again.
const prompt = step.kind === 'prompt' ? step.prompt : step.kind === 'preview' ? step.prompt : undefined;
try {
- const p = prompt ? await importApi.previewText(reply) : file ? await importApi.previewFile(file, file.name) : null;
+ let p = null;
+ if (prompt) p = await importApi.previewText(reply);
+ else if (files.length > 0 && !pickProblem(files)) {
+ // Several files go up as one zip, which the server reads into one preview.
+ const up = await uploadFor(files);
+ p = await importApi.previewFile(up.body, up.filename);
+ }
if (!p) return;
setPreview(p);
setSkip(new Set());
@@ -496,7 +529,12 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged })
let footer: React.ReactNode = null;
if (step.kind === 'prompt' || step.kind === 'upload') {
- const ready = step.kind === 'prompt' ? reply.trim() !== '' && !textTooLong(reply) : !!file && !fileTooBig(file.size);
+ const ready =
+ step.kind === 'prompt'
+ ? reply.trim() !== '' && !textTooLong(reply)
+ : files.length > 1
+ ? !pickProblem(files)
+ : files.length === 1 && !fileTooBig(files[0].size);
footer = (
<button type="button" onClick={check} disabled={!ready || busy} className={primary}>
{busy && <Loader2 size={13} className="animate-spin motion-reduce:animate-none" />} {busy ? 'Reading…' : 'Preview'}
@@ -555,10 +593,11 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged })
{step.kind === 'prompt' && (
<PromptStep prompt={step.prompt} reply={reply} onReply={setReply} copied={copied} onCopy={copy} />
)}
- {step.kind === 'upload' && <UploadStep file={file} onFile={setFile} inputRef={fileRef} />}
+ {step.kind === 'upload' && <UploadStep files={files} onFiles={setFiles} inputRef={fileRef} />}
{step.kind === 'preview' && preview && (
<PreviewView
preview={preview}
+ pickedFiles={step.from === 'upload' ? files.length : 0}
skip={skip}
onToggle={(ref) =>
setSkip((s) => {
diff --git a/frontend/src/gettingStarted.ts b/frontend/src/gettingStarted.ts
index 271a46c6..0c2be37e 100644
--- a/frontend/src/gettingStarted.ts
+++ b/frontend/src/gettingStarted.ts
@@ -421,14 +421,16 @@ export const isDismissed = (space: string) => store()?.getItem(dismissKey(space)
/** The card was shown here before (so it stays until dismissed, C4, even once an account works). */
export const wasStarted = (space: string) => {
const v = store()?.getItem(dismissKey(space));
- return v === 'open' || v === 'kept';
+ return v === 'open' || v === 'kept' || v === 'imported';
};
/** "Keep the starter bots" pressed before sign-in finished: step 3 is done, the card waits for step 2. */
export const isKept = (space: string) => store()?.getItem(dismissKey(space)) === 'kept';
-export function markStarted(space: string, value: 'open' | 'kept' = 'open') {
+/** Step 3 was done by importing bots ("Bring your bots"), before step 2 was done. */
+export const isImported = (space: string) => store()?.getItem(dismissKey(space)) === 'imported';
+export function markStarted(space: string, value: 'open' | 'kept' | 'imported' = 'open') {
try {
const cur = store()?.getItem(dismissKey(space));
- if (cur === 'dismissed' || (cur === 'kept' && value === 'open')) return;
+ if (cur === 'dismissed' || ((cur === 'kept' || cur === 'imported') && value === 'open')) return;
store()?.setItem(dismissKey(space), value);
} catch {
/* nothing to keep */
diff --git a/frontend/src/importZip.ts b/frontend/src/importZip.ts
new file mode 100644
index 00000000..dfd10f8b
--- /dev/null
+++ b/frontend/src/importZip.ts
@@ -0,0 +1,126 @@
+// Several picked files → one uncompressed (STORED) zip, so the import server's zip path reads them
+// all into one preview. No dependency: local headers, CRC-32 and a central directory.
+
+/** The server's zip limits (src/import/mod.rs). */
+export const PICK_LIMITS = { zipBytes: 20 * 1024 * 1024, files: 500, fileBytes: 4 * 1024 * 1024 } as const;
+
+/** Archives the server won't open inside a zip (src/import/archive.rs ARCHIVE_EXTENSIONS). */
+const ARCHIVES = ['.zip', '.gz', '.tgz', '.tar', '.7z', '.rar', '.xz', '.bz2', '.zst'];
+export const isArchiveName = (name: string) => ARCHIVES.some((e) => name.toLowerCase().endsWith(e));
+
+let table: Uint32Array | null = null;
+export function crc32(data: Uint8Array): number {
+ if (!table) {
+ table = new Uint32Array(256);
+ for (let n = 0; n < 256; n++) {
+ let c = n;
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
+ table[n] = c >>> 0;
+ }
+ }
+ let c = 0xffffffff;
+ for (let i = 0; i < data.length; i++) c = table[(c ^ data[i]) & 0xff] ^ (c >>> 8);
+ return (c ^ 0xffffffff) >>> 0;
+}
+
+/** Base names only (no folders), and a second "a.json" becomes "a (2).json". A SKILL.md keeps its
+ * name (the server needs it) and goes in its own folder instead: "skill-2/SKILL.md". */
+export function zipNames(names: string[]): string[] {
+ const used = new Set<string>();
+ return names.map((raw) => {
+ const base = raw.split(/[\\/]/).pop()?.trim() || 'file';
+ const skill = base.toLowerCase() === 'skill.md';
+ const dot = base.lastIndexOf('.');
+ const [stem, ext] = dot > 0 ? [base.slice(0, dot), base.slice(dot)] : [base, ''];
+ let name = base;
+ for (let n = 2; used.has(name.toLowerCase()); n++) name = skill ? `skill-${n}/${base}` : `${stem} (${n})${ext}`;
+ used.add(name.toLowerCase());
+ return name;
+ });
+}
+
+/** Header bytes the zip adds per file and in total, on top of the files themselves. */
+export const zipOverhead = (names: string[]) =>
+ names.reduce((n, name) => n + 30 + 46 + 2 * new TextEncoder().encode(name).length, 22);
+
+/** One STORED zip of these files (names as given, UTF-8). */
+export function storedZip(files: Array<{ name: string; data: Uint8Array }>): Uint8Array {
+ const enc = new TextEncoder();
+ const parts: Uint8Array[] = [];
+ const central: Uint8Array[] = [];
+ let offset = 0;
+ // 1980-01-01 00:00: the same bytes every time (the date doesn't matter to the server).
+ const time = 0;
+ const date = (0 << 9) | (1 << 5) | 1;
+ for (const f of files) {
+ const name = enc.encode(f.name);
+ const crc = crc32(f.data);
+ const size = f.data.length;
+ const local = new DataView(new ArrayBuffer(30));
+ local.setUint32(0, 0x04034b50, true);
+ local.setUint16(4, 20, true); // version needed
+ local.setUint16(6, 0x0800, true); // UTF-8 names
+ local.setUint16(8, 0, true); // STORED
+ local.setUint16(10, time, true);
+ local.setUint16(12, date, true);
+ local.setUint32(14, crc, true);
+ local.setUint32(18, size, true);
+ local.setUint32(22, size, true);
+ local.setUint16(26, name.length, true);
+ local.setUint16(28, 0, true);
+ parts.push(new Uint8Array(local.buffer), name, f.data);
+ const cd = new DataView(new ArrayBuffer(46));
+ cd.setUint32(0, 0x02014b50, true);
+ cd.setUint16(4, 20, true); // version made by
+ cd.setUint16(6, 20, true);
+ cd.setUint16(8, 0x0800, true);
+ cd.setUint16(10, 0, true);
+ cd.setUint16(12, time, true);
+ cd.setUint16(14, date, true);
+ cd.setUint32(16, crc, true);
+ cd.setUint32(20, size, true);
+ cd.setUint32(24, size, true);
+ cd.setUint16(28, name.length, true);
+ // extra, comment, disk, internal attrs: 0
+ cd.setUint32(38, 0, true); // external attrs
+ cd.setUint32(42, offset, true);
+ central.push(new Uint8Array(cd.buffer), name);
+ offset += 30 + name.length + size;
+ }
+ const cdSize = central.reduce((n, p) => n + p.length, 0);
+ const end = new DataView(new ArrayBuffer(22));
+ end.setUint32(0, 0x06054b50, true);
+ end.setUint16(8, files.length, true);
+ end.setUint16(10, files.length, true);
+ end.setUint32(12, cdSize, true);
+ end.setUint32(16, offset, true);
+ const all = [...parts, ...central, new Uint8Array(end.buffer)];
+ const out = new Uint8Array(all.reduce((n, p) => n + p.length, 0));
+ let at = 0;
+ for (const p of all) {
+ out.set(p, at);
+ at += p.length;
+ }
+ return out;
+}
+
+/** Why these picked files can't be sent, in plain words; null when they can. One file is checked as before. */
+export function pickProblem(files: ReadonlyArray<{ name: string; size: number }>): string | null {
+ if (files.length < 2) return null;
+ if (files.some((f) => isArchiveName(f.name))) return 'Pick one zip, or several files that aren’t zips.';
+ if (files.length > PICK_LIMITS.files) return `That’s ${files.length} files. Pick up to ${PICK_LIMITS.files} at once.`;
+ const big = files.find((f) => f.size > PICK_LIMITS.fileBytes);
+ if (big) return `${big.name} is over 4 MB, so it can’t be imported.`;
+ const total = files.reduce((n, f) => n + f.size, 0) + zipOverhead(zipNames(files.map((f) => f.name)));
+ if (total > PICK_LIMITS.zipBytes) return 'These files add up to more than 20 MB. Pick fewer at a time.';
+ return null;
+}
+
+/** What to upload for a pick: the one file as it is, or several packed into "bots.zip". */
+export async function uploadFor(files: ReadonlyArray<File>): Promise<{ body: Blob; filename: string }> {
+ if (files.length === 1) return { body: files[0], filename: files[0].name };
+ const names = zipNames(files.map((f) => f.name));
+ const data = await Promise.all(files.map(async (f) => new Uint8Array(await f.arrayBuffer())));
+ const zip = storedZip(names.map((name, i) => ({ name, data: data[i] })));
+ return { body: new Blob([zip.buffer as ArrayBuffer], { type: 'application/zip' }), filename: 'bots.zip' };
+}
diff --git a/frontend/tests/gettingStarted.test.mjs b/frontend/tests/gettingStarted.test.mjs
index 461c27a2..8289f7df 100644
--- a/frontend/tests/gettingStarted.test.mjs
+++ b/frontend/tests/gettingStarted.test.mjs
@@ -336,6 +336,141 @@ test('card: already signed in → hero D2, steps 1–2 done with Change, step 3
r2.done();
});
+// ------------------------------------------------------------------ step 3: Bring your bots (0.7.7)
+
+/** Fake import routes: prompts, a one-bot preview, apply. Records each call. */
+function importRoutes() {
+ const calls = [];
+ const bundle = { format: 'kwant.bundle/1', source: { kind: 'grok', label: 'Grok' }, bots: [{ ref: 'g', name: 'Grokky', title: '', persona_prompt: 'Hi.', memories: [], skills: [], routines: [] }], teams: [], skills: [], omitted: [] };
+ const record = { id: 'imp1', space_id: 'r', source_kind: 'grok', status: 'applied', created: { kwants: [{ ref: 'g', id: 'k1', name: 'Grokky' }], skills: [], routines: [], teams: [], channels: [], memories: 0 }, created_at: '', undone_at: null };
+ const json = (b) => new Response(JSON.stringify(b), { status: 200, headers: { 'Content-Type': 'application/json' } });
+ const fetch = async (url, init = {}) => {
+ const u = String(url);
+ calls.push([init.method ?? 'GET', u]);
+ if (u === '/api/import/prompts') return json([{ id: 'grok', label: 'Grok', where_to_send: 'Open your Grok bot.', prompt: 'Export yourself.' }]);
+ if (u.startsWith('/api/import/preview')) return json({ bundle, warnings: [], dropped: [], problems: [], renames: [], can_apply: true });
+ if (u === '/api/import/apply') return json({ import: record, warnings: [], dropped: [], renames: [] });
+ return new Response('{}', { status: 404, headers: { 'Content-Type': 'application/json' } });
+ };
+ return { calls, fetch };
+}
+const byText = (root, re) => [...root.querySelectorAll('button')].find((b) => re.test(b.textContent));
+function typeInto(el, value) {
+ Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set.call(el, value);
+ el.dispatchEvent(new window.Event('input', { bubbles: true }));
+}
+function mountStep3(space, extra = {}) {
+ localStorage.clear();
+ return mount(h(m.GetStarted, { space, spaceName: 'Home', bots: [{ id: 'a', name: 'Architect' }], engines: [ready('claude')], reloadEngines() {}, onDismissed() {}, hostOverride: null, ...extra }));
+}
+
+test('step 3: "Bring your bots" sits next to Keep the starter bots and opens the importer for this space', async () => {
+ const real = g.fetch;
+ const r0 = importRoutes();
+ g.fetch = g.window.fetch = r0.fetch;
+ try {
+ const r = mountStep3('imp-open');
+ await settle();
+ const tile = r.host.querySelector('[data-import-bots]');
+ assert.ok(tile, 'the tile is in step 3');
+ assert.equal(tile.closest('ul'), r.host.querySelector('[data-keep-starter]').closest('ul'));
+ assert.match(tile.textContent, /^Bring your botsFrom Grok Bot, ChatGPT or Claude, or from a file\. You check a preview first\./);
+ assert.match(tile.getAttribute('aria-label'), /^Bring your bots: /);
+ assert.equal(tile.getAttribute('aria-haspopup'), 'dialog');
+ assert.equal(document.querySelector('[role="dialog"]'), null);
+ tile.click();
+ await settle();
+ const dlg = document.querySelector('[role="dialog"]');
+ assert.ok(dlg, 'the import dialog opens');
+ assert.match(dlg.textContent, /Import bots into Home/);
+ assert.ok(byText(dlg, /^Grok/), 'the sources load');
+ assert.ok(r0.calls.some(([, u]) => u === '/api/import/prompts'));
+ r.done();
+ } finally {
+ g.fetch = g.window.fetch = real;
+ }
+});
+
+test('step 3: closing the importer without importing leaves step 3 open and focus on the tile', async () => {
+ const real = g.fetch;
+ g.fetch = g.window.fetch = importRoutes().fetch;
+ try {
+ let dismissed = 0;
+ const r = mountStep3('imp-cancel', { onDismissed: () => dismissed++ });
+ await settle();
+ const tile = r.host.querySelector('[data-import-bots]');
+ tile.focus();
+ tile.click();
+ await settle();
+ document.querySelector('[role="dialog"] button[aria-label="Close"]').click();
+ await settle();
+ await sleep(5);
+ assert.equal(document.querySelector('[role="dialog"]'), null);
+ assert.equal(dismissed, 0);
+ assert.equal(m.isDismissed('imp-cancel'), false);
+ assert.equal(m.isImported('imp-cancel'), false);
+ assert.equal([...r.host.querySelectorAll('h3')][2].textContent, 'Step 3 of 3, Pick a team, open');
+ assert.equal(document.activeElement, r.host.querySelector('[data-import-bots]'));
+ r.done();
+ } finally {
+ g.fetch = g.window.fetch = real;
+ }
+});
+
+test('step 3: a successful import completes step 3 once the dialog closes; an undo afterwards does not bring the card back', async () => {
+ const real = g.fetch;
+ const r0 = importRoutes();
+ g.fetch = g.window.fetch = r0.fetch;
+ try {
+ let dismissed = 0;
+ let changed = 0;
+ const r = mountStep3('imp-done', { onDismissed: () => dismissed++, onImported: () => changed++ });
+ await settle();
+ r.host.querySelector('[data-import-bots]').click();
+ await settle();
+ let dlg = document.querySelector('[role="dialog"]');
+ byText(dlg, /^Grok/).click();
+ await settle();
+ typeInto(document.getElementById('import-reply'), '{"name":"Grokky"}');
+ await settle();
+ byText(dlg, /Preview/).click();
+ await settle();
+ dlg = document.querySelector('[role="dialog"]');
+ const go = byText(dlg, /^\s*Import 1 bot/);
+ assert.ok(go, dlg.textContent);
+ go.click();
+ await settle();
+ assert.ok(r0.calls.some(([meth, u]) => meth === 'POST' && u === '/api/import/apply'));
+ assert.equal(changed, 1, 'the sidebar reloads after the import');
+ // Still open on the Done view (with Undo); the card waits for the dialog to close.
+ assert.equal(dismissed, 0);
+ assert.equal(m.isDismissed('imp-done'), false);
+ dlg = document.querySelector('[role="dialog"]');
+ byText(dlg, /^Done$/).click();
+ await settle();
+ // Step 2 is done here, so like Keep the starter bots the card goes for good.
+ assert.equal(dismissed, 1);
+ assert.equal(m.isDismissed('imp-done'), true);
+ assert.equal(m.showCard({ dismissed: m.isDismissed('imp-done'), canRun: true, generalMessages: 0, teams: 1, started: m.wasStarted('imp-done') }), false);
+ r.done();
+ } finally {
+ g.fetch = g.window.fetch = real;
+ }
+});
+
+test('step 3: imported before step 2 is done → step 3 reads done with "Your imported bots"; Open never undoes it', () => {
+ localStorage.clear();
+ m.markStarted('imp-early', 'imported');
+ assert.equal(m.isImported('imp-early'), true);
+ assert.equal(m.wasStarted('imp-early'), true);
+ m.markStarted('imp-early');
+ assert.equal(m.isImported('imp-early'), true, 'a later visit does not reset it');
+ const r = mount(h(m.GetStarted, { space: 'imp-early', bots: [{ id: 'a', name: 'Architect' }], engines: [signedOut('claude')], reloadEngines() {}, onDismissed() {}, hostOverride: null }));
+ const heads = [...r.host.querySelectorAll('h3')].map((x) => x.textContent);
+ assert.equal(heads[2], 'Step 3 of 3, Pick a team, doneYour imported bots');
+ r.done();
+});
+
test('card: step 1 tiles are a radiogroup; arrows move, a tap starts at once; server shows the host', async () => {
localStorage.clear();
const r = mount(h(m.GetStarted, { space: 't1', bots: [], engines: [engine('claude'), signedOut('codex')], reloadEngines() {}, onDismissed() {}, hostOverride: 'vps.example.net' }));
diff --git a/frontend/tests/importZip.test.mjs b/frontend/tests/importZip.test.mjs
new file mode 100644
index 00000000..e3a12cf9
--- /dev/null
+++ b/frontend/tests/importZip.test.mjs
@@ -0,0 +1,212 @@
+// 0.7.7: pick several files in the importer. They go up as one STORED zip ("bots.zip") that the
+// server's zip path reads into one preview. The writer, the checks before upload, and the dialog.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { JSDOM } from 'jsdom';
+import { loadBundled } from './bundle.mjs';
+
+const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/', pretendToBeVisual: true });
+const g = globalThis;
+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Element', 'Node', 'Event', 'MouseEvent', 'KeyboardEvent', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'localStorage', 'sessionStorage']) {
+ if (!(k in dom.window)) continue;
+ Object.defineProperty(g, k, { value: dom.window[k], configurable: true, writable: true });
+}
+g.window.matchMedia = g.window.matchMedia || ((q) => ({ matches: false, media: q, addEventListener() {}, removeEventListener() {} }));
+
+const m = await loadBundled(`
+ export { default as React } from 'react';
+ export { createRoot } from 'react-dom/client';
+ export { flushSync } from 'react-dom';
+ export * from './src/importZip';
+ export { ImportDialog, pickedLabel } from './src/components/ImportDialog';
+`);
+const { React, createRoot, flushSync } = m;
+const h = React.createElement;
+const settle = async (n = 6) => {
+ for (let i = 0; i < n; i++) await new Promise((r) => setTimeout(r, 0));
+};
+const bytes = (s) => new TextEncoder().encode(s);
+const str = (b) => new TextDecoder().decode(b);
+
+/** A small independent zip reader: walks the central directory, checks each local header and CRC. */
+function readZip(buf) {
+ const v = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
+ const eocd = buf.length - 22;
+ assert.equal(v.getUint32(eocd, true), 0x06054b50, 'end of central directory');
+ const count = v.getUint16(eocd + 10, true);
+ const cdSize = v.getUint32(eocd + 12, true);
+ let p = v.getUint32(eocd + 16, true);
+ assert.equal(p + cdSize, eocd, 'central directory ends where the end record starts');
+ const out = [];
+ for (let i = 0; i < count; i++) {
+ assert.equal(v.getUint32(p, true), 0x02014b50, 'central header');
+ const flags = v.getUint16(p + 8, true);
+ const method = v.getUint16(p + 10, true);
+ const crc = v.getUint32(p + 16, true);
+ const csize = v.getUint32(p + 20, true);
+ const usize = v.getUint32(p + 24, true);
+ const nlen = v.getUint16(p + 28, true);
+ const elen = v.getUint16(p + 30, true);
+ const clen = v.getUint16(p + 32, true);
+ const off = v.getUint32(p + 42, true);
+ const name = str(buf.subarray(p + 46, p + 46 + nlen));
+ assert.equal(v.getUint32(off, true), 0x04034b50, 'local header');
+ assert.equal(v.getUint16(off + 8, true), method);
+ assert.equal(v.getUint32(off + 14, true), crc);
+ assert.equal(v.getUint32(off + 18, true), csize);
+ const lnlen = v.getUint16(off + 26, true);
+ const lelen = v.getUint16(off + 28, true);
+ assert.equal(str(buf.subarray(off + 30, off + 30 + lnlen)), name, 'same name in both headers');
+ const data = buf.subarray(off + 30 + lnlen + lelen, off + 30 + lnlen + lelen + csize);
+ out.push({ name, flags, method, crc, csize, usize, data });
+ p += 46 + nlen + elen + clen;
+ }
+ return out;
+}
+
+test('crc32 matches the standard check values', () => {
+ assert.equal(m.crc32(bytes('123456789')), 0xcbf43926);
+ assert.equal(m.crc32(new Uint8Array()), 0);
+ assert.equal(m.crc32(bytes('The quick brown fox jumps over the lazy dog')), 0x414fa339);
+});
+
+test('storedZip: STORED entries, UTF-8 names, right CRCs, and the bytes read back', () => {
+ const files = [
+ { name: 'grok-a.json', data: bytes('{"name":"A"}') },
+ { name: 'agent ü.md', data: bytes('---\nname: x\n---\nhi') },
+ { name: 'empty.txt', data: new Uint8Array() },
+ ];
+ const zip = m.storedZip(files);
+ const back = readZip(zip);
+ assert.deepEqual(back.map((e) => e.name), files.map((f) => f.name));
+ back.forEach((e, i) => {
+ assert.equal(e.method, 0, 'STORED');
+ assert.equal(e.flags & 0x0800, 0x0800, 'UTF-8 flag');
+ assert.equal(e.csize, e.usize);
+ assert.equal(e.crc, m.crc32(files[i].data));
+ assert.deepEqual([...e.data], [...files[i].data]);
+ });
+ assert.equal(zip.length, files.reduce((n, f) => n + f.data.length, 0) + m.zipOverhead(files.map((f) => f.name)));
+});
+
+test('zipNames: base names only, duplicates get " (2)", a second SKILL.md gets its own folder', () => {
+ assert.deepEqual(m.zipNames(['a/b/bot.json', 'C:\\x\\bot.json', 'bot.json', 'README', 'readme']), ['bot.json', 'bot (2).json', 'bot (3).json', 'README', 'readme (2)']);
+ assert.deepEqual(m.zipNames(['one/SKILL.md', 'two/SKILL.md']), ['SKILL.md', 'skill-2/SKILL.md']);
+});
+
+test('pickProblem: one file is checked as before; several files: no archives, ≤500, ≤4 MB each, ≤20 MB in all', () => {
+ const MB = 1024 * 1024;
+ assert.equal(m.pickProblem([]), null);
+ assert.equal(m.pickProblem([{ name: 'big.zip', size: 19 * MB }]), null, 'one file goes the old way');
+ assert.equal(m.pickProblem([{ name: 'a.json', size: 10 }, { name: 'b.md', size: 10 }]), null);
+ assert.equal(m.pickProblem([{ name: 'a.json', size: 10 }, { name: 'more.ZIP', size: 10 }]), 'Pick one zip, or several files that aren’t zips.');
+ assert.equal(m.pickProblem([{ name: 'a.json', size: 10 }, { name: 'x.tar.gz', size: 10 }]), 'Pick one zip, or several files that aren’t zips.');
+ assert.match(m.pickProblem(Array.from({ length: 501 }, (_, i) => ({ name: `${i}.json`, size: 1 }))), /^That’s 501 files\. Pick up to 500 at once\.$/);
+ assert.equal(m.pickProblem(Array.from({ length: 500 }, (_, i) => ({ name: `${i}.json`, size: 1 }))), null);
+ assert.equal(m.pickProblem([{ name: 'a.json', size: 10 }, { name: 'huge.png', size: 4 * MB + 1 }]), 'huge.png is over 4 MB, so it can’t be imported.');
+ assert.equal(m.pickProblem(Array.from({ length: 6 }, (_, i) => ({ name: `${i}.png`, size: 3.5 * MB }))), 'These files add up to more than 20 MB. Pick fewer at a time.');
+});
+
+test('uploadFor: one file goes up unchanged; several become one bots.zip', async () => {
+ const one = new File(['{"a":1}'], 'grok.json');
+ const up1 = await m.uploadFor([one]);
+ assert.equal(up1.body, one);
+ assert.equal(up1.filename, 'grok.json');
+ const up3 = await m.uploadFor([one, new File(['{"b":2}'], 'grok.json'), new File(['---\nname: r\n---\n'], 'reviewer.md')]);
+ assert.equal(up3.filename, 'bots.zip');
+ const back = readZip(new Uint8Array(await up3.body.arrayBuffer()));
+ assert.deepEqual(back.map((e) => [e.name, str(e.data)]), [['grok.json', '{"a":1}'], ['grok (2).json', '{"b":2}'], ['reviewer.md', '---\nname: r\n---\n']]);
+});
+
+test('pickedLabel names one file, or counts several', () => {
+ assert.equal(m.pickedLabel([{ name: 'a.json' }]), 'a.json');
+ assert.equal(m.pickedLabel([{ name: 'a.json' }, { name: 'b.md' }]), '2 files: a.json and b.md');
+ assert.equal(m.pickedLabel([{ name: 'a' }, { name: 'b' }, { name: 'c' }]), '3 files: a, b and c');
+ assert.equal(m.pickedLabel([{ name: 'a' }, { name: 'b' }, { name: 'c' }, { name: 'd' }, { name: 'e' }]), '5 files: a, b, c and 2 more');
+});
+
+// ------------------------------------------------------------------ the dialog
+
+function dialog() {
+ const calls = [];
+ const preview = { bundle: { format: 'kwant.bundle/1', source: { kind: 'zip' }, bots: [], teams: [], skills: [], omitted: [] }, warnings: [], dropped: [], problems: [], renames: [], can_apply: false };
+ g.fetch = g.window.fetch = async (url, init = {}) => {
+ calls.push({ url: String(url), method: init.method ?? 'GET', body: init.body });
+ const json = (b) => new Response(JSON.stringify(b), { status: 200, headers: { 'Content-Type': 'application/json' } });
+ if (String(url) === '/api/import/prompts') return json([]);
+ if (String(url).startsWith('/api/import/preview')) return json(preview);
+ return new Response('{}', { status: 404 });
+ };
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const root = createRoot(host);
+ flushSync(() => root.render(h(m.ImportDialog, { spaceName: 'Home', onClose() {}, onChanged() {} })));
+ const btn = (re) => [...document.querySelectorAll('[role="dialog"] button')].find((b) => re.test(b.textContent));
+ const pick = (files) => {
+ const input = document.querySelector('[role="dialog"] input[type="file"]');
+ Object.defineProperty(input, 'files', { value: files, configurable: true });
+ input.dispatchEvent(new window.Event('change', { bubbles: true }));
+ };
+ return { calls, host, btn, pick, done: () => (root.unmount(), host.remove()) };
+}
+
+test('dialog: the picker takes several files; one file uploads exactly as before', async () => {
+ const d = dialog();
+ await settle();
+ d.btn(/Upload a file/).click();
+ await settle();
+ const input = document.querySelector('[role="dialog"] input[type="file"]');
+ assert.equal(input.multiple, true);
+ assert.match(document.querySelector('[role="dialog"]').textContent, /Several of these at once/);
+ const f = new File(['{"name":"A"}'], 'grok a.json');
+ d.pick([f]);
+ await settle();
+ assert.equal(document.querySelector('[data-picked]').textContent, 'grok a.json');
+ d.btn(/Preview/).click();
+ await settle();
+ const up = d.calls.find((c) => c.url.startsWith('/api/import/preview'));
+ assert.equal(up.url, '/api/import/preview?filename=grok%20a.json');
+ assert.equal(up.body, f, 'the file itself, not a zip');
+ d.done();
+});
+
+test('dialog: three files go up as one bots.zip with all three inside', async () => {
+ const d = dialog();
+ await settle();
+ d.btn(/Upload a file/).click();
+ await settle();
+ d.pick([new File(['{"a":1}'], 'a.json'), new File(['{"b":1}'], 'b.json'), new File(['---\nname: r\n---\nx'], 'reviewer.md')]);
+ await settle();
+ assert.equal(document.querySelector('[data-picked]').textContent, '3 files: a.json, b.json and reviewer.md');
+ d.btn(/Preview/).click();
+ await settle(12);
+ const up = d.calls.find((c) => c.url.startsWith('/api/import/preview'));
+ assert.equal(up.url, '/api/import/preview?filename=bots.zip');
+ const back = readZip(new Uint8Array(await up.body.arrayBuffer()));
+ assert.deepEqual(back.map((e) => e.name), ['a.json', 'b.json', 'reviewer.md']);
+ d.done();
+});
+
+test('dialog: a zip among several files is refused before anything is sent', async () => {
+ const d = dialog();
+ await settle();
+ d.btn(/Upload a file/).click();
+ await settle();
+ d.pick([new File(['x'], 'a.json'), new File(['PK'], 'more.zip')]);
+ await settle();
+ assert.equal(document.querySelector('[role="dialog"] [role="alert"]').textContent, 'Pick one zip, or several files that aren’t zips.');
+ assert.equal(d.btn(/Preview/).disabled, true);
+ assert.equal(d.calls.some((c) => c.url.startsWith('/api/import/preview')), false);
+ d.done();
+});
+
+test('preview of several picked files says "from 3 files" and "Files that weren\'t read", not "a zip"', async () => {
+ const { renderToStaticMarkup } = await loadBundled(`export { renderToStaticMarkup } from 'react-dom/server.browser';`);
+ const pv = await loadBundled(`export { PreviewView } from './src/components/ImportDialog'; export { createElement } from 'react';`);
+ const bot = (ref) => ({ ref, name: ref, title: '', persona_prompt: 'x', memories: [], skills: [], routines: [] });
+ const preview = { bundle: { format: 'kwant.bundle/1', source: { kind: 'zip' }, bots: [bot('a'), bot('b'), bot('c')], teams: [], skills: [], omitted: ["Files in the zip that weren't read: notes.txt"] }, warnings: [], dropped: [], problems: [], renames: [], can_apply: true };
+ const out = (n) => renderToStaticMarkup(pv.createElement(pv.PreviewView, { preview, skip: new Set(), onToggle() {}, pickedFiles: n })).replace(/<[^>]+>/g, ' ').replace(/&#x27;/g, "'");
+ assert.match(out(3), /3 bots will be created from 3 files\./);
+ assert.match(out(3), /Files that weren't read: notes\.txt/);
+ assert.match(out(0), /Files in the zip that weren't read: notes\.txt/, 'an uploaded zip keeps the server wording');
+});