Slice 12: inline command-result toasts

New <toast-host> overlay: components post 'toast' CustomEvents ({message, kind: success|error|info}) and it shows brief, auto-dismissing, bottom-right toasts (errors linger). <repo-menu> (git + coordination actions) and <pr-list> (create/merge) now post friendly success/error toasts instead of alert(); the activity feed still logs everything. Also adds the slice 11 CHANGELOG entry. Verified live: 'Checked for updates' toast shown.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 17:50:32 -04:00
parent 68b6c3a3f8
commit 34ed127653
6 changed files with 139 additions and 4 deletions
+23 -2
View File
@@ -135,12 +135,15 @@ class RepoMenu extends HTMLElement {
}
case 'active':
await this.#post('/api/active-project', { path: repo.path });
this.#toast(`${name} is now the active project`, 'info');
break;
case 'handoff':
await this.#post('/api/switch', { target: repo.path });
this.#toast(`Asked Claude to switch to ${name}`, 'info');
break;
case 'copy':
try { await navigator.clipboard.writeText(repo.path); } catch { /* ignore */ }
try { await navigator.clipboard.writeText(repo.path); this.#toast('Path copied', 'info'); }
catch { this.#toast('Could not copy path', 'error'); }
break;
}
}
@@ -150,6 +153,19 @@ class RepoMenu extends HTMLElement {
await this.#git('checkout', { branch });
}
#okLabel(op, extra) {
switch (op) {
case 'pull': return 'Got the latest';
case 'push': return 'Published';
case 'fetch': return 'Checked for updates';
case 'commit': return 'Saved your work';
case 'checkout': return `Switched to ${extra.branch}`;
case 'create-branch': return `Created branch ${extra.branch}`;
case 'discard': return 'Discarded changes';
default: return 'Done';
}
}
async #git(op, extra = {}) {
try {
const res = await fetch('/api/repo/git', {
@@ -159,11 +175,16 @@ class RepoMenu extends HTMLElement {
});
const data = await res.json();
if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`);
this.#toast(this.#okLabel(op, extra), 'success');
} catch (err) {
window.alert(`${op} failed: ${err.message}`);
this.#toast(`${this.#okLabel(op, extra)} failed: ${err.message}`, 'error');
}
}
#toast(message, kind) {
document.dispatchEvent(new CustomEvent('toast', { detail: { message, kind } }));
}
async #post(url, body) {
try {
await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });