fix(browser): improve error handling and code quality

- Fix response.json() called before checking response.ok in popup.js
- Consolidate duplicate onInstalled listeners in background.js
- Remove unnecessary return true from content.js message handler
- Add better error handling for non-JSON responses
- Improve user experience by not auto-opening popup on install

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-12 03:09:33 +00:00
parent 5d42e03b90
commit 142c19ef50
3 changed files with 19 additions and 21 deletions
+10 -6
View File
@@ -109,18 +109,22 @@ sendFileBtn.addEventListener('click', async () => {
credentials: 'include'
});
const result = await response.json();
if (response.ok) {
const result = await response.json();
showStatus(
`✓ File sent successfully! Task ID: ${result.task_id}\nFilename: ${result.filename}`,
'success'
);
} else {
showStatus(
`Error: ${result.detail || 'Failed to send file'}`,
'error'
);
// Try to parse JSON error, fall back to status text
let errorMessage = 'Failed to send file';
try {
const result = await response.json();
errorMessage = result.detail || errorMessage;
} catch (e) {
errorMessage = `HTTP ${response.status}: ${response.statusText}`;
}
showStatus(`Error: ${errorMessage}`, 'error');
}
} catch (error) {
showStatus(