Skip to content

Commit 85bbf50

Browse files
committed
Allow the first queued chat to initialize even when the browser is not focused and delay subsequent focus-triggered processing by 2 seconds
- current behavior: user can fill the queue and no items will be initialized until the browser is focused. expected behavior: initialize the very first item in the queue immediately and wait for browser focus to initialize the others. └── apps └── browser ├── .eslintrc.json ├── .gitignore ├── README.md ├── create-firefox-build.ts ├── package.json ├── src │ ├── background │ │ ├── clear-chat-init-data.ts │ │ ├── config.ts │ │ ├── keep-alive.ts │ │ ├── main.ts │ │ ├── message-handler.ts │ │ └── websocket.ts │ ├── content-scripts │ │ └── send-prompt-content-script │ │ ├── chatbots │ │ │ ├── ai-studio.ts │ │ │ ├── arena.ts │ │ │ ├── chatgpt.ts │ │ │ ├── claude.ts │ │ │ ├── copilot.ts │ │ │ ├── deepseek.ts │ │ │ ├── doubao.ts │ │ │ ├── gemini.ts │ │ │ ├── github-copilot.ts │ │ │ ├── grok.ts │ │ │ ├── hugging-chat.ts │ │ │ ├── index.ts │ │ │ ├── kimi.ts │ │ │ ├── meta.ts │ │ │ ├── mistral.ts │ │ │ ├── open-webui.ts │ │ │ ├── openrouter.ts │ │ │ ├── qwen.ts │ │ │ ├── together.ts │ │ │ ├── yuanbao.ts │ │ │ └── z-ai.ts │ │ ├── constants │ │ │ ├── apply-response-icon.ts │ │ │ └── dictionary.ts │ │ ├── send-prompt-content-script.ts │ │ ├── types │ │ │ └── chatbot.ts │ │ └── utils │ │ ├── add-apply-response-button.ts │ │ ├── apply-response-styles.ts │ │ ├── logger.ts │ │ ├── report-initialization-error.ts │ │ └── show-response-ready-notification.ts │ ├── fonts │ │ └── Bangers-Regular.ttf │ ├── icons │ │ ├── icon-128.png │ │ ├── icon-16.png │ │ ├── icon-32.png │ │ └── icon-48.png │ ├── manifest.json │ ├── types │ │ └── messages.ts │ ├── utils │ │ └── is-message.ts │ └── views │ └── popup │ ├── App.tsx │ ├── Popup.module.scss │ ├── Popup.tsx │ ├── index.css │ ├── index.html │ ├── use-browser-profile-name.ts │ └── use-firefox-containers.ts ├── tsconfig.json └── webpack.config.ts
1 parent b19b757 commit 85bbf50

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

‎apps/browser/create-zip-archives.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ const main = async () => {
6868

6969
log(`Successfully created ZIP archives for version ${version}`)
7070
} catch (error) {
71-
log(`Error creating ZIP archives: ${error.message}`)
71+
log(
72+
`Error creating ZIP archives: ${error instanceof Error ? error.message : String(error)}`
73+
)
7274
process.exit(1)
7375
}
7476
}

‎apps/browser/src/background/message-handler.ts‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface ChatQueueItem {
1515
const chat_queue: ChatQueueItem[] = []
1616
let is_processing = false
1717
let is_waiting_for_focus = false
18-
let is_first_focus_for_queue = true
18+
let is_first_item_in_queue = true
1919
let last_opened_tab_id: number | undefined
2020
let is_finished_responding = false
2121

@@ -63,12 +63,12 @@ const process_next_chat = async () => {
6363
}
6464

6565
const has_focus = await check_browser_focus()
66-
if (!has_focus) {
66+
if (!has_focus && !is_first_item_in_queue) {
6767
is_waiting_for_focus = true
6868
return
6969
}
7070

71-
is_first_focus_for_queue = false
71+
is_first_item_in_queue = false
7272

7373
const current_queue_item = chat_queue[0]
7474

@@ -156,7 +156,7 @@ const process_next_chat = async () => {
156156
const start_processing = async () => {
157157
if (!is_processing && chat_queue.length > 0) {
158158
is_processing = true
159-
is_first_focus_for_queue = true
159+
is_first_item_in_queue = true
160160
await process_next_chat()
161161
}
162162
}
@@ -183,14 +183,9 @@ export const setup_message_listeners = () => {
183183
if (window_id !== browser.windows.WINDOW_ID_NONE) {
184184
if (is_waiting_for_focus) {
185185
is_waiting_for_focus = false
186-
if (is_first_focus_for_queue) {
187-
is_first_focus_for_queue = false
186+
setTimeout(() => {
188187
process_next_chat()
189-
} else {
190-
setTimeout(() => {
191-
process_next_chat()
192-
}, 2000)
193-
}
188+
}, 2000)
194189
}
195190
}
196191
})

0 commit comments

Comments
 (0)