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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
0.8.0 A4 follow-ups: import dialog fixes (Pixel items 1–11) (#471)
Oleksandr Ivanchenkodc815e57ef34
diff --git a/frontend/src/components/ImportDialog.tsx b/frontend/src/components/ImportDialog.tsxindex c5a291e1..74041fab 100644--- a/frontend/src/components/ImportDialog.tsx+++ b/frontend/src/components/ImportDialog.tsx@@ -358,10 +358,13 @@ export const PreviewView: React.FC<{<p className="text-xs text-zinc-300">No bots in this one. <strong className="font-semibold text-zinc-100">{plural(shared.length, 'skill')}</strong> will be added to {spaceName}.</p>- ) : (+ ) : bots.length > 0 ? (<p className="text-xs text-zinc-300">- {bots.length > 0 ? `${plural(kept, 'bot')} will be created` : 'No bots in this one'}- {from ? ` from ${from}` : ''}. Untick any you don’t want.+ {plural(kept, 'bot')} will be created{from ? ` from ${from}` : ''}. Untick any you don’t want.+ </p>+ ) : (+ <p className="text-xs text-zinc-300" data-preview-empty>+ Nothing here can be brought in: no bots and no skills.</p>)}{skillsOnly && (@@ -380,7 +383,7 @@ export const PreviewView: React.FC<{const off = skip.has(b.ref);return (<li key={b.ref} className={`${card} p-3 space-y-2 ${off ? 'opacity-50' : ''}`}>- <label className="flex items-start gap-2.5 cursor-pointer">+ <label className="flex items-start gap-2.5 cursor-pointer max-md:min-h-11" data-bot-tick><input type="checkbox" checked={!off} onChange={() => onToggle(b.ref)} className="mt-0.5 accent-sky-500" aria-label={`Import ${b.name}`} /><span className="flex-1 min-w-0"><span className="block text-sm font-medium text-zinc-100 break-words">{b.name}</span>@@ -420,10 +423,12 @@ export const PreviewView: React.FC<{)}<Notes items={general.warnings} tone="warn" label="Worth a look" /><Notes items={[...general.dropped, ...omitted]} tone="drop" label="Not brought over" />- <p className="flex gap-2 text-[11px] text-zinc-400 rounded-lg bg-zinc-900/60 p-2.5">- <Info size={13} className="shrink-0 mt-px text-sky-400" aria-hidden="true" />- <span>To keep you safe, imported bots start with no tools, their skills wait for your OK, and routines start paused. Keys are removed.</span>- </p>+ {(bots.length > 0 || shared.length > 0) && (+ <p className="flex gap-2 text-[11px] text-zinc-400 rounded-lg bg-zinc-900/60 p-2.5">+ <Info size={13} className="shrink-0 mt-px text-sky-400" aria-hidden="true" />+ <span>To keep you safe, imported bots start with no tools, their skills wait for your OK, and routines start paused. Keys are removed.</span>+ </p>+ )}</div>);};@@ -471,7 +476,8 @@ export const DoneView: React.FC<{ applied: Applied; undo: UndoState; onUndo: (fo</p>{github && (<p className="text-[11px] text-zinc-400 break-words" data-github-done>- {githubFromLine(github)} They wait for your OK in Settings › This space › Skills.+ {githubFromLine(github)}+ {skillsOnly ? ' They wait for your OK in Settings › This space › Skills.' : ''}</p>)}{names.length > 0 && <p className="text-xs text-zinc-300 break-words">{names.join(', ')}</p>}@@ -616,11 +622,18 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged, le.preventDefault();items[next].focus();};- // Each step starts at the top, with focus inside the dialog.+ // Each step starts at the top, with focus inside the dialog. Found runs again once its list arrives, so+ // focus moves from the "Looking…" line to the first checkbox (or Pick a folder / Try again).+ const foundPhase = step.kind === 'found' ? local.kind : '';useEffect(() => {- bodyRef.current?.scrollTo?.(0, 0);- bodyRef.current?.querySelector<HTMLElement>('button, textarea, input:not([type="file"]), [tabindex="0"]')?.focus();- }, [step.kind]);+ const body = bodyRef.current;+ if (!body) return;+ if (foundPhase === '' || foundPhase === 'loading') body.scrollTo?.(0, 0);+ (+ body.querySelector<HTMLElement>('[data-autofocus]') ??+ body.querySelector<HTMLElement>('button, textarea, input:not([type="file"]), [tabindex="0"]')+ )?.focus();+ }, [step.kind, foundPhase]);const go = (s: Step) => {setError(null);@@ -824,7 +837,7 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged, l) : (cancel)}- <button type="button" onClick={check} disabled={!plan || !!plan.problem || plan.kept.length === 0 || busy} className={`${primary} ${fb}`}>+ <button type="button" onClick={check} disabled={!plan || !!plan.problem || plan.kept.length === 0 || folderUnsupported || busy} className={`${primary} ${fb}`}>{busy && spin} {busy ? 'Reading…' : 'Preview'}</button></>@@ -881,13 +894,13 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged, laria-labelledby="import-title"className="kw-dialog-panel bg-zinc-900 sm:border border-zinc-800 sm:rounded-2xl w-full sm:max-w-xl h-full sm:h-auto sm:max-h-[90vh] flex flex-col text-zinc-100 shadow-2xl">- <div className={`flex items-center gap-2 border-b border-zinc-800 px-4 ${phone ? 'h-14 px-2' : 'py-3'}`}>+ <div className={`flex items-center gap-2 border-b border-zinc-800 ${phone ? 'h-14 px-2' : 'px-4 py-3'}`}>{step.kind !== 'choose' && step.kind !== 'done' && (<button type="button" onClick={back} aria-label="Back" className={`${iconBtn} -ml-1 rounded-lg text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800`}><ArrowLeft size={17} /></button>)}- <h2 id="import-title" className="flex-1 min-w-0 text-sm font-semibold truncate">{title}</h2>+ <h2 id="import-title" className={`flex-1 min-w-0 text-sm font-semibold truncate ${phone && (step.kind === 'choose' || step.kind === 'done') ? 'pl-2' : ''}`}>{title}</h2><button type="button" onClick={onClose} aria-label="Close" className={`${iconBtn} rounded-lg text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800`}><X size={18} /></button>@@ -942,6 +955,12 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged, lfetching={busy}error={error}phone={phone}+ onSubmit={() => {+ // Enter keeps Preview's rules: nothing while fetching or empty; a bad link shows its reason.+ if (busy || ghUrl.trim() === '') return;+ setGhChecked(true);+ if (githubLinkOk(ghUrl)) void check();+ }}/>)}{step.kind === 'preview' && preview && (@@ -964,7 +983,7 @@ export const ImportDialog: React.FC<Props> = ({ spaceName, onClose, onChanged, l/>)}{step.kind === 'done' && applied && (- <DoneView applied={applied} undo={undo} onUndo={doUndo} onKeep={() => setUndo({ kind: 'idle' })} github={step.github && applied.import.created.kwants.length === 0 ? step.github : undefined} />+ <DoneView applied={applied} undo={undo} onUndo={doUndo} onKeep={() => setUndo({ kind: 'idle' })} github={step.github} />)}{error != null && step.kind !== 'github' && <ErrorBox error={error} />}</div>diff --git a/frontend/src/components/ImportSources.tsx b/frontend/src/components/ImportSources.tsxindex dae4b5cf..ee60447a 100644--- a/frontend/src/components/ImportSources.tsx+++ b/frontend/src/components/ImportSources.tsx@@ -15,7 +15,8 @@ import {formatBytes,githubErrorText,githubLicenceUrl,- githubLinkOk,+ githubLinkCheck,+ githubLinkProblemText,githubRefLine,githubRepoUrl,licenceLine,@@ -116,7 +117,8 @@ export const FoundStep: React.FC<{if (state.kind === 'loading' || state.kind === 'off') {return (<div className="space-y-3" data-found-state="loading">- <p role="status" className="flex items-center gap-2 text-xs text-zinc-400">+ {/* Focus waits here while the look runs (F1), so it never drops to the page behind the dialog. */}+ <p role="status" tabIndex={-1} data-autofocus className="flex items-center gap-2 text-xs text-zinc-400 focus:outline-none"><Loader2 size={13} className={spin} aria-hidden="true" /> {LOOKING}</p><ul className="space-y-2" aria-hidden="true">@@ -340,14 +342,25 @@ export const GithubStep: React.FC<{fetching: boolean;error: unknown;phone: boolean;-}> = ({ url, onUrl, checked, onCheck, fetching, error, phone }) => {+ /** Enter in the field: the same as pressing Preview. */+ onSubmit: () => void;+}> = ({ url, onUrl, checked, onCheck, fetching, error, phone, onSubmit }) => {const id = useId();- const bad = checked && url.trim() !== '' && !githubLinkOk(url);- const notGithub = bad || (error as { code?: string } | null)?.code === 'not_github';+ const check = githubLinkCheck(url);+ const problem = checked && url.trim() !== '' && 'problem' in check ? check.problem : null;+ // The server's 422 not_github keeps the plain "other sites" line (Decision 2).+ const serverNotGithub = (error as { code?: string } | null)?.code === 'not_github';+ const notGithub = problem !== null || serverNotGithub;const text = error && !notGithub ? githubErrorText(error) : null;return (<div className="space-y-3">- <div>+ <form+ noValidate+ onSubmit={(e) => {+ e.preventDefault();+ onSubmit();+ }}+ ><label htmlFor={id} className="block text-xs font-medium text-zinc-300 mb-1">Link to a public GitHub repo</label><inputid={id}@@ -366,8 +379,8 @@ export const GithubStep: React.FC<{className={`w-full bg-zinc-950 border rounded-lg px-3 py-2 font-mono ${phone ? 'text-base' : 'text-xs'} text-zinc-100 focus:outline-none ${notGithub ? 'border-rose-500/70 focus:border-rose-400' : 'border-zinc-800 focus:border-sky-500'}`}/>{notGithub && (- <p className="mt-1 text-[11px] text-rose-300" role="alert">- {NOT_GITHUB}+ <p className="mt-1 text-[11px] text-rose-300" role="alert" data-github-problem={problem ?? 'not_github'}>+ {problem ? githubLinkProblemText(problem) : NOT_GITHUB}</p>)}<p id={`${id}-help`} className="mt-1.5 text-[11px] text-zinc-500">@@ -376,7 +389,7 @@ export const GithubStep: React.FC<{<p className="mt-0.5 text-[11px] text-zinc-500">Example: <span className="font-mono">github.com/owner/repo/tree/main/skills</span></p>- </div>+ </form>{fetching && (<p role="status" className="flex items-center gap-2 text-xs text-zinc-400"><Loader2 size={13} className={spin} aria-hidden="true" /> Downloading from github.com…@@ -403,7 +416,7 @@ export const GithubSourceBlock: React.FC<{ github: GithubInfo }> = ({ github: gtarget="_blank"rel="noopener noreferrer"aria-label={`Open ${g.owner}/${g.repo} on GitHub`}- className={`shrink-0 flex items-center gap-1 text-xs text-sky-300 hover:text-sky-200 rounded ${ring}`}+ className={`shrink-0 flex items-center gap-1 text-xs text-sky-300 hover:text-sky-200 rounded ${ring} max-md:min-h-11 max-md:-my-3.5 max-md:px-2 max-md:-mr-2`}>Open <ExternalLink size={12} aria-hidden="true" /></a>diff --git a/frontend/src/importSources.ts b/frontend/src/importSources.tsindex 855a8a8f..bb1e35af 100644--- a/frontend/src/importSources.ts+++ b/frontend/src/importSources.ts@@ -141,19 +141,31 @@ const SECRET_NAME_EXACT = new Set(['settings.json', 'settings.local.json', 'mcp.const SECRET_JSON_PREFIXES = ['auth-profiles', 'oauth', 'credentials', 'token'];const SECRET_NAME_PREFIXES = ['client_secret', 'service-account'];/** Any other file whose name says it holds a secret. Notes and pictures (.md, .png) are judged by content, not name. */-const SECRET_WORDS = /(auth|oauth|credential|secret|token|passw|api[-_]?key|private)/i;+const SECRET_WORDS = /(oauth|credential|secret|token|passw|api[-_]?key|private)/i;+/** "auth" anywhere except author/authors/authority (Ada's #471 review): authkey.json, googleAuth.json and+ * authorisation.json are secrets; author.json and authors-note.json are not. */+const AUTH_WORD = /auth(?!or(?!i[sz]))/i;+/** OpenClaw's device keypair and paired devices: never sent, even from a renamed copy (Ada's #459 review item 10). */+const DEVICE_KEY_DIRS = new Set(['identity', 'devices']);/** A picked app folder (its own name), packed as an app home. */const APP_HOME_NAMES = new Set(['.openclaw', '.hermes', '.codex', '.claude', 'openclaw', 'hermes']);const isKeyStore = (base: string) =>base.startsWith('.env') || KEY_STORE_FILES.has(base) || base.startsWith('state.db') || base === '.credentials.json';+/**+ * Settings files that many kits and repos have too (a `.env.example`, a `config.yaml`). They are never+ * sent, but they mark an app home only inside a folder named like an app (Ada's #459 review item 11);+ * openclaw.json, auth.json, .credentials.json, state.db*, credentials/ and sessions/ always do.+ */+const isWeakMarker = (base: string) => base.startsWith('.env') || base === 'config.yaml' || base === 'config.toml';function isSecretName(base: string, dirs: string[]): boolean {if (SECRET_NAME_EXACT.has(base) || SECRET_NAME_PREFIXES.some((p) => base.startsWith(p))) return true;if (base.endsWith('.json') && SECRET_JSON_PREFIXES.some((p) => base.startsWith(p))) return true;+ if (base.endsWith('.json') && dirs.some((d) => DEVICE_KEY_DIRS.has(d))) return true;// OpenClaw's agents/<id>/agent/ holds auth-profiles.json and models.json.if (dirs.some((d, i) => d === 'agent' && i >= 2 && dirs[i - 2] === 'agents')) return true;- return !base.endsWith('.md') && !base.endsWith('.png') && SECRET_WORDS.test(base);+ return !base.endsWith('.md') && !base.endsWith('.png') && (SECRET_WORDS.test(base) || AUTH_WORD.test(base));}const isLicence = (base: string) => {@@ -177,8 +189,9 @@ function formatReads(inner: string[], appHome: boolean): boolean {/*** The folders of a pick that are an app's home: the picked folder when it is named like one, and any- * folder holding an app's key store (openclaw.json, auth.json, config.toml, config.yaml, .env*, state.db*,- * .credentials.json, credentials/, sessions/). Lowercased paths below the picked folder, "" for the pick itself.+ * folder holding an app's key store (openclaw.json, auth.json, state.db*, .credentials.json, credentials/,+ * sessions/). `.env*`, config.toml and config.yaml count only inside a folder named like an app+ * (`isWeakMarker`). Lowercased paths below the picked folder, "" for the pick itself.*/export function appHomes(paths: ReadonlyArray<string>): string[] {const homes = new Set<string>();@@ -187,7 +200,8 @@ export function appHomes(paths: ReadonlyArray<string>): string[] {if (APP_HOME_NAMES.has((parts[0] ?? '').toLowerCase())) homes.add('');const inner = parts.slice(1).map((p) => p.toLowerCase());const dirs = inner.slice(0, -1);- if (isKeyStore(inner[inner.length - 1] ?? '')) homes.add(dirs.join('/'));+ const base = inner[inner.length - 1] ?? '';+ if (isWeakMarker(base) ? dirs.some((d) => APP_HOME_NAMES.has(d)) : isKeyStore(base)) homes.add(dirs.join('/'));const k = dirs.findIndex((d) => KEY_STORE_DIRS.has(d));if (k >= 0) homes.add(dirs.slice(0, k).join('/'));}@@ -317,32 +331,54 @@ const SEG = /^[A-Za-z0-9._-]{1,100}$/;* scheme), no user or port, and one of the three shapes. Null when it looks fine; the server checks again.*/export function githubLinkOk(raw: string): { owner: string; repo: string } | null {+ const r = githubLinkCheck(raw);+ return 'owner' in r ? r : null;+}++/** Why a GitHub link fails the client's check (Mira's ui-check-459 Decision 2), each with its own line. */+export type GithubLinkProblem = 'empty' | 'http' | 'shape' | 'other_site';++/** The client's check of a GitHub link, with the reason when it fails. */+export function githubLinkCheck(raw: string): { owner: string; repo: string } | { problem: GithubLinkProblem } {const s = raw.trim();- if (!s) return null;+ if (!s) return { problem: 'empty' };let u: URL;try {u = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(s) ? s : `https://${s}`);} catch {- return null;+ return { problem: 'other_site' };}- if (u.protocol !== 'https:' || u.username || u.password || u.port) return null;- if (!['github.com', 'www.github.com'].includes(u.hostname.toLowerCase())) return null;- if (/%2e|%2f|%5c|\\/i.test(s)) return null;+ const github = ['github.com', 'www.github.com'].includes(u.hostname.toLowerCase());+ // A user or a port is "another site", whatever the host says (Decision 2).+ if (!github || u.username || u.password || u.port) return { problem: 'other_site' };+ if (u.protocol === 'http:') return { problem: 'http' };+ if (u.protocol !== 'https:') return { problem: 'other_site' };+ const shape = { problem: 'shape' as const };+ if (/%2e|%2f|%5c|\\/i.test(s)) return shape;const parts = u.pathname.replace(/\/+$/, '').split('/').slice(1);- if (parts.length < 2 || parts.some((p) => p === '' || p === '.' || p === '..')) return null;+ if (parts.length < 2 || parts.some((p) => p === '' || p === '.' || p === '..')) return shape;const [owner, rawRepo, kind, ref, ...rest] = parts;const repo = rawRepo.replace(/\.git$/, '');- if (!SEG.test(owner) || !SEG.test(repo)) return null;+ if (!SEG.test(owner) || !SEG.test(repo)) return shape;if (parts.length === 2) return { owner, repo };if (kind === 'tree' && ref && SEG.test(ref)) return { owner, repo };if (kind === 'blob' && ref && SEG.test(ref) && rest.length > 0) return { owner, repo };- return null;+ return shape;}-/** The server's 20 MB line (src/import/github.rs), in the app's typography. */-export const GITHUB_OVER_20MB = 'This repository is larger than 20 MB, so kwant can’t fetch it. Download the folder you want, zip it and import the zip instead.';+/**+ * The server's 20 MB answer (src/import/github.rs, "larger than 20 MB"), in Mira's smoother words+ * (ui-check-459 Later 4): it names the repo, as the title does, and points to the Folder row.+ */+export const GITHUB_OVER_20MB =+ 'This repo is over 20 MB, so kwant can’t download it. Download it from GitHub yourself, then bring just the part you need with Folder, or zip that part and upload it.';export const NOT_GITHUB = 'Only github.com links work here. kwant doesn’t fetch from other sites.';+export const GITHUB_HTTP = 'Use the https:// link. kwant only downloads from github.com over https.';+export const GITHUB_SHAPE = 'Link to a repo, a branch or a folder in it, like github.com/owner/repo.';++/** The rose line under the GitHub field for a link that fails the client's check. */+export const githubLinkProblemText = (p: GithubLinkProblem): string => (p === 'http' ? GITHUB_HTTP : p === 'shape' ? GITHUB_SHAPE : NOT_GITHUB);/** The ErrorBox copy for `POST /api/import/github/preview` (G4), from its code. */export function githubErrorText(err: unknown): { title: string; detail: string } {@@ -352,7 +388,7 @@ export function githubErrorText(err: unknown): { title: string; detail: string }return { title: 'No public repo at that link', detail: 'It may be private, or the branch or link may be wrong. Only public repos work for now.' };case 'too_large':// The whole download was over 20 MB (#455 11efe7d2): a folder link wouldn't help, a zip does.- if (err instanceof ImportError && /larger than 20 MB/.test(err.message))+ if (err instanceof ImportError && /(larger than|over) 20 MB/.test(err.message))return { title: 'That repo is too big', detail: GITHUB_OVER_20MB };return { title: 'That repo is too big', detail: 'Link to the folder you need instead, like …/tree/main/skills. (20 MB, or over 500 readable files.)' };case 'unsupported':diff --git a/frontend/tests/importA4.test.mjs b/frontend/tests/importA4.test.mjsindex 53fd72fe..4bf6119b 100644--- a/frontend/tests/importA4.test.mjs+++ b/frontend/tests/importA4.test.mjs@@ -390,10 +390,13 @@ test('every GitHub error code gets Mira’s words', () => {for (const [code, title] of Object.entries(want)) assert.equal(m.githubErrorText(new m.ImportError('raw', code, 422)).title, title, code);});-test('GitHub too_large: over 20 MB says to zip the folder; the 500-file case keeps the folder-link advice', () => {+test('GitHub too_large: over 20 MB gets Mira’s smoother line (Later 4); the 500-file case keeps the folder-link advice', () => {+ const want = 'This repo is over 20 MB, so kwant can’t download it. Download it from GitHub yourself, then bring just the part you need with Folder, or zip that part and upload it.';const big = m.githubErrorText(new m.ImportError("This repository is larger than 20 MB, so kwant can't fetch it. Download the folder you want, zip it and import the zip instead.", 'too_large', 413));assert.equal(big.title, 'That repo is too big');- assert.equal(big.detail, 'This repository is larger than 20 MB, so kwant can’t fetch it. Download the folder you want, zip it and import the zip instead.');+ assert.equal(big.detail, want);+ // Still matched if the server line is reworded the same way later.+ assert.equal(m.githubErrorText(new m.ImportError('This repo is over 20 MB.', 'too_large', 413)).detail, want);const many = m.githubErrorText(new m.ImportError('too many files', 'too_large', 413));assert.match(many.detail, /Link to the folder you need instead/);});@@ -513,3 +516,205 @@ test('folder picking is off on iPhone and iPad, even where the property exists',assert.equal(m.folderPickSupported(proto, { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', maxTouchPoints: 5 }), false);assert.equal(m.folderPickSupported({}, { userAgent: 'x' }), false);});++// ------------------------------------------------------------------ A4 follow-ups (release-080/a4-followups.md, Pixel 1–11)++test('item 1, F1 focus: opening Found while it looks keeps focus in the dialog, then moves to the first checkbox', async () => {+ let release;+ const d = await open({ desktop: true, over: { 'GET /api/import/local': () => new Promise((r) => (release = () => r(json(demo.localList())))) } });+ await d.click(/^Found on this computer/);+ const status = d.dlg().querySelector('[data-found-state="loading"] [role="status"]');+ assert.equal(document.activeElement, status, 'the Looking… line holds focus');+ assert.equal(status.getAttribute('tabindex'), '-1');+ assert.ok(d.dlg().contains(document.activeElement));+ release();+ await settle(12);+ const first = d.dlg().querySelector('input[type="checkbox"]');+ assert.ok(first, 'list arrived');+ assert.equal(document.activeElement, first, 'focus moves to the first checkbox');+});++test('item 1, F1 focus: a failed look moves focus to Try again', async () => {+ let release;+ const d = await open({ desktop: true, over: { 'GET /api/import/local': () => new Promise((r) => (release = () => r(fail(500, 'internal')))) } });+ await d.click(/^Found on this computer/);+ release();+ await settle(12);+ assert.match(document.activeElement.textContent, /Try again/);+});++test('item 2: Enter on the GitHub field runs Preview, with Preview’s rules', async () => {+ const d = await open();+ await d.click(/^GitHub link/);+ const form = d.dlg().querySelector('input[type="url"]').closest('form');+ assert.ok(form, 'the field is in a form');+ form.requestSubmit();+ await settle();+ assert.equal(d.s.count('POST /api/import/github/preview'), 0, 'empty: nothing sent');+ typeUrl(d.dlg, 'https://gitlab.com/a/b');+ await settle();+ form.requestSubmit();+ await settle();+ assert.equal(d.s.count('POST /api/import/github/preview'), 0, 'bad link: nothing sent');+ assert.match(d.dlg().querySelector('[role="alert"]').textContent, /Only github\.com links/);+ typeUrl(d.dlg, 'github.com/example-team/support-skills');+ await settle();+ d.dlg().querySelector('input[type="url"]').closest('form').requestSubmit();+ await settle(12);+ assert.equal(d.s.count('POST /api/import/github/preview'), 1);+ assert.equal(d.dlg().querySelector('h2').textContent, 'Check before importing');+});++test('item 3, D4: after a 415 Preview stays off until another folder is picked', async () => {+ const d = await open({ folders: true, over: { 'POST /api/import/preview': (_i, n) => (n === 1 ? fail(415, 'unsupported', 'raw') : json(demo.folderPreview())) } });+ await d.click(/^Folder/);+ pickFolder(d.dlg, [['notes/agents/readme.md', 'hi']]);+ await settle();+ primaryOf(d.dlg).click();+ await settle(12);+ assert.match(d.dlg().textContent, /Nothing kwant can bring in this folder/);+ assert.equal(primaryOf(d.dlg).disabled, true, 'Preview off for the same folder');+ assert.ok(btn(footer(d.dlg), /^Change folder$/));+ pickFolder(d.dlg, demo.folderFiles());+ await settle();+ assert.equal(primaryOf(d.dlg).disabled, false, 'a new folder clears it');+});++test('item 4: the not-GitHub line says why — http://, a github.com link of the wrong shape, or another site', async () => {+ const cases = [+ ['http://github.com/a/b', 'http', 'Use the https:// link. kwant only downloads from github.com over https.'],+ ['http://www.github.com/a/b', 'http', 'Use the https:// link. kwant only downloads from github.com over https.'],+ ['https://github.com/owner', 'shape', 'Link to a repo, a branch or a folder in it, like github.com/owner/repo.'],+ ['github.com/a/b/issues/1', 'shape', 'Link to a repo, a branch or a folder in it, like github.com/owner/repo.'],+ ['https://github.com/a/b/pull/2', 'shape', 'Link to a repo, a branch or a folder in it, like github.com/owner/repo.'],+ ['https://gist.github.com/a/b', 'other_site', 'Only github.com links work here. kwant doesn’t fetch from other sites.'],+ ['https://gitlab.com/a/b', 'other_site', 'Only github.com links work here. kwant doesn’t fetch from other sites.'],+ ['https://[email protected]/a/b', 'other_site', 'Only github.com links work here. kwant doesn’t fetch from other sites.'],+ ['https://github.com:8443/a/b', 'other_site', 'Only github.com links work here. kwant doesn’t fetch from other sites.'],+ ];+ for (const [url, problem, line] of cases) {+ assert.deepEqual(m.githubLinkCheck(url), { problem }, url);+ assert.equal(m.githubLinkProblemText(problem), line, url);+ }+ assert.deepEqual(m.githubLinkCheck('github.com/a/b'), { owner: 'a', repo: 'b' });+ const d = await open();+ await d.click(/^GitHub link/);+ for (const [url, problem, line] of cases.slice(0, 3).concat([cases[6]])) {+ typeUrl(d.dlg, url);+ await settle();+ primaryOf(d.dlg).click();+ await settle();+ const alert = d.dlg().querySelector('[role="alert"]');+ assert.equal(alert.dataset.githubProblem, problem, url);+ assert.equal(alert.textContent, line, url);+ }+ assert.equal(d.s.count('POST /api/import/github/preview'), 0);+});++test('item 4: the server’s 422 not_github keeps the plain other-sites line', async () => {+ const d = await open({ over: { 'POST /api/import/github/preview': () => fail(422, 'not_github', 'raw') } });+ await d.click(/^GitHub link/);+ typeUrl(d.dlg, 'github.com/a/b');+ await settle();+ primaryOf(d.dlg).click();+ await settle(12);+ assert.equal(d.dlg().querySelector('[role="alert"]').textContent, 'Only github.com links work here. kwant doesn’t fetch from other sites.');+});++test('item 5, Decision 3: GitHub preview with bots → Import → Done shows "From github.com/" and the licence', async () => {+ const p = demo.githubBotsPreview();+ const d = await open({ over: { 'POST /api/import/github/preview': () => json(p), 'POST /api/import/apply': () => json(demo.applied(p)) } });+ await d.click(/^GitHub link/);+ typeUrl(d.dlg, 'https://github.com/example-team/ai-team');+ await settle();+ primaryOf(d.dlg).click();+ await settle(12);+ assert.equal(primaryOf(d.dlg).textContent.trim(), 'Import 3 bots');+ primaryOf(d.dlg).click();+ await settle(12);+ assert.match(d.dlg().textContent, /Imported 3 bots/);+ const line = d.dlg().querySelector('[data-github-done]');+ assert.ok(line, 'GitHub credit on Done with bots');+ assert.equal(line.textContent, 'From github.com/example-team/ai-team (MIT).');+ assert.match(line.className, /text-\[11px\] text-zinc-400/);+ assert.match(d.dlg().textContent, /Give them an account and tools in Settings › This space/);+ // Order: title, the From line, then the names.+ assert.match(d.dlg().textContent, /Imported 3 bots.*From github\.com\/example-team\/ai-team \(MIT\)\..*Ada, Ben, Cy/);+});++test('item 6: 44 px targets on phone — per-bot tick rows and the Open on GitHub link', () => {+ const p = demo.githubBotsPreview();+ const raw = m.renderToStaticMarkup(h(m.PreviewView, { preview: p, github: p.github, skip: new Set(), onToggle() {} }));+ const ticks = raw.match(/<label class="[^"]*"[^>]*data-bot-tick/g) ?? [];+ assert.equal(ticks.length, 3);+ // The phone layout runs to 767 px (PHONE_QUERY), so the 44 px targets use max-md:, not an sm: reset at 640 px.+ for (const t of ticks) {+ assert.match(t, /max-md:min-h-11/);+ assert.doesNotMatch(t, /(^|[\s"])(min-h-11|sm:min-h-0)\b/);+ }+ const link = raw.match(/<a [^>]*class="([^"]*)"[^>]*>Open/)?.[1] ?? '';+ for (const c of ['max-md:min-h-11', 'max-md:-my-3.5', 'max-md:px-2', 'max-md:-mr-2']) assert.ok(link.split(/\s+/).includes(c), `${c} in ${link}`);+ assert.doesNotMatch(link, /\bsm:/);+});++test('item 7: an empty GitHub preview doesn’t say "Untick any you don’t want"', () => {+ const p = demo.githubEmptyPreview();+ const out = html(m.PreviewView, { preview: p, github: p.github, skip: new Set(), onToggle() {} });+ assert.doesNotMatch(out, /Untick/);+ assert.match(out, /Nothing here can be brought in: no bots and no skills\./);+ assert.match(out, /SKILL\.md is over 8,000 characters/);+ // Nothing to bring, so no "To keep you safe" line (ui-check-471 Later 2).+ assert.doesNotMatch(out, /To keep you safe/);+ // With bots, the untick line and the safety line stay.+ const b = demo.githubBotsPreview();+ const withBots = html(m.PreviewView, { preview: b, github: b.github, skip: new Set(), onToggle() {} });+ assert.match(withBots, /3 bots will be created\. Untick any you don’t want\./);+ assert.match(withBots, /To keep you safe, imported bots start with no tools/);+});++test('item 11: the phone header has one horizontal padding (px-2), desktop keeps px-4', async () => {+ const header = (d) => d.dlg().querySelector('#import-title').parentElement.className.split(/\s+/);+ let d = await open();+ assert.ok(header(d).includes('px-4') && !header(d).includes('px-2'), header(d).join(' '));+ cleanup.forEach((f) => f());+ cleanup = [];+ const was = g.window.matchMedia;+ g.window.matchMedia = (q) => ({ matches: true, media: q, addEventListener() {}, removeEventListener() {} });+ try {+ d = await open();+ const c = header(d);+ assert.ok(c.includes('h-14') && c.includes('px-2') && !c.includes('px-4'), c.join(' '));+ } finally {+ g.window.matchMedia = was;+ }+});++test('ui-check-471 must-fix: on phone the title gets pl-2 on Choose and Done (no Back), not on other steps', async () => {+ const cls = (d) => d.dlg().querySelector('#import-title').className.split(/\s+/);+ // Desktop: never pl-2.+ let d = await open();+ assert.ok(!cls(d).includes('pl-2'), cls(d).join(' '));+ cleanup.forEach((f) => f());+ cleanup = [];+ const was = g.window.matchMedia;+ g.window.matchMedia = (q) => ({ matches: true, media: q, addEventListener() {}, removeEventListener() {} });+ try {+ const p = demo.githubBotsPreview();+ d = await open({ over: { 'POST /api/import/github/preview': () => json(p), 'POST /api/import/apply': () => json(demo.applied(p)) } });+ assert.ok(cls(d).includes('pl-2'), `choose: ${cls(d).join(' ')}`);+ await d.click(/^GitHub link/);+ assert.ok(!cls(d).includes('pl-2'), `github: ${cls(d).join(' ')}`);+ typeUrl(d.dlg, 'https://github.com/example-team/ai-team');+ await settle();+ primaryOf(d.dlg).click();+ await settle(12);+ assert.equal(primaryOf(d.dlg).textContent.trim(), 'Import 3 bots');+ assert.ok(!cls(d).includes('pl-2'), `preview: ${cls(d).join(' ')}`);+ primaryOf(d.dlg).click();+ await settle(12);+ assert.match(d.dlg().textContent, /Imported 3 bots/);+ assert.ok(cls(d).includes('pl-2'), `done: ${cls(d).join(' ')}`);+ } finally {+ g.window.matchMedia = was;+ }+});diff --git a/frontend/tests/importA4Demo.mjs b/frontend/tests/importA4Demo.mjsindex 0c3be1f3..7e9b9d78 100644--- a/frontend/tests/importA4Demo.mjs+++ b/frontend/tests/importA4Demo.mjs@@ -112,3 +112,21 @@ export const folderFiles = (name = 'molty-workspace') => [[`${name}/.git/HEAD`, 'ref: refs/heads/main'],[`${name}/openclaw.json`, '{"apiKey":"sk-demo-not-real"}'],];++/** A GitHub repo of bots (ai-employees style): Done credits the repo for bots too (ui-check-459 Decision 3). */+export const githubBotsPreview = (over = {}) => {+ const p = githubPreview({ repo: 'ai-team', ...over });+ p.bundle.bots = [bot('ada', 'Ada', 'Ads lead'), bot('ben', 'Ben', 'SEO writer'), bot('cy', 'Cy', 'Support')];+ p.bundle.skills = [];+ p.bundle.source.label = `${p.github.owner}/${p.github.repo}`;+ return p;+};++/** A GitHub folder with nothing kwant can bring (qa-459 minor note 3). */+export const githubEmptyPreview = (over = {}) => {+ const p = githubPreview({ path: 'skills/doc-coauthoring', ref: 'main', ...over });+ p.bundle.skills = [];+ p.bundle.omitted = [...p.bundle.omitted, 'doc-coauthoring: SKILL.md is over 8,000 characters'];+ p.can_apply = false;+ return p;+};diff --git a/frontend/tests/importFolderPack.test.mjs b/frontend/tests/importFolderPack.test.mjsindex 2c57e16b..78b012b3 100644--- a/frontend/tests/importFolderPack.test.mjs+++ b/frontend/tests/importFolderPack.test.mjs@@ -5,7 +5,7 @@ import assert from 'node:assert/strict';import test from 'node:test';import { loadBundled } from './bundle.mjs';-const m = await loadBundled(`export { folderPlan, folderZip, leftOutKind } from './src/importSources';`);+const m = await loadBundled(`export { folderPlan, folderZip, leftOutKind, appHomes } from './src/importSources';`);const pick = (files) => files.map(([path, body = 'x']) => ({ path, size: body.length, file: new Blob([body]) }));const kept = (plan) => plan.kept.map((e) => e.path).sort();@@ -206,3 +206,80 @@ test('a generic folder drops named key files but keeps bot .json (employee.json,assert.ok(!text.includes(PROBE), 'no sk-ant-PROBE bytes in the zip');assert.equal(plan.left.find((l) => /never sent/i.test(l.label))?.count, 6, JSON.stringify(plan.left));});++// ------------------------------------------------------------------ A4 follow-ups 8–10 (Ada's #459 review items 10–12)++test('item 8: a renamed OpenClaw copy (no openclaw.json, not hidden) never sends .json under identity/ or devices/', async () => {+ const plan = m.folderPlan(+ pick([+ ['claw-backup/identity/device.json', `{"privateKey":"${PROBE}"}`],+ ['claw-backup/Identity/keys.json', `{"k":"${PROBE}"}`],+ ['claw-backup/devices/paired.json', `{"token":"${PROBE}"}`],+ ['claw-backup/devices/pending/phone.json', `{"k":"${PROBE}"}`],+ ['claw-backup/workspace/SOUL.md', 'be kind'],+ ['claw-backup/workspace/skills/x/SKILL.md', '# x'],+ ['claw-backup/team/employee.json', '{"name":"Ada"}'],+ ]),+ );+ assert.deepEqual(kept(plan), ['claw-backup/team/employee.json', 'claw-backup/workspace/SOUL.md', 'claw-backup/workspace/skills/x/SKILL.md']);+ const { names, text } = await zipNames(plan);+ assert.ok(!names.some((n) => /identity\/|devices\//i.test(n)), names.join(', '));+ assert.ok(!text.includes(PROBE), 'no key bytes in the zip');+ assert.equal(plan.left.find((l) => /never sent/i.test(l.label))?.count, 4, JSON.stringify(plan.left));+});++test('item 9: .env.example, config.yaml and config.toml alone don’t make a kit an app home; its bot .json still goes', async () => {+ const plan = m.folderPlan(+ pick([+ ['kit/.env.example', `OPENAI_API_KEY=${PROBE}`],+ ['kit/config.yaml', `api_key: ${PROBE}`],+ ['kit/cards/config.toml', `key = "${PROBE}"`],+ ['kit/employees/ada/employee.json', '{"name":"Ada"}'],+ ['kit/cards/molty.json', '{"spec":"chara_card_v2"}'],+ ['kit/skills/seo/SKILL.md', '# seo'],+ ]),+ );+ assert.deepEqual(kept(plan), ['kit/cards/molty.json', 'kit/employees/ada/employee.json', 'kit/skills/seo/SKILL.md']);+ const { names, text } = await zipNames(plan);+ assert.ok(!names.some((n) => /\.env|config\.yaml/.test(n)), names.join(', '));+ assert.ok(!text.includes(PROBE), 'the marker files themselves are never sent');+ assert.deepEqual(m.appHomes(plan.kept.map((e) => e.path).concat(['kit/.env.example', 'kit/config.yaml', 'kit/cards/config.toml'])), []);+});++test('item 9: the same markers inside an app-named folder, or next to a real key store, still mark an app home', async () => {+ const plan = m.folderPlan(+ pick([+ ['backup/openclaw/.env', `K=${PROBE}`],+ ['backup/openclaw/export.json', `{"k":"${PROBE}"}`],+ ['backup/openclaw/SOUL.md', 'be kind'],+ ['backup/hub/auth.json', `{"k":"${PROBE}"}`],+ ['backup/hub/config.yaml', `k: ${PROBE}`],+ ['backup/hub/models.json', `{"k":"${PROBE}"}`],+ ['backup/hub/AGENTS.md', 'work'],+ ]),+ );+ assert.deepEqual(kept(plan), ['backup/hub/AGENTS.md', 'backup/openclaw/SOUL.md']);+ assert.ok(!(await zipNames(plan)).text.includes(PROBE));+ assert.deepEqual(m.appHomes(['backup/openclaw/.env', 'backup/hub/auth.json']).sort(), ['hub', 'openclaw']);+});++test('item 10: "auth" anywhere is a secret (authkey, googleAuth, authinfo, authorisation); only author.json and authors-note.json go', async () => {+ const plan = m.folderPlan(+ pick([+ ['cards/authors-note.json', '{"note":"by Ada"}'],+ ['cards/author.json', '{"name":"Ada"}'],+ ['cards/my-auth.json', `{"k":"${PROBE}"}`],+ ['cards/auth_cache.json', `{"k":"${PROBE}"}`],+ ['cards/github-authz.json', `{"k":"${PROBE}"}`],+ ['cards/AUTH.yaml', `k: ${PROBE}`],+ ['cards/oauthcache.json', `{"k":"${PROBE}"}`],+ ['cards/authkey.json', `{"k":"${PROBE}"}`],+ ['cards/googleAuth.json', `{"k":"${PROBE}"}`],+ ['cards/authinfo.json', `{"k":"${PROBE}"}`],+ ['cards/authorisation.json', `{"k":"${PROBE}"}`],+ ]),+ );+ assert.deepEqual(kept(plan), ['cards/author.json', 'cards/authors-note.json']);+ assert.ok(!(await zipNames(plan)).text.includes(PROBE), 'no key bytes in the zip');+ assert.equal(plan.left.find((l) => /never sent/i.test(l.label))?.count, 9, JSON.stringify(plan.left));+});diff --git a/frontend/tests/wording.test.mjs b/frontend/tests/wording.test.mjsindex 5177eda9..16eb6401 100644--- a/frontend/tests/wording.test.mjs+++ b/frontend/tests/wording.test.mjs@@ -27,8 +27,9 @@ const MAESTRO = /\bAgent Maestro\b|\bHermes Agent\b/g;// Run Claude inside the VM (0.7.7): Mira's ui-check-450 must-fix 2 names kwant, the program on the computer,// in these settings and chat-notice sentences ("Restart kwant" is what a person on a phone has to do).// Import from this computer, a folder or a GitHub link (0.8.0 A4): Mira's a4-import.md names kwant, the program-// that looks and fetches, in these sentences.-const RULED = /\bso kwant can read\b|\bmanifests kwant knows\b|\bnames kwant knows\b|\bkwant’s (?:browser|log|own data|tools)\b|\bkwant (?:adds it|couldn’t|won’t share|keeps|is running as root|can’t pass|can’t fetch)\b|\b[Rr]estart kwant\b|\bStart kwant as\b|\bkwant (?:looked|never follows|downloads it|found nothing|doesn’t fetch)\b|\bNothing kwant can bring\b|\bwhere kwant looked\b|\bsent kwant somewhere\b/g;+// that looks and fetches, in these sentences. A4 follow-ups: Mira's ui-check-459 Later 4 ("kwant can’t download it") and+// the https-only reason ("kwant only downloads from github.com").+const RULED = /\bso kwant can read\b|\bmanifests kwant knows\b|\bnames kwant knows\b|\bkwant’s (?:browser|log|own data|tools)\b|\bkwant (?:adds it|couldn’t|won’t share|keeps|is running as root|can’t pass|can’t fetch|can’t download|only downloads)\b|\b[Rr]estart kwant\b|\bStart kwant as\b|\bkwant (?:looked|never follows|downloads it|found nothing|doesn’t fetch)\b|\bNothing kwant can bring\b|\bwhere kwant looked\b|\bsent kwant somewhere\b/g;/** Whether a literal reads like text a person sees (a sentence, or a capitalised word). */const looksVisible = (text, node) => {