Skip to content

Nikita onboarding flow #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/argo-archive-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import "@material/web/list/list-item.js";
import "@material/web/checkbox/checkbox.js";
import "@material/web/icon/icon.js";
import "@material/web/labs/card/elevated-card.js";
// @ts-expect-error
import filingDrawer from "assets/images/filing-drawer.avif";

import { getLocalOption } from "./localstorage";
Expand Down
1 change: 0 additions & 1 deletion src/argo-shared-archive-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "@material/web/icon/icon.js";
import "@material/web/labs/card/elevated-card.js";
import "@material/web/button/filled-button.js";
import "@material/web/button/outlined-button.js";
// @ts-expect-error
import filingDrawer from "assets/images/filing-drawer.avif";

import { getLocalOption, setSharedArchives } from "./localstorage";
Expand Down
1 change: 1 addition & 0 deletions src/assets/brand/packrat-lockup-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/downloading.avif
Binary file not shown.
Binary file added src/assets/images/forest.avif
Binary file not shown.
Binary file added src/assets/images/sharing-warning.avif
Binary file not shown.
Binary file added src/assets/images/sharing.avif
Binary file not shown.
56 changes: 55 additions & 1 deletion src/ext/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ function sidepanelHandler(port) {
// @ts-expect-error - TS2339 - Property 'port' does not exist on type 'BrowserRecorder'.
self.recorders[tabId].port = port;
self.recorders[tabId].doUpdateStatus();
} else if (isRecordingEnabled) {
// Send the current recording state even if no recorder exists for this tab
port.postMessage({
type: "status",
recording: false, // No recorder for this tab
autorun,
// @ts-expect-error
collId: defaultCollId,
});
}
port.postMessage(await listAllMsg(collLoader));
break;
Expand Down Expand Up @@ -353,8 +362,18 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {

if (changeInfo.url && !isValidUrl(changeInfo.url, skipDomains)) {
stopRecorder(tabId);

// Ensure debugger is detached when navigating to a skipped domain
try {
chrome.debugger.detach({ tabId }, () => {
// Debugger detached, ignore any errors as it might already be detached
});
} catch (e) {
// Ignore errors - debugger might already be detached
}

delete self.recorders[tabId];
// let the side-panel know the canRecord/UI state changed
// let the side-panel know the 'canRecord'/UI state changed
// @ts-expect-error
if (sidepanelPort) {
sidepanelPort.postMessage({ type: "update" });
Expand Down Expand Up @@ -440,6 +459,9 @@ async function startRecorder(tabId, opts) {
let err = null;
// @ts-expect-error - TS7034 - Variable 'sidepanelPort' implicitly has type 'any' in some locations where its type cannot be determined.
if (sidepanelPort) {
// Set the port on the recorder so it can send status updates
// @ts-expect-error
self.recorders[tabId].port = sidepanelPort;
sidepanelPort.postMessage({ type: "update" });
}
const { waitForTabUpdate } = opts;
Expand All @@ -449,9 +471,28 @@ async function startRecorder(tabId, opts) {
try {
self.recorders[tabId].setCollId(opts.collId);
await self.recorders[tabId].attach();

// Send status update after successful attach
// @ts-expect-error
if (sidepanelPort && self.recorders[tabId]) {
self.recorders[tabId].doUpdateStatus();
}
} catch (e) {
console.warn(e);
err = e;

// Clean up on error
// @ts-expect-error
if (err?.message?.includes("already attached")) {
// Try to detach and delete the recorder
try {
chrome.debugger.detach({ tabId }, () => {
delete self.recorders[tabId];
});
} catch (detachErr) {
console.warn("Failed to detach debugger:", detachErr);
}
}
Comment on lines +485 to +495

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The error handling only cleans up when the error message includes "already attached", but other errors should also trigger cleanup to prevent resource leaks. The recorder should be deleted for any error during attachment. [possible issue, importance: 8]

Suggested change
// @ts-expect-error
if (err?.message?.includes("already attached")) {
// Try to detach and delete the recorder
try {
chrome.debugger.detach({ tabId }, () => {
delete self.recorders[tabId];
});
} catch (detachErr) {
console.warn("Failed to detach debugger:", detachErr);
}
}
// Clean up on error
try {
if (err?.message?.includes("already attached")) {
// Try to detach the debugger first for "already attached" errors
chrome.debugger.detach({ tabId }, () => {
console.log("Detached debugger after 'already attached' error");
});
}
// Delete the recorder for any error
delete self.recorders[tabId];
} catch (detachErr) {
console.warn("Failed to detach debugger:", detachErr);
}

}
return err;
}
Expand All @@ -462,6 +503,19 @@ async function startRecorder(tabId, opts) {
function stopRecorder(tabId) {
if (self.recorders[tabId]) {
self.recorders[tabId].detach();

// Ensure the sidepanel is notified about the stop
// @ts-expect-error - TS7034 - Variable 'sidepanelPort' implicitly has type 'any' in some locations where its type cannot be determined.
if (sidepanelPort) {
sidepanelPort.postMessage({
type: "status",
recording: false,
autorun,
// @ts-expect-error - defaultCollId implicitly has an 'any' type.
collId: defaultCollId,
});
}

return true;
}

Expand Down
3 changes: 3 additions & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
declare module "*.svg";
declare module "*.png";
declare module "*.avif"
declare module "*.jpg";
declare module "*.html";
declare module "*.scss";
declare module "*.sass";
Expand Down
Loading
Loading