browser-assistant 2.9.2 → 2.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,101 @@
1
+ const DETACHED_PANEL_KEY = 'assistantDetachedPanel';
2
+ const DETACHED_PANEL_MODE = 'assistantPanelMode';
3
+ const detachedPage = () => chrome.runtime.getURL('detached-panel.html');
4
+ let detachedPanelQueue = Promise.resolve();
5
+ function serializeDetachedPanel(action) {
6
+ const result = detachedPanelQueue.then(action);
7
+ detachedPanelQueue = result.catch(() => undefined);
8
+ return result;
9
+ }
10
+ async function detachedPanelSession() {
11
+ return (await chrome.storage.session.get(DETACHED_PANEL_KEY))[DETACHED_PANEL_KEY];
12
+ }
13
+ function messagePanelTab(tabId, message) {
14
+ return chrome.tabs.sendMessage(tabId, message, { frameId: 0 });
15
+ }
16
+ async function releasePanelTab(session) {
17
+ await messagePanelTab(session.targetTabId, { action: 'assistantPanelDetach', token: session.token })
18
+ .catch(() => undefined);
19
+ }
20
+ async function openDetachedPanel(tabId) {
21
+ const tab = await chrome.tabs.get(tabId);
22
+ if (!tab.active || !/^https?:\/\//.test(tab.url || '')) {
23
+ throw Error('Open the toolbar on the web tab you want to control.');
24
+ }
25
+ const ready = await messagePanelTab(tabId, { action: 'assistantPanelPing' }).catch(() => null);
26
+ if (!ready?.ok)
27
+ throw Error('Refresh the web tab to load Browser Assistant, then try again.');
28
+ let previous = await detachedPanelSession();
29
+ const existing = previous && await chrome.windows.get(previous.windowId, { populate: true }).catch(() => null);
30
+ if (previous && !existing?.tabs?.some(item => (item.url || item.pendingUrl) === detachedPage())) {
31
+ await releasePanelTab(previous);
32
+ await chrome.storage.session.remove(DETACHED_PANEL_KEY);
33
+ previous = undefined;
34
+ }
35
+ const created = previous ? undefined : await chrome.windows.create({
36
+ url: detachedPage(), type: 'popup', width: 420, height: 690, focused: true,
37
+ });
38
+ const windowId = previous?.windowId ?? created?.id;
39
+ if (windowId === undefined)
40
+ throw Error('Chrome could not open the separate panel.');
41
+ if (previous && previous.targetTabId !== tabId)
42
+ await releasePanelTab(previous);
43
+ const session = previous?.targetTabId === tabId ? previous : { windowId, targetTabId: tabId, token: crypto.randomUUID() };
44
+ await chrome.storage.session.set({ [DETACHED_PANEL_KEY]: session });
45
+ await chrome.storage.local.set({ [DETACHED_PANEL_MODE]: 'separate' });
46
+ if (previous)
47
+ await chrome.windows.update(windowId, { focused: true, state: 'normal' });
48
+ return { ok: true };
49
+ }
50
+ function browserAssistantDetachedMessage(request, sender, reply) {
51
+ if (sender.id !== chrome.runtime.id) {
52
+ reply({ error: 'Extension sender required.' });
53
+ return false;
54
+ }
55
+ void serializeDetachedPanel(async () => {
56
+ if (request.action === 'panel:open' && sender.url === chrome.runtime.getURL('popup.html')) {
57
+ if (!Number.isInteger(request.targetTabId))
58
+ throw Error('Choose a web tab first.');
59
+ return openDetachedPanel(request.targetTabId);
60
+ }
61
+ const session = await detachedPanelSession();
62
+ if (request.action === 'panel:target-status' && sender.tab && sender.frameId === 0) {
63
+ return { token: session?.targetTabId === sender.tab.id ? session.token : '' };
64
+ }
65
+ if (sender.url !== detachedPage() || !session || sender.tab?.windowId !== session.windowId) {
66
+ throw Error('Open the separate panel from the Browser Assistant toolbar on a web tab.');
67
+ }
68
+ if (request.action === 'panel:return') {
69
+ await chrome.storage.local.set({ [DETACHED_PANEL_MODE]: 'floating' });
70
+ await chrome.storage.session.remove(DETACHED_PANEL_KEY);
71
+ await releasePanelTab(session);
72
+ await chrome.windows.remove(session.windowId);
73
+ return { ok: true };
74
+ }
75
+ const tab = await chrome.tabs.get(session.targetTabId).catch(() => null);
76
+ if (!tab)
77
+ throw Error('The selected tab was closed. Open the toolbar on another web tab to reconnect.');
78
+ if (!/^https?:\/\//.test(tab.url || ''))
79
+ throw Error('Return to a webpage in the selected tab.');
80
+ if (request.action === 'panel:action' && request.token !== session.token) {
81
+ throw Error('The selected tab changed. Try the control again.');
82
+ }
83
+ const response = await messagePanelTab(tab.id, {
84
+ action: request.action === 'panel:snapshot' ? 'assistantPanelSnapshot' : 'assistantPanelAction',
85
+ token: session.token, panelControl: request.panelControl, operation: request.operation, value: request.value,
86
+ }).catch(() => null);
87
+ if (!response)
88
+ throw Error('Waiting for Browser Assistant in the selected tab. Refresh that tab if needed.');
89
+ return { ...response, token: session.token, title: tab.title || new URL(tab.url).hostname, active: tab.active };
90
+ }).then(reply, error => reply({ error: error.message }));
91
+ return true;
92
+ }
93
+ chrome.windows.onRemoved.addListener(windowId => {
94
+ void serializeDetachedPanel(async () => {
95
+ const session = await detachedPanelSession();
96
+ if (session?.windowId !== windowId)
97
+ return;
98
+ await chrome.storage.session.remove(DETACHED_PANEL_KEY);
99
+ await releasePanelTab(session);
100
+ }).catch(() => { });
101
+ });
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Browser Assistant — Separate Panel</title>
7
+ <link rel="stylesheet" href="styles.css">
8
+ </head>
9
+ <body class="detached-panel">
10
+ <header class="detached-toolbar">
11
+ <div id="detached-status" role="status">Connecting to the selected tab…</div>
12
+ <button type="button" id="detached-return">Return to floating panel</button>
13
+ </header>
14
+ <p id="detached-countdown" role="timer" hidden></p>
15
+ <main id="assistant-root"></main>
16
+ <script src="detached-panel.js"></script>
17
+ </body>
18
+ </html>
@@ -0,0 +1,201 @@
1
+ /* Render only the assistant's supported controls from the selected tab. */
2
+ (() => {
3
+ const shell = document.getElementById('assistant-root');
4
+ const status = document.getElementById('detached-status');
5
+ const countdown = document.getElementById('detached-countdown');
6
+ const returnButton = document.getElementById('detached-return');
7
+ const tags = new Set(['DIV', 'SPAN', 'P', 'SMALL', 'STRONG', 'DL', 'DT', 'DD', 'H3', 'H4', 'SECTION', 'BUTTON', 'SVG', 'PATH',
8
+ 'PRE', 'CODE', 'DETAILS', 'SUMMARY', 'KBD', 'TEXTAREA', 'LABEL', 'SELECT', 'OPTION', 'BR']);
9
+ const attributes = new Set(['id', 'class', 'type', 'role', 'title', 'tabindex', 'disabled', 'hidden', 'open', 'selected',
10
+ 'placeholder', 'rows', 'value', 'viewBox', 'd', 'data-panel-control', 'data-state', 'data-info', 'data-countdown']);
11
+ let token = '';
12
+ let lastHtml;
13
+ let requesting = false;
14
+ function safePanelNode(node) {
15
+ if (node.nodeType === Node.TEXT_NODE)
16
+ return document.createTextNode(node.textContent || '');
17
+ if (!(node instanceof Element) || !tags.has(node.tagName.toUpperCase()))
18
+ return null;
19
+ const tag = node.tagName.toLowerCase();
20
+ const element = tag === 'svg' || tag === 'path'
21
+ ? document.createElementNS('http://www.w3.org/2000/svg', tag)
22
+ : document.createElement(tag);
23
+ for (const attr of node.attributes) {
24
+ if (attributes.has(attr.name) || /^aria-[a-z-]+$/.test(attr.name))
25
+ element.setAttribute(attr.name, attr.value);
26
+ }
27
+ for (const child of node.childNodes) {
28
+ const copy = safePanelNode(child);
29
+ if (copy)
30
+ element.appendChild(copy);
31
+ }
32
+ return element;
33
+ }
34
+ function updatePanel(html) {
35
+ if (html === lastHtml)
36
+ return;
37
+ const active = document.activeElement;
38
+ const activeId = active?.getAttribute('data-panel-control');
39
+ const activeMode = active?.matches('[role="tab"]') ? active.id : '';
40
+ const caret = active instanceof HTMLTextAreaElement
41
+ ? [active.selectionStart, active.selectionEnd] : null;
42
+ const scrolls = ['.assistant-body', '.assistant-qa-panel'].map(selector => [selector, shell.querySelector(selector)?.scrollTop ?? 0]);
43
+ const source = document.createElement('template');
44
+ source.innerHTML = html;
45
+ const content = document.createDocumentFragment();
46
+ for (const child of source.content.childNodes) {
47
+ const copy = safePanelNode(child);
48
+ if (copy)
49
+ content.appendChild(copy);
50
+ }
51
+ shell.replaceChildren(content);
52
+ for (const [selector, scrollTop] of scrolls) {
53
+ const region = shell.querySelector(selector);
54
+ if (region)
55
+ region.scrollTop = scrollTop;
56
+ }
57
+ if (activeId) {
58
+ const replacement = shell.querySelector('[data-panel-control="' + CSS.escape(activeId) + '"]')
59
+ ?? (activeMode ? shell.querySelector('#' + CSS.escape(activeMode)) : null);
60
+ replacement?.focus({ preventScroll: true });
61
+ if (caret && replacement instanceof HTMLTextAreaElement) {
62
+ replacement.value = active.value;
63
+ replacement.setSelectionRange(...caret);
64
+ }
65
+ }
66
+ lastHtml = html;
67
+ }
68
+ async function refresh() {
69
+ if (requesting)
70
+ return;
71
+ requesting = true;
72
+ try {
73
+ const result = await chrome.runtime.sendMessage({ action: 'panel:snapshot' });
74
+ if (!result?.ok)
75
+ throw Error(result?.error || 'The selected tab did not respond.');
76
+ token = result.token;
77
+ const label = result.title + (result.active ? '' : ' · Select this tab in Chrome for Vision Scan.');
78
+ if (status.textContent !== label)
79
+ status.textContent = label;
80
+ if (countdown.textContent !== result.countdown)
81
+ countdown.textContent = result.countdown;
82
+ countdown.hidden = !result.countdown;
83
+ updatePanel(result.html);
84
+ }
85
+ catch (error) {
86
+ token = '';
87
+ lastHtml = undefined;
88
+ shell.replaceChildren();
89
+ countdown.hidden = true;
90
+ status.textContent = error.message;
91
+ }
92
+ finally {
93
+ requesting = false;
94
+ }
95
+ }
96
+ async function send(operation, control, value) {
97
+ if (!token)
98
+ return;
99
+ try {
100
+ const response = await chrome.runtime.sendMessage({
101
+ action: 'panel:action', token, operation, panelControl: control?.dataset.panelControl, value,
102
+ });
103
+ if (!response?.ok)
104
+ throw Error(response?.error || 'The selected tab did not respond.');
105
+ }
106
+ catch (error) {
107
+ status.textContent = error.message;
108
+ }
109
+ void refresh();
110
+ }
111
+ async function returnToFloating() {
112
+ try {
113
+ const response = await chrome.runtime.sendMessage({ action: 'panel:return' });
114
+ if (response?.error)
115
+ status.textContent = response.error;
116
+ }
117
+ catch (error) {
118
+ status.textContent = error.message;
119
+ }
120
+ }
121
+ returnButton.addEventListener('click', returnToFloating);
122
+ shell.addEventListener('click', event => {
123
+ const control = event.target.closest('[data-panel-control]');
124
+ if (!control?.matches('button,summary') || control.matches(':disabled'))
125
+ return;
126
+ event.preventDefault();
127
+ if (control.id === 'assistant-close-btn') {
128
+ returnToFloating();
129
+ return;
130
+ }
131
+ if (control.classList.contains('assistant-copy-btn')) {
132
+ const code = control.closest('.assistant-code-container')?.querySelector('code')?.textContent;
133
+ if (code === undefined)
134
+ return;
135
+ void navigator.clipboard.writeText(code).then(() => {
136
+ control.textContent = 'Copied';
137
+ setTimeout(() => { control.textContent = 'Copy'; }, 2000);
138
+ }).catch(error => { status.textContent = error.message; });
139
+ return;
140
+ }
141
+ void send('click', control);
142
+ });
143
+ shell.addEventListener('input', event => {
144
+ if (event.target instanceof HTMLTextAreaElement)
145
+ void send('value', event.target, event.target.value);
146
+ });
147
+ shell.addEventListener('change', event => {
148
+ if (event.target instanceof HTMLSelectElement)
149
+ void send('value', event.target, event.target.value);
150
+ });
151
+ document.addEventListener('keydown', event => {
152
+ if (event.repeat || event.isComposing || event.defaultPrevented || event.ctrlKey || event.metaKey)
153
+ return;
154
+ const key = event.key.toLowerCase();
155
+ if (event.altKey) {
156
+ if (key === 'a' || event.code === 'KeyA') {
157
+ event.preventDefault();
158
+ void send('automation');
159
+ }
160
+ else if (event.shiftKey && (key === 'j' || event.code === 'KeyJ')) {
161
+ event.preventDefault();
162
+ void send('journal');
163
+ }
164
+ return;
165
+ }
166
+ const focused = event.target;
167
+ if (focused.closest('input,textarea,select,[contenteditable="true"]'))
168
+ return;
169
+ if (focused.matches('[role="tab"]')) {
170
+ const tabs = [...shell.querySelectorAll('[role="tab"]')];
171
+ const index = tabs.indexOf(focused);
172
+ const next = { arrowright: (index + 1) % tabs.length, arrowleft: (index + tabs.length - 1) % tabs.length,
173
+ home: 0, end: tabs.length - 1 }[key];
174
+ if (next !== undefined && tabs[next]) {
175
+ event.preventDefault();
176
+ tabs[next].focus();
177
+ void send('click', tabs[next]);
178
+ return;
179
+ }
180
+ }
181
+ if (key === ']') {
182
+ event.preventDefault();
183
+ returnToFloating();
184
+ }
185
+ else if (key === '\\') {
186
+ event.preventDefault();
187
+ shell.hidden = false;
188
+ void send('vision');
189
+ }
190
+ else if (key === '[') {
191
+ event.preventDefault();
192
+ shell.hidden = !shell.hidden;
193
+ }
194
+ else if (key === '`') {
195
+ event.preventDefault();
196
+ shell.hidden = false;
197
+ }
198
+ });
199
+ void refresh();
200
+ setInterval(refresh, 650);
201
+ })();
@@ -132,15 +132,10 @@ function browserAssistantJournal(global) {
132
132
  const panel = document.createElement('section');
133
133
  panel.id = 'assistant-journal';
134
134
  panel.dataset.build = journalBuild;
135
- panel.style.cssText = 'position:fixed;right:16px;top:160px;width:290px;z-index:2147483646;background:white;color:#17233d;padding:16px;border:2px solid #7638ff;border-radius:12px;box-shadow:0 4px 20px #0003;font:14px Arial';
136
- panel.innerHTML = '<strong>Reflective Journal</strong><p data-info></p><p data-countdown style="font-weight:600;margin:8px 0"></p><textarea aria-label="Your class experience and feelings" placeholder="Your actual class experience / feelings (optional)" rows="3" style="width:100%;box-sizing:border-box"></textarea><button type="button" style="margin-top:8px;padding:10px">Fill &amp; Submit Journal</button><p role="status" aria-live="polite"></p>';
135
+ panel.innerHTML = '<strong>Reflective Journal</strong><p data-info></p><p data-countdown></p><textarea aria-label="Your class experience and feelings" placeholder="Your actual class experience / feelings (optional)" rows="3"></textarea><button type="button">Fill &amp; Submit Journal</button><p role="status" aria-live="polite"></p>';
137
136
  document.body.appendChild(panel);
138
137
  const controls = document.createElement('div');
139
138
  controls.innerHTML = '<label>Subject <select data-subject aria-label="Journal subject"><option value="">Detect from page</option><option>Backend Development Fundamentals</option><option>Computer Organization and Architecture</option><option>Advanced Data Structures</option><option>Linear Algebra Essentials</option><option>Fundamentals of Artificial Intelligence</option></select></label><label>Module / Journal <select data-number aria-label="Journal number"><option value="">Detect from page</option>' + Array.from({ length: 10 }, (_, i) => `<option value="${i + 1}">${i + 1}</option>`).join('') + '</select></label>';
140
- for (const label of controls.querySelectorAll('label'))
141
- label.style.cssText = 'display:block;margin:8px 0';
142
- for (const select of controls.querySelectorAll('select'))
143
- select.style.cssText = 'display:block;width:100%;padding:5px;color:#17233d;background:white;border:1px solid #abb3c3';
144
139
  panel.insertBefore(controls, panel.querySelector('textarea'));
145
140
  const status = panel.querySelector('[role=status]'), button = panel.querySelector('button');
146
141
  const countdown = panel.querySelector('[data-countdown]');
@@ -234,7 +229,6 @@ function browserAssistantJournal(global) {
234
229
  button.setAttribute('aria-keyshortcuts', 'Alt+Shift+J');
235
230
  const shortcutHint = document.createElement('p');
236
231
  shortcutHint.textContent = 'Shortcut: Alt + Shift + J';
237
- shortcutHint.style.cssText = 'font-size:12px;margin:6px 0;color:#516078';
238
232
  panel.insertBefore(shortcutHint, status);
239
233
  const shortcutListener = event => {
240
234
  if (!event.altKey || !event.shiftKey || event.ctrlKey || event.metaKey || event.repeat || event.isComposing)
@@ -277,7 +271,7 @@ function browserAssistantJournal(global) {
277
271
  if (slot) {
278
272
  if (panel.parentElement !== slot)
279
273
  slot.appendChild(panel);
280
- panel.style.cssText = 'display:block;position:static;width:100%;box-sizing:border-box;padding:10px;border:1px solid #6c58aa;border-radius:8px;background:#fff;color:#17233d;font:13px Arial;margin:10px 0;';
274
+ panel.style.display = '';
281
275
  button.hidden = true;
282
276
  }
283
277
  else
@@ -597,6 +591,12 @@ function browserAssistantJournal(global) {
597
591
  }
598
592
  }
599
593
  if (typeof window !== 'undefined' && location.origin === 'https://admissions.aurora.edu.in') {
594
+ const ongoingJournalStartLink = () => {
595
+ const links = [...document.querySelectorAll('a[href*="/modules/reflective-journal/"]')].filter(link => [...(link.closest('tr,[role="row"]')?.querySelectorAll('*') || [])].some(node => /^Ongoing$/i.test(node.textContent.trim())) && link.getClientRects().length
596
+ && new URL(link.href, location.origin).origin === location.origin
597
+ && /^\/modules\/reflective-journal\//.test(new URL(link.href, location.origin).pathname));
598
+ return links.length === 1 ? links[0] : null;
599
+ };
600
600
  window.BrowserAssistantJournal = window.BrowserAssistantJournal || {
601
601
  current: null,
602
602
  opening: false,
@@ -610,6 +610,7 @@ if (typeof window !== 'undefined' && location.origin === 'https://admissions.aur
610
610
  }
611
611
  catch { } },
612
612
  pause() { this.active()?.pause(); },
613
+ getStartLink() { return ongoingJournalStartLink(); },
613
614
  start() {
614
615
  if (this.active())
615
616
  return this.active().start();
@@ -619,16 +620,14 @@ if (typeof window !== 'undefined' && location.origin === 'https://admissions.aur
619
620
  }
620
621
  if (this.opening)
621
622
  return;
622
- const links = [...document.querySelectorAll('a[href*="/modules/reflective-journal/"]')].filter(link => [...(link.closest('tr,[role="row"]')?.querySelectorAll('*') || [])].some(node => /^Ongoing$/i.test(node.textContent.trim())) && link.getClientRects().length
623
- && new URL(link.href, location.origin).origin === location.origin
624
- && /^\/modules\/reflective-journal\//.test(new URL(link.href, location.origin).pathname));
625
- if (links.length === 1) {
623
+ const link = ongoingJournalStartLink();
624
+ if (link) {
626
625
  this.opening = true;
627
626
  try {
628
- sessionStorage.setItem('assistantPendingJournal', JSON.stringify({ path: new URL(links[0].href, location.origin).pathname, createdAt: Date.now() }));
627
+ sessionStorage.setItem('assistantPendingJournal', JSON.stringify({ path: new URL(link.href, location.origin).pathname, createdAt: Date.now() }));
629
628
  }
630
629
  catch { }
631
- links[0].click();
630
+ link.click();
632
631
  }
633
632
  },
634
633
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Assistant",
4
- "version": "2.9.2",
4
+ "version": "2.9.4",
5
5
  "description": "Scans webpages for MCQs and coding problems. Powered by Groq (cloud) and Ollama (local fallback).",
6
6
  "permissions": [
7
7
  "activeTab",
@@ -4,59 +4,30 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Browser Assistant</title>
7
- <style>
8
- body {
9
- width: 220px;
10
- padding: 12px 14px;
11
- font-family: 'Inter', system-ui, sans-serif;
12
- background: #0f0f0f;
13
- color: #eee;
14
- margin: 0;
15
- }
16
- .logo {
17
- display: flex;
18
- align-items: center;
19
- gap: 8px;
20
- margin-bottom: 10px;
21
- }
22
- .logo-dot {
23
- width: 10px;
24
- height: 10px;
25
- border-radius: 50%;
26
- background: #6e8efb;
27
- box-shadow: 0 0 6px #6e8efb;
28
- }
29
- h3 { margin: 0; font-size: 14px; color: #fff; }
30
- p { font-size: 11px; color: #888; margin: 0 0 10px; line-height: 1.5; }
31
- .status { font-size: 11px; color: #555; }
32
- .status span { color: #10b981; font-weight: 600; }
33
- .shortcuts { margin-top: 10px; border-top: 1px solid #222; padding-top: 8px; }
34
- .shortcut-row { display: flex; justify-content: space-between; font-size: 10px; color: #666; margin-bottom: 4px; }
35
- kbd {
36
- background: #222; border: 1px solid #444; border-radius: 3px;
37
- padding: 1px 5px; font-size: 10px; color: #bbb;
38
- }
39
- #server-status { color: #f59e0b; }
40
- #server-status.online { color: #10b981; }
41
- #server-status.offline { color: #ef4444; }
42
- </style>
7
+ <link rel="stylesheet" href="styles.css">
43
8
  </head>
44
- <body>
45
- <div class="logo">
46
- <div class="logo-dot"></div>
47
- <h3>Browser Assistant</h3>
48
- </div>
49
- <p>Extension active. The floating panel appears on every page.</p>
50
- <div class="status">Server: <span id="server-status">checking...</span></div>
51
- <p id="journal-countdown" hidden></p>
52
- <div class="shortcuts">
53
- <div class="shortcut-row"><span>Open panel</span> <kbd>`</kbd></div>
54
- <div class="shortcut-row"><span>Close panel</span> <kbd>]</kbd></div>
55
- <div class="shortcut-row"><span>Vision scan</span> <kbd>\</kbd></div>
56
- <div class="shortcut-row"><span>Minimal mode</span> <kbd>[</kbd></div>
57
- <div class="shortcut-row"><span>Journal fill &amp; submit</span> <kbd>Alt+Shift+J</kbd></div>
58
- <div class="shortcut-row"><span>Automation start / pause / resume</span> <kbd>Alt+A</kbd></div>
59
- </div>
9
+ <body class="assistant-popup">
10
+ <main class="popup-shell">
11
+ <header class="popup-title">
12
+ <span class="popup-mark" aria-hidden="true">BA</span>
13
+ <h1>Browser Assistant</h1>
14
+ </header>
15
+ <section class="popup-card" aria-label="Server status">
16
+ <div>Server <span id="server-status" role="status">Checking…</span></div>
17
+ <p id="journal-countdown" hidden></p>
18
+ <button type="button" id="open-separate-panel">Open separate panel for this tab</button>
19
+ <p id="separate-panel-status" role="status" hidden></p>
20
+ </section>
21
+ <section class="popup-card" aria-labelledby="popup-shortcuts">
22
+ <h2 id="popup-shortcuts">Keyboard shortcuts</h2>
23
+ <div class="shortcut-row"><span>Open panel</span> <kbd>`</kbd></div>
24
+ <div class="shortcut-row"><span>Close panel</span> <kbd>]</kbd></div>
25
+ <div class="shortcut-row"><span>Vision scan</span> <kbd>\</kbd></div>
26
+ <div class="shortcut-row"><span>Minimal mode</span> <kbd>[</kbd></div>
27
+ <div class="shortcut-row"><span>Fill and submit journal</span> <kbd>Alt+Shift+J</kbd></div>
28
+ <div class="shortcut-row"><span>Start, pause or resume</span> <kbd>Alt+A</kbd></div>
29
+ </section>
30
+ </main>
60
31
  <script src="popup.js"></script>
61
32
  </body>
62
33
  </html>
@@ -48,3 +48,27 @@ journalTimerStorage.onChanged.addListener(changes => {
48
48
  });
49
49
  void refreshPopupJournalTimers();
50
50
  setInterval(showJournalCountdown, 1000);
51
+ const separatePanelButton = document.querySelector('#open-separate-panel');
52
+ const separatePanelStatus = document.getElementById('separate-panel-status');
53
+ if (separatePanelButton) {
54
+ void chrome.storage.local.get('assistantPanelMode').then(settings => {
55
+ if (settings.assistantPanelMode === 'separate')
56
+ separatePanelButton.textContent = 'Resume separate panel for this tab';
57
+ }).catch(() => { });
58
+ separatePanelButton.addEventListener('click', async () => {
59
+ separatePanelButton.disabled = true;
60
+ separatePanelStatus.hidden = true;
61
+ try {
62
+ const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
63
+ const result = await chrome.runtime.sendMessage({ action: 'panel:open', targetTabId: tab?.id });
64
+ if (!result?.ok)
65
+ throw Error(result?.error || 'Could not open the separate panel.');
66
+ window.close();
67
+ }
68
+ catch (error) {
69
+ separatePanelStatus.textContent = error.message;
70
+ separatePanelStatus.hidden = false;
71
+ separatePanelButton.disabled = false;
72
+ }
73
+ });
74
+ }