M1.12: notifications as toasts
The host publishes picker, command-line and pump errors as notification events (Engine::notify, same id sequence) instead of stderr, keeps notifications and watchFailed published before engine_ready and replays them after the state replay, so startup warnings (corrupt settings, journal entries) reach the UI. ipc.ts announces engine_ready once all subscriptions started together are registered. Frontend: notifications store and NotificationStack (bottom right, info auto-dismissed after 5 s, warnings/errors stay, close button and Escape, at most 5 visible with "+n more", role status/alert); watchFailed maps to a warning toast; failed commands without their own UI raise an error toast. Catalog keys notification.settings.*, project.*, vfs.*, watch.*, command.* plus the runtime allow-list. Docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7b7273a947
commit
f41df518b5
21 changed files with 1178 additions and 94 deletions
168
ui/src/components/notifications/NotificationStack.vue
Normal file
168
ui/src/components/notifications/NotificationStack.vue
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* The toast stack at the bottom right of the window, newest at the bottom.
|
||||
*
|
||||
* Shows the toasts of the notifications store: info toasts as
|
||||
* `role="status"`, warnings and errors as `role="alert"`. Each toast has a
|
||||
* close button and closes with Escape while focus is inside it; older
|
||||
* toasts beyond the visible limit collapse into a "+n more" button. The
|
||||
* colours match the editor's in-place notices (`--lt-notice-bg`, the error
|
||||
* tint).
|
||||
*/
|
||||
import { CircleAlert, Info, TriangleAlert, X } from "@lucide/vue";
|
||||
import { t } from "../../i18n";
|
||||
import { useNotificationsStore, type NotificationLevel } from "../../stores/notifications";
|
||||
|
||||
const notifications = useNotificationsStore();
|
||||
|
||||
/** Icon of each level. */
|
||||
const ICONS = { info: Info, warning: TriangleAlert, error: CircleAlert } as const;
|
||||
|
||||
/**
|
||||
* ARIA role of a toast: errors and warnings interrupt, info is polite.
|
||||
*
|
||||
* @param level - the toast's level.
|
||||
*/
|
||||
function roleOf(level: NotificationLevel): "status" | "alert" {
|
||||
return level === "info" ? "status" : "alert";
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="notifications.toasts.length > 0"
|
||||
class="toasts"
|
||||
:aria-label="t('notification.stack.label')"
|
||||
data-test="toasts"
|
||||
>
|
||||
<button
|
||||
v-if="notifications.hiddenCount > 0"
|
||||
type="button"
|
||||
class="toasts__more"
|
||||
data-test="toasts-more"
|
||||
@click="notifications.expand()"
|
||||
>
|
||||
{{ t("notification.stack.more", { count: notifications.hiddenCount }) }}
|
||||
</button>
|
||||
<div
|
||||
v-for="toast in notifications.visible"
|
||||
:key="toast.id"
|
||||
class="toast"
|
||||
:class="`toast--${toast.level}`"
|
||||
:role="roleOf(toast.level)"
|
||||
data-test="toast"
|
||||
:data-level="toast.level"
|
||||
@keydown.escape.stop="notifications.dismiss(toast.id)"
|
||||
>
|
||||
<component
|
||||
:is="ICONS[toast.level]"
|
||||
class="toast__icon"
|
||||
:size="16"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span
|
||||
class="toast__text"
|
||||
data-test="toast-text"
|
||||
>{{ toast.text }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="toast__close"
|
||||
:aria-label="t('notification.close')"
|
||||
:title="t('notification.close')"
|
||||
data-test="toast-close"
|
||||
@click="notifications.dismiss(toast.id)"
|
||||
>
|
||||
<X
|
||||
:size="14"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.toasts {
|
||||
position: fixed;
|
||||
right: 16px;
|
||||
bottom: 36px;
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
width: min(420px, calc(100vw - 32px));
|
||||
max-height: calc(100vh - 72px);
|
||||
overflow-y: auto;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.toast {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 8px 8px 8px 12px;
|
||||
color: var(--lt-fg);
|
||||
background: var(--lt-notice-bg);
|
||||
border: 1px solid var(--lt-border);
|
||||
border-left: 3px solid var(--lt-fg-muted);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.toast--warning {
|
||||
border-left-color: var(--lt-accent);
|
||||
}
|
||||
|
||||
.toast--error {
|
||||
background: color-mix(in srgb, var(--lt-error) 15%, var(--lt-bg));
|
||||
border-left-color: var(--lt-error);
|
||||
}
|
||||
|
||||
.toast__icon {
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
color: var(--lt-fg-muted);
|
||||
}
|
||||
|
||||
.toast--warning .toast__icon {
|
||||
color: var(--lt-accent);
|
||||
}
|
||||
|
||||
.toast--error .toast__icon {
|
||||
color: var(--lt-error);
|
||||
}
|
||||
|
||||
.toast__text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.toast__close,
|
||||
.toasts__more {
|
||||
font: inherit;
|
||||
color: var(--lt-fg);
|
||||
background: transparent;
|
||||
border: 1px solid var(--lt-border);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.toast__close {
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.toasts__more {
|
||||
padding: 2px 8px;
|
||||
background: var(--lt-notice-bg);
|
||||
}
|
||||
|
||||
.toast__close:focus-visible,
|
||||
.toasts__more:focus-visible {
|
||||
outline: 2px solid var(--lt-accent);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue