Skip to content

Add multi-instance support#312

Open
hogejiro wants to merge 1 commit intosindresorhus:mainfrom
hogejiro:feature/multi_instances
Open

Add multi-instance support#312
hogejiro wants to merge 1 commit intosindresorhus:mainfrom
hogejiro:feature/multi_instances

Conversation

@hogejiro
Copy link
Copy Markdown

Summary

Addresses #290 and #260.
Adds support for multiple GitHub instances (e.g., github.com + GitHub Enterprise) with per-instance notification tracking.

  • Primary instance uses native badge, secondary uses Canvas pill (top-left)
image
  • Popup for selecting which instance to open
image
  • Options page with multiple instances
image
image
  • Options page adapts: single instance shows original-style UI, 2+ shows list with inline editor

  • Auto-migration from single-instance settings

  • GHE host permissions requested at runtime via optional_host_permissions

New *-multi files sit alongside originals — no existing files are deleted.

Test plan

  • Fresh install: original-style single-instance UI
  • Add token: notifications appear with native badge
  • Add second instance: switches to multi view, GHE host permission requested
  • Badge: most notifications → native (bottom-right), second → Canvas (top-left)
  • Click icon: popup when 2+ have notifications, direct open when 1
  • Delete instance: confirm → Undo (15s countdown)
  • Delete to 1 instance: Undo available, then auto-switches to single view
  • Existing users: automatic migration on update

Supported by Claude Code

}
}

const BADGE_POSITIONS = ['bottom-right', 'top-left'];
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorted by notification count descending. Only 2 slots —
bottom-right uses native setBadgeText for best readability,
top-left uses Canvas. 3rd+ are visible in popup/tooltip only.

export async function getInstances() {
const {[STORAGE_KEY]: instances = []} = await browser.storage.local.get(STORAGE_KEY);

// Backfill colorIndex for instances created before this field existed
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Instances created before colorIndex was added get a stable index assigned on first read, so colors don't shift on delete.


// Assign a stable color index if not provided
if (data.colorIndex === undefined) {
const usedIndices = new Set(instances.map(i => i.colorIndex).filter(i => i !== undefined));
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Finds the lowest unused index rather than using array length,
so deleted instance colors can be reused without collisions.

@notlmn notlmn assigned sindresorhus and unassigned sindresorhus Mar 27, 2026
@notlmn notlmn requested a review from sindresorhus March 27, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants