browser-assistant 2.8.25 → 2.8.26

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.
@@ -65,10 +65,24 @@ chrome.alarms.onAlarm.addListener(alarm => {
65
65
  if (alarm.name !== 'assistant-workspace-update')
66
66
  return;
67
67
  void checkWorkspaceUpdate();
68
- void checkJournalReminder();
69
68
  void updateJournalBadge();
70
69
  });
71
- chrome.runtime.onInstalled.addListener(() => { void attachUpdatedPanels(); });
70
+ chrome.runtime.onInstalled.addListener(details => {
71
+ void attachUpdatedPanels();
72
+ if (details.reason === 'update')
73
+ void clearRetiredReminderSettings();
74
+ });
75
+ async function clearRetiredReminderSettings() {
76
+ try {
77
+ const storage = chrome.storage.local;
78
+ const keys = Object.keys(await storage.get()).filter(key => key === 'assistantJournalReminderConfig' || key.startsWith('assistantJournalReminder:'));
79
+ if (keys.length)
80
+ await storage.remove(keys);
81
+ }
82
+ catch (error) {
83
+ console.warn('Could not remove retired journal reminder settings.', error);
84
+ }
85
+ }
72
86
  let journalBadgeRevision = 0;
73
87
  function activeJournalTimers(data, now = Date.now()) {
74
88
  const prefix = 'assistantJournalTimer:';
@@ -111,62 +125,6 @@ chrome.storage?.local.onChanged?.addListener(changes => {
111
125
  }
112
126
  });
113
127
  void updateJournalBadge();
114
- let checkingJournalReminder = false;
115
- async function checkJournalReminder() {
116
- if (checkingJournalReminder)
117
- return;
118
- checkingJournalReminder = true;
119
- try {
120
- const storage = chrome.storage.local;
121
- const data = await storage.get();
122
- const config = data.assistantJournalReminderConfig;
123
- if (!config?.url || !config?.token)
124
- return;
125
- await Promise.all(activeJournalTimers(data).map(timer => sendJournalReminder(timer, config)));
126
- }
127
- catch { /* The minute alarm keeps timer checks independent of workspace updates. */ }
128
- finally {
129
- checkingJournalReminder = false;
130
- }
131
- }
132
- async function sendJournalReminder(timer, config) {
133
- try {
134
- const storage = chrome.storage.local;
135
- const remaining = timer.deadline - Date.now();
136
- // Give the portal time to confirm an existing submission at 30:00.
137
- if (remaining > (30 * 60 - 45) * 1000 || remaining <= 0)
138
- return;
139
- const stateKey = `assistantJournalReminder:${timer.path}`;
140
- const confirmationKey = `assistantJournalConfirmed:${timer.path}`;
141
- const previous = await storage.get([stateKey, confirmationKey]);
142
- if (previous[stateKey] || previous[confirmationKey])
143
- return;
144
- // Reserve the one attempt before the network call. A timed-out webhook
145
- // can still have sent a message, so replay would risk a duplicate.
146
- await storage.set({ [stateKey]: 'sending' });
147
- const latest = await storage.get();
148
- const current = activeJournalTimers(latest).find(candidate => candidate.path === timer.path);
149
- if (!current || Math.abs(current.deadline - timer.deadline) > 2000 ||
150
- latest.assistantJournalReminderConfig?.url !== config.url || latest.assistantJournalReminderConfig.token !== config.token) {
151
- await storage.remove(stateKey);
152
- return;
153
- }
154
- let result = 'failed';
155
- try {
156
- const response = await fetch(config.url, {
157
- method: 'POST', credentials: 'omit', redirect: 'error', signal: AbortSignal.timeout(15000),
158
- headers: { 'Content-Type': 'application/json', 'X-Journal-Reminder-Token': config.token },
159
- body: JSON.stringify({ event: 'journal_submission_unconfirmed' }),
160
- });
161
- if (response.ok)
162
- result = 'sent';
163
- }
164
- finally {
165
- await storage.set({ [stateKey]: result });
166
- }
167
- }
168
- catch { /* One failed request does not interrupt the other journals. */ }
169
- }
170
128
  chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
171
129
  if (!request || typeof request.action !== 'string') {
172
130
  sendResponse({ error: 'Invalid extension message' });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Browser Assistant",
4
- "version": "2.8.25",
4
+ "version": "2.8.26",
5
5
  "description": "Scans webpages for MCQs and coding problems. Powered by Groq (cloud) and Ollama (local fallback).",
6
6
  "permissions": [
7
7
  "activeTab",
@@ -39,11 +39,6 @@
39
39
  #server-status { color: #f59e0b; }
40
40
  #server-status.online { color: #10b981; }
41
41
  #server-status.offline { color: #ef4444; }
42
- #journal-reminder { margin: 10px 0; font-size: 11px; }
43
- #journal-reminder summary { cursor: pointer; }
44
- #journal-reminder label { display: block; margin: 7px 0; }
45
- #journal-reminder input { box-sizing: border-box; width: 100%; }
46
- #journal-reminder-status { margin-top: 6px; }
47
42
  </style>
48
43
  </head>
49
44
  <body>
@@ -54,16 +49,6 @@
54
49
  <p>Extension active. The floating panel appears on every page.</p>
55
50
  <div class="status">Server: <span id="server-status">checking...</span></div>
56
51
  <p id="journal-countdown" hidden></p>
57
- <details id="journal-reminder">
58
- <summary>WhatsApp journal reminder</summary>
59
- <form id="journal-reminder-form">
60
- <label>n8n production webhook URL<input id="journal-webhook-url" type="url" required></label>
61
- <label>Webhook token<input id="journal-webhook-token" type="password" required autocomplete="off"></label>
62
- <button type="submit">Enable</button>
63
- <button type="button" id="journal-reminder-disable">Disable</button>
64
- </form>
65
- <p id="journal-reminder-status" role="status">Checking settings…</p>
66
- </details>
67
52
  <div class="shortcuts">
68
53
  <div class="shortcut-row"><span>Open panel</span> <kbd>`</kbd></div>
69
54
  <div class="shortcut-row"><span>Close panel</span> <kbd>]</kbd></div>
@@ -48,48 +48,3 @@ journalTimerStorage.onChanged.addListener(changes => {
48
48
  });
49
49
  void refreshPopupJournalTimers();
50
50
  setInterval(showJournalCountdown, 1000);
51
- const reminderForm = document.querySelector('#journal-reminder-form');
52
- if (reminderForm) {
53
- const key = 'assistantJournalReminderConfig';
54
- const urlInput = document.querySelector('#journal-webhook-url');
55
- const tokenInput = document.querySelector('#journal-webhook-token');
56
- const status = document.getElementById('journal-reminder-status');
57
- const disable = document.querySelector('#journal-reminder-disable');
58
- void journalTimerStorage.get(key).then(data => {
59
- const config = data[key];
60
- if (config)
61
- urlInput.value = config.url;
62
- status.textContent = config ? 'Reminder enabled.' : 'Reminder disabled.';
63
- }).catch(() => { status.textContent = 'Could not load reminder settings.'; });
64
- reminderForm.addEventListener('submit', async (event) => {
65
- event.preventDefault();
66
- try {
67
- const url = new URL(urlInput.value);
68
- const local = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
69
- if (!(url.protocol === 'https:' || (local && url.protocol === 'http:')) || url.username || url.password ||
70
- url.search || url.hash || !url.pathname.includes('/webhook/')) {
71
- throw Error('Enter the n8n production webhook URL. Use HTTPS for remote n8n.');
72
- }
73
- const token = tokenInput.value.trim();
74
- if (!/^[\x21-\x7e]{20,256}$/.test(token))
75
- throw Error('Use a webhook token of at least 20 characters, with no spaces.');
76
- await journalTimerStorage.set({ [key]: { url: url.href, token } });
77
- tokenInput.value = '';
78
- status.textContent = 'Reminder enabled.';
79
- }
80
- catch (error) {
81
- status.textContent = error.message;
82
- }
83
- });
84
- disable.addEventListener('click', async () => {
85
- try {
86
- await journalTimerStorage.remove(key);
87
- urlInput.value = '';
88
- tokenInput.value = '';
89
- status.textContent = 'Reminder disabled.';
90
- }
91
- catch {
92
- status.textContent = 'Could not disable reminder.';
93
- }
94
- });
95
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-assistant",
3
- "version": "2.8.25",
3
+ "version": "2.8.26",
4
4
  "description": "Chrome extension and local Python backend for exploring webpage questions and coding exercises",
5
5
  "license": "MIT",
6
6
  "repository": {
package/server/main.py CHANGED
@@ -191,7 +191,7 @@ async def lifespan(_app: FastAPI):
191
191
  client.close()
192
192
 
193
193
 
194
- app = FastAPI(title="Browser Assistant API", version="2.8.25", lifespan=lifespan)
194
+ app = FastAPI(title="Browser Assistant API", version="2.8.26", lifespan=lifespan)
195
195
  install_local_guards(app)
196
196
 
197
197
  @app.exception_handler(HTTPException)