From 5d29d03b83b7035a8d9e9ab70f2333981bb1b7c5 Mon Sep 17 00:00:00 2001 From: Jeremy SNIDARO Date: Fri, 22 May 2026 16:16:11 +0200 Subject: [PATCH] feat: use persistent container color from Leapp session When Leapp sends a sessionColor on the create-new-session WebSocket message, Firefox containers are created (or updated) with that color instead of a random fallback. Existing containers are updated in place if the color changed since they were last opened. Requires: Noovolari/leapp# Signed-off-by: Jeremy Snidaro Signed-off-by: Jeremy SNIDARO --- manifest-chrome.json | 2 +- manifest-firefox.json | 2 +- package.json | 2 +- src/backend/models/leapp-session-info.ts | 1 + .../services/tab-controller.service.ts | 36 ++++++++++++------- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/manifest-chrome.json b/manifest-chrome.json index 14668c1..07758a9 100644 --- a/manifest-chrome.json +++ b/manifest-chrome.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Leapp Multi-Console Extension", - "version": "0.1.8", + "version": "0.1.9", "description": "Leapp Multi AWS Console Browser Extension", "icons": { "16": "icons/icon_16.png", diff --git a/manifest-firefox.json b/manifest-firefox.json index 0a3e533..a562f84 100644 --- a/manifest-firefox.json +++ b/manifest-firefox.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Leapp Multi-Console Extension", - "version": "0.1.8", + "version": "0.1.9", "description": "Leapp Multi AWS Console Browser Extension", "icons": { "16": "icons/icon_16.png", diff --git a/package.json b/package.json index 62ff010..5db19bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leapp-browser-extension", - "version": "0.1.8", + "version": "0.1.9", "author": { "name": "Noovolari", "email": "info@noovolari.com" diff --git a/src/backend/models/leapp-session-info.ts b/src/backend/models/leapp-session-info.ts index 9fad5c0..063886e 100644 --- a/src/backend/models/leapp-session-info.ts +++ b/src/backend/models/leapp-session-info.ts @@ -6,5 +6,6 @@ export interface LeappSessionInfo { sessionRegion: string; sessionRole: string; sessionType: LeappSessionType; + sessionColor?: string; createdAt: number; } diff --git a/src/backend/services/tab-controller.service.ts b/src/backend/services/tab-controller.service.ts index 904d389..d52fcc6 100644 --- a/src/backend/services/tab-controller.service.ts +++ b/src/backend/services/tab-controller.service.ts @@ -47,7 +47,12 @@ export class TabControllerService { if (this.state.isChrome) { this.newChromeSessionTab(leappPayload.url); } else { - this.newFirefoxSessionTab(leappPayload.url, `${leappPayload.sessionName} (${leappPayload.sessionRole})`, sessionId).then(() => {}); + this.newFirefoxSessionTab( + leappPayload.url, + `${leappPayload.sessionName} (${leappPayload.sessionRole})`, + sessionId, + leappPayload.sessionColor + ).then(() => {}); } } @@ -68,21 +73,28 @@ export class TabControllerService { }); } - private async newFirefoxSessionTab(url: string, containerName: string, sessionId: number) { - const colorIndex = this.state.sessionCounter % containerColors.length; + private async newFirefoxSessionTab(url: string, containerName: string, sessionId: number, preferredColor?: string) { + const fallbackColorIndex = this.state.sessionCounter % containerColors.length; + const color = preferredColor ?? containerColors[fallbackColorIndex]; const container = await this.getBrowser() .contextualIdentities.query({ name: containerName, }) - .then( - (contexts) => - contexts.pop() || - this.getBrowser().contextualIdentities.create({ - name: containerName, - color: containerColors[colorIndex], - icon: "circle", - }) - ); + .then(async (contexts) => { + const existing = contexts.pop(); + if (existing) { + if (preferredColor && existing.color !== preferredColor) { + await this.getBrowser().contextualIdentities.update(existing.cookieStoreId, { color: preferredColor }); + return this.getBrowser().contextualIdentities.get(existing.cookieStoreId); + } + return existing; + } + return this.getBrowser().contextualIdentities.create({ + name: containerName, + color, + icon: "circle", + }); + }); this.state.setCookieStoreId(sessionId, container.cookieStoreId); await this.getBrowser().tabs.create({ url,