-
Notifications
You must be signed in to change notification settings - Fork 199
feat: add notification queue and priority management #1700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| export type NotificationPriority = "low" | "medium" | "high"; | ||
|
|
||
| export interface Notification { | ||
| id: string; | ||
| message: string; | ||
| priority?: NotificationPriority; | ||
| duration?: number; | ||
| } | ||
|
|
||
| export class NotificationQueue { | ||
| private queue: Notification[] = []; | ||
| private paused = false; | ||
|
|
||
| add(notification: Notification): void { | ||
| this.queue.push({ | ||
| priority: "medium", | ||
| duration: 3000, | ||
| ...notification, | ||
| }); | ||
|
|
||
| this.queue.sort((a, b) => { | ||
| const order = { | ||
| high: 3, | ||
| medium: 2, | ||
| low: 1, | ||
| }; | ||
|
|
||
| return order[b.priority!] - order[a.priority!]; | ||
| }); | ||
| } | ||
|
|
||
| getAll(): Notification[] { | ||
| return this.queue; | ||
| } | ||
|
|
||
| remove(id: string): void { | ||
| this.queue = this.queue.filter( | ||
| item => item.id !== id | ||
| ); | ||
| } | ||
|
|
||
| clear(): void { | ||
| this.queue = []; | ||
| } | ||
|
|
||
| pause(): void { | ||
| this.paused = true; | ||
| } | ||
|
|
||
| resume(): void { | ||
| this.paused = false; | ||
| } | ||
|
|
||
| isPaused(): boolean { | ||
| return this.paused; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -129,6 +129,13 @@ export type { DraggableOptions, DroppableOptions } from './layout/DragAndDrop.js | |||||||||||||||||||||||||||||||||
| export { Fill } from './layout/Fill.js'; | ||||||||||||||||||||||||||||||||||
| export type { FillOptions } from './layout/Fill.js'; | ||||||||||||||||||||||||||||||||||
| export { SplitPane } from './layout/SplitPane.js'; | ||||||||||||||||||||||||||||||||||
| export type { SplitPaneOptions } from './layout/SplitPane.js'; | ||||||||||||||||||||||||||||||||||
| export { NotificationQueue } from "./feedback/NotificationQueue.js"; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export type { | ||||||||||||||||||||||||||||||||||
| Notification, | ||||||||||||||||||||||||||||||||||
| NotificationPriority | ||||||||||||||||||||||||||||||||||
| } from "./feedback/NotificationQueue.js"; | ||||||||||||||||||||||||||||||||||
| export type { SplitPaneOptions, SplitDirection } from './layout/SplitPane.js'; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+132
to
139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify duplicate SplitPaneOptions type exports in the index module
rg -n "export type \{[^}]*SplitPaneOptions" packages/widgets/src/index.tsRepository: Karanjot786/TermUI Length of output: 212 🏁 Script executed: sed -n '130,141p' packages/widgets/src/index.tsRepository: Karanjot786/TermUI Length of output: 536 🏁 Script executed: # Check for any other duplicate exports in the file
rg "^export (type )?\{ [^}]*\}" packages/widgets/src/index.ts | sort | uniq -dRepository: Karanjot786/TermUI Length of output: 44 Remove duplicate
Fix export { SplitPane } from './layout/SplitPane.js';
export type { SplitPaneOptions } from './layout/SplitPane.js';
export { NotificationQueue } from "./feedback/NotificationQueue.js";
export type {
Notification,
NotificationPriority
} from "./feedback/NotificationQueue.js";
-export type { SplitPaneOptions, SplitDirection } from './layout/SplitPane.js';
+export type { SplitDirection } from './layout/SplitPane.js';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // ── Feedback Widgets ────────────────────────────────── | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAll()exposes mutable internal state.Line 33 returns the backing array directly, so callers can mutate queue contents/order and bypass
add()invariants (priority defaults + sorting).Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents