Skip to content

feat: add notification queue and priority management#1700

Open
jainiksha wants to merge 2 commits into
Karanjot786:mainfrom
jainiksha:feature/notification-queue-priority-1695
Open

feat: add notification queue and priority management#1700
jainiksha wants to merge 2 commits into
Karanjot786:mainfrom
jainiksha:feature/notification-queue-priority-1695

Conversation

@jainiksha

@jainiksha jainiksha commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Added a notification queue system with priority handling and queue controls.

Changes

  • Added low, medium, and high priority levels.
  • Added notification queue management.
  • Added pause, resume, remove, and clear actions.

Closes #1695

Summary by CodeRabbit

  • New Features
    • Added a notification queue utility for managing application notifications with priority-based sorting (low, medium, high levels), customizable display durations, and comprehensive lifecycle management including add, retrieve, remove, clear, pause, and resume operations.

@jainiksha jainiksha requested a review from Karanjot786 as a code owner June 20, 2026 20:04
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new NotificationQueue class in packages/widgets/src/feedback/NotificationQueue.ts that manages in-memory Notification objects with priority-based sorting, default values for priority and duration, and pause/resume state. The class and its associated types are re-exported from the package's public entry point alongside a new SplitPaneOptions type export.

Changes

NotificationQueue feature

Layer / File(s) Summary
Notification types and NotificationQueue implementation
packages/widgets/src/feedback/NotificationQueue.ts
Defines NotificationPriority ("low" | "medium" | "high") and Notification interface, then implements NotificationQueue with add() (applies "medium" priority and 3000 ms duration defaults, sorts queue by descending priority), getAll(), remove(id), clear(), and pause()/resume()/isPaused() pause-state controls.
Public API re-exports
packages/widgets/src/index.ts
Adds NotificationQueue, Notification, and NotificationPriority to the package public exports. Also adds a standalone SplitPaneOptions type re-export from ./layout/SplitPane.js.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop, hop, a queue in line,
High-priority carrots first in time!
Pause the crunch, resume the bite,
Each notification ordered right.
No toast gets lost — the rabbit's delight! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers main changes and links the issue, but omits several required sections including package, type of change, and pre-merge checklist. Complete the PR template by adding the package name (@termuijs/widgets), checking the feature type box, and verifying the pre-merge checklist items.
Out of Scope Changes check ⚠️ Warning All changes directly support the notification queue feature. The addition of SplitPaneOptions export appears unrelated to the primary objective and may represent scope creep. Remove the unrelated SplitPaneOptions export from index.ts or provide justification for its inclusion in this feature PR.
Linked Issues check ❓ Inconclusive The implementation addresses core requirements: queue management, priority levels, and pause/resume functionality. However, auto-grouping similar messages and custom duration options are not fully evident from the code summary. Clarify whether message grouping [#1695] is implemented or deferred, and confirm custom duration support works as intended in the codebase.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main addition: a notification queue system with priority management features.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added type:feature +10 pts. New feature. area:widgets @termuijs/widgets labels Jun 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/widgets/src/feedback/NotificationQueue.ts`:
- Around line 32-33: The getAll() method in NotificationQueue exposes the
mutable internal queue array directly, allowing callers to modify it and bypass
the add() method's invariants like priority defaults and sorting. Fix this by
returning a shallow copy of the queue array instead of returning this.queue
directly, using either the spread operator or the slice() method to create a new
array instance that callers can modify without affecting the internal state.

In `@packages/widgets/src/index.ts`:
- Around line 132-139: The `SplitPaneOptions` type is being exported twice from
the same source file './layout/SplitPane.js'. Remove `SplitPaneOptions` from the
second export statement (the one that also exports `SplitDirection`) and keep
only `SplitDirection` in that second export. The first export of
`SplitPaneOptions` on line 132 should remain unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b4c416c3-9c74-43e5-80af-3a83d0ef5c2e

📥 Commits

Reviewing files that changed from the base of the PR and between 3c064c4 and 1980d9b.

📒 Files selected for processing (2)
  • packages/widgets/src/feedback/NotificationQueue.ts
  • packages/widgets/src/index.ts

Comment on lines +32 to +33
getAll(): Notification[] {
return this.queue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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
-    getAll(): Notification[] {
-        return this.queue;
-    }
+    getAll(): ReadonlyArray<Notification> {
+        return [...this.queue];
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
getAll(): Notification[] {
return this.queue;
getAll(): ReadonlyArray<Notification> {
return [...this.queue];
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/widgets/src/feedback/NotificationQueue.ts` around lines 32 - 33, The
getAll() method in NotificationQueue exposes the mutable internal queue array
directly, allowing callers to modify it and bypass the add() method's invariants
like priority defaults and sorting. Fix this by returning a shallow copy of the
queue array instead of returning this.queue directly, using either the spread
operator or the slice() method to create a new array instance that callers can
modify without affecting the internal state.

Comment on lines +132 to 139
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';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify duplicate SplitPaneOptions type exports in the index module
rg -n "export type \{[^}]*SplitPaneOptions" packages/widgets/src/index.ts

Repository: Karanjot786/TermUI

Length of output: 212


🏁 Script executed:

sed -n '130,141p' packages/widgets/src/index.ts

Repository: 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 -d

Repository: Karanjot786/TermUI

Length of output: 44


Remove duplicate SplitPaneOptions type export.

SplitPaneOptions is exported on line 132 and again on line 139. TypeScript will error on the duplicate identifier. Keep the export on line 132 and remove it from line 139.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 { SplitPaneOptions } from './layout/SplitPane.js';
export { NotificationQueue } from "./feedback/NotificationQueue.js";
export type {
Notification,
NotificationPriority
} from "./feedback/NotificationQueue.js";
export type { SplitDirection } from './layout/SplitPane.js';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/widgets/src/index.ts` around lines 132 - 139, The `SplitPaneOptions`
type is being exported twice from the same source file './layout/SplitPane.js'.
Remove `SplitPaneOptions` from the second export statement (the one that also
exports `SplitDirection`) and keep only `SplitDirection` in that second export.
The first export of `SplitPaneOptions` on line 132 should remain unchanged.

@jainiksha

Copy link
Copy Markdown
Contributor Author

@Karanjot786 resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:widgets @termuijs/widgets type:feature +10 pts. New feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Terminal Toast Queue and Notification Prioritization

1 participant