refactor(electrobun): modularize stores + shared UI components
Stores: - notifications-store.svelte.ts: owns notifications array (was inline in App) - workspace-store.svelte.ts: extended with addProjectFromWizard, loadGroupsFromDb, loadProjectsFromDb, derived getters (totalCost, totalTokens, mountedGroupIds) Shared UI components (ui/): - SegmentedControl.svelte: replaces repeated .seg button groups - SliderInput.svelte: labeled range slider with value display - StatusDot.svelte: colored dot with pulse support - IconButton.svelte: icon-only button with tooltip, 3 sizes - Section.svelte: settings section wrapper with heading App.svelte: script 390→221 lines (removed all inline CRUD, delegates to stores) ProjectCard: uses StatusDot shared component AgentSettings + OrchestrationSettings: use SegmentedControl, SliderInput, Section
This commit is contained in:
parent
265ddd3f1d
commit
c88577a34a
12 changed files with 647 additions and 437 deletions
49
ui-electrobun/src/mainview/notifications-store.svelte.ts
Normal file
49
ui-electrobun/src/mainview/notifications-store.svelte.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Notifications store — owns notification list and toast integration.
|
||||
*
|
||||
* Extracted from App.svelte inline state (Phase 2).
|
||||
*/
|
||||
|
||||
// ── Types ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface Notification {
|
||||
id: number;
|
||||
message: string;
|
||||
type: 'success' | 'warning' | 'info' | 'error';
|
||||
time: string;
|
||||
}
|
||||
|
||||
// ── State ─────────────────────────────────────────────────────────────────
|
||||
|
||||
let notifications = $state<Notification[]>([
|
||||
{ id: 1, message: 'Agent completed: wake scheduler implemented', type: 'success', time: '2m ago' },
|
||||
{ id: 2, message: 'Context pressure: 78% on agent-orchestrator', type: 'warning', time: '5m ago' },
|
||||
{ id: 3, message: 'PTY daemon connected', type: 'info', time: '12m ago' },
|
||||
]);
|
||||
|
||||
let nextId = $state(100);
|
||||
|
||||
// ── Public API ────────────────────────────────────────────────────────────
|
||||
|
||||
export function getNotifications(): Notification[] {
|
||||
return notifications;
|
||||
}
|
||||
|
||||
export function getNotifCount(): number {
|
||||
return notifications.length;
|
||||
}
|
||||
|
||||
export function addNotification(message: string, type: Notification['type'] = 'info'): void {
|
||||
const now = new Date();
|
||||
const time = `${now.getHours()}:${String(now.getMinutes()).padStart(2, '0')}`;
|
||||
const id = nextId++;
|
||||
notifications = [{ id, message, type, time }, ...notifications].slice(0, 100);
|
||||
}
|
||||
|
||||
export function removeNotification(id: number): void {
|
||||
notifications = notifications.filter(n => n.id !== id);
|
||||
}
|
||||
|
||||
export function clearAll(): void {
|
||||
notifications = [];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue