Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: desktop blank window and reload loop

Oladipupo Ayoola59b3998e323b
diff --git a/.gitignore b/.gitignore
index 40ea0b279..62ede0e17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,3 +50,4 @@ tauri.windows.conf.json
# Cursor
.cursor
.env*.local
+.docs/
diff --git a/apps/desktop/app.config.ts b/apps/desktop/app.config.ts
index c7569b934..5e88eaad0 100644
--- a/apps/desktop/app.config.ts
+++ b/apps/desktop/app.config.ts
@@ -37,5 +37,21 @@ export default defineConfig({
define: {
"import.meta.vitest": "undefined",
},
+ optimizeDeps: {
+ include: [
+ "@tauri-apps/plugin-os",
+ "@tanstack/solid-query",
+ "@tauri-apps/api/webviewWindow",
+ "@tauri-apps/plugin-dialog",
+ "@tauri-apps/plugin-store",
+ "posthog-js",
+ "uuid",
+ "@tauri-apps/plugin-clipboard-manager",
+ "@tauri-apps/api/window",
+ "@tauri-apps/api/core",
+ "@tauri-apps/api/event",
+ "cva",
+ ],
+ },
}),
});
diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rs
index 9b215c7b5..d255a6884 100644
--- a/apps/desktop/src-tauri/src/general_settings.rs
+++ b/apps/desktop/src-tauri/src/general_settings.rs
@@ -134,7 +134,7 @@ fn default_enable_native_camera_preview() -> bool {
}
fn default_enable_new_recording_flow() -> bool {
- true
+ false
}
fn no(_: &bool) -> bool {
@@ -259,10 +259,14 @@ pub fn init(app: &AppHandle) {
};
if !store.recording_picker_preference_set {
- store.enable_new_recording_flow = true;
+ store.enable_new_recording_flow = false;
store.recording_picker_preference_set = true;
}
+ if store.enable_new_recording_flow {
+ store.enable_new_recording_flow = false;
+ }
+
if let Err(e) = store.save(app) {
error!("Failed to save general settings: {}", e);
}
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index 98eccdfef..d3a78ea9f 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -2677,6 +2677,8 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
async move {
if !permissions.screen_recording.permitted()
|| !permissions.accessibility.permitted()
+ || !permissions.microphone.permitted()
+ || !permissions.camera.permitted()
|| GeneralSettingsStore::get(&app)
.ok()
.flatten()
diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx
index 251a08d25..a88ad1378 100644
--- a/apps/desktop/src/App.tsx
+++ b/apps/desktop/src/App.tsx
@@ -1,12 +1,11 @@
-import { Router, useCurrentMatches } from "@solidjs/router";
-import { FileRoutes } from "@solidjs/start/router";
+import { Route, Router, useCurrentMatches } from "@solidjs/router";
import { QueryClient, QueryClientProvider } from "@tanstack/solid-query";
import {
getCurrentWebviewWindow,
type WebviewWindow,
} from "@tauri-apps/api/webviewWindow";
import { message } from "@tauri-apps/plugin-dialog";
-import { createEffect, onCleanup, onMount, Suspense } from "solid-js";
+import { createEffect, lazy, onCleanup, onMount, Suspense } from "solid-js";
import { Toaster } from "solid-toast";
import "@cap/ui-solid/main.css";
@@ -19,6 +18,35 @@ import { initAnonymousUser } from "./utils/analytics";
import { type AppTheme, commands } from "./utils/tauri";
import titlebar from "./utils/titlebar-state";
+const WindowChromeLayout = lazy(() => import("./routes/(window-chrome)"));
+const MainPage = lazy(() => import("./routes/(window-chrome)/(main)"));
+const NewMainPage = lazy(() => import("./routes/(window-chrome)/new-main"));
+const SetupPage = lazy(() => import("./routes/(window-chrome)/setup"));
+const SettingsLayout = lazy(() => import("./routes/(window-chrome)/settings"));
+const SettingsGeneralPage = lazy(() => import("./routes/(window-chrome)/settings/general"));
+const SettingsRecordingsPage = lazy(() => import("./routes/(window-chrome)/settings/recordings"));
+const SettingsScreenshotsPage = lazy(() => import("./routes/(window-chrome)/settings/screenshots"));
+const SettingsHotkeysPage = lazy(() => import("./routes/(window-chrome)/settings/hotkeys"));
+const SettingsChangelogPage = lazy(() => import("./routes/(window-chrome)/settings/changelog"));
+const SettingsFeedbackPage = lazy(() => import("./routes/(window-chrome)/settings/feedback"));
+const SettingsExperimentalPage = lazy(() => import("./routes/(window-chrome)/settings/experimental"));
+const SettingsLicensePage = lazy(() => import("./routes/(window-chrome)/settings/license"));
+const SettingsIntegrationsPage = lazy(() => import("./routes/(window-chrome)/settings/integrations"));
+const SettingsS3ConfigPage = lazy(() => import("./routes/(window-chrome)/settings/integrations/s3-config"));
+const UpgradePage = lazy(() => import("./routes/(window-chrome)/upgrade"));
+const UpdatePage = lazy(() => import("./routes/(window-chrome)/update"));
+const CameraPage = lazy(() => import("./routes/camera"));
+const CaptureAreaPage = lazy(() => import("./routes/capture-area"));
+const DebugPage = lazy(() => import("./routes/debug"));
+const EditorPage = lazy(() => import("./routes/editor"));
+const InProgressRecordingPage = lazy(() => import("./routes/in-progress-recording"));
+const ModeSelectPage = lazy(() => import("./routes/mode-select"));
+const NotificationsPage = lazy(() => import("./routes/notifications"));
+const RecordingsOverlayPage = lazy(() => import("./routes/recordings-overlay"));
+const ScreenshotEditorPage = lazy(() => import("./routes/screenshot-editor"));
+const TargetSelectOverlayPage = lazy(() => import("./routes/target-select-overlay"));
+const WindowCaptureOccluderPage = lazy(() => import("./routes/window-capture-occluder"));
+
const queryClient = new QueryClient({
defaultOptions: {
queries: {
@@ -35,6 +63,9 @@ const queryClient = new QueryClient({
});
export default function App() {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'App.tsx:App',message:'App component rendering',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{});
+ // #endregion
return (
<QueryClientProvider client={queryClient}>
<Suspense>
@@ -45,10 +76,16 @@ export default function App() {
}
function Inner() {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'App.tsx:Inner',message:'Inner component rendering',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{});
+ // #endregion
const currentWindow = getCurrentWebviewWindow();
createThemeListener(currentWindow);
onMount(() => {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'App.tsx:Inner:onMount',message:'Inner onMount',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{});
+ // #endregion
initAnonymousUser();
});
@@ -78,6 +115,9 @@ function Inner() {
const matches = useCurrentMatches();
onMount(() => {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'App.tsx:Router:root:onMount',message:'Router root onMount',data:{pathname:location.pathname,matchCount:matches().length,autoShowFlags:matches().map(m=>m.route.info?.AUTO_SHOW_WINDOW)},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C,D'})}).catch(()=>{});
+ // #endregion
for (const match of matches()) {
if (match.route.info?.AUTO_SHOW_WINDOW === false) return;
}
@@ -98,7 +138,37 @@ function Inner() {
);
}}
>
- <FileRoutes />
+ <Route path="/" component={WindowChromeLayout}>
+ <Route path="/" component={MainPage} />
+ <Route path="/new-main" component={NewMainPage} />
+ <Route path="/setup" component={SetupPage} />
+ <Route path="/settings" component={SettingsLayout}>
+ <Route path="/" component={SettingsGeneralPage} />
+ <Route path="/general" component={SettingsGeneralPage} />
+ <Route path="/recordings" component={SettingsRecordingsPage} />
+ <Route path="/screenshots" component={SettingsScreenshotsPage} />
+ <Route path="/hotkeys" component={SettingsHotkeysPage} />
+ <Route path="/changelog" component={SettingsChangelogPage} />
+ <Route path="/feedback" component={SettingsFeedbackPage} />
+ <Route path="/experimental" component={SettingsExperimentalPage} />
+ <Route path="/license" component={SettingsLicensePage} />
+ <Route path="/integrations" component={SettingsIntegrationsPage} />
+ <Route path="/integrations/s3-config" component={SettingsS3ConfigPage} />
+ </Route>
+ <Route path="/upgrade" component={UpgradePage} />
+ <Route path="/update" component={UpdatePage} />
+ </Route>
+ <Route path="/camera" component={CameraPage} />
+ <Route path="/capture-area" component={CaptureAreaPage} />
+ <Route path="/debug" component={DebugPage} />
+ <Route path="/editor" component={EditorPage} />
+ <Route path="/in-progress-recording" component={InProgressRecordingPage} />
+ <Route path="/mode-select" component={ModeSelectPage} />
+ <Route path="/notifications" component={NotificationsPage} />
+ <Route path="/recordings-overlay" component={RecordingsOverlayPage} />
+ <Route path="/screenshot-editor" component={ScreenshotEditorPage} />
+ <Route path="/target-select-overlay" component={TargetSelectOverlayPage} />
+ <Route path="/window-capture-occluder" component={WindowCaptureOccluderPage} />
</Router>
</CapErrorBoundary>
</>
diff --git a/apps/desktop/src/entry-client.tsx b/apps/desktop/src/entry-client.tsx
index c4f2cfe08..801872019 100644
--- a/apps/desktop/src/entry-client.tsx
+++ b/apps/desktop/src/entry-client.tsx
@@ -1,6 +1,16 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";
-import { type } from "@tauri-apps/plugin-os";
-document.documentElement.classList.add(`platform-${type()}`);
-mount(() => <StartClient />, document.getElementById("app")!);
+async function initApp() {
+ try {
+ const { type } = await import("@tauri-apps/plugin-os");
+ const osType = type();
+ document.documentElement.classList.add(`platform-${osType}`);
+ } catch (error) {
+ console.error("Failed to get OS type:", error);
+ }
+
+ mount(() => <StartClient />, document.getElementById("app")!);
+}
+
+initApp();
diff --git a/apps/desktop/src/routes/(window-chrome).tsx b/apps/desktop/src/routes/(window-chrome).tsx
index 6483767ac..02ddaac32 100644
--- a/apps/desktop/src/routes/(window-chrome).tsx
+++ b/apps/desktop/src/routes/(window-chrome).tsx
@@ -13,16 +13,17 @@ import {
WindowChromeContext,
} from "./(window-chrome)/Context";
-export const route = {
- info: {
- AUTO_SHOW_WINDOW: false,
- },
-};
-
export default function (props: RouteSectionProps) {
let unlistenResize: UnlistenFn | undefined;
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'(window-chrome).tsx:render',message:'WindowChrome component rendering',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{});
+ // #endregion
+
onMount(async () => {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'(window-chrome).tsx:onMount',message:'WindowChrome onMount',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{});
+ // #endregion
console.log("window chrome mounted");
unlistenResize = await initializeTitlebar();
if (location.pathname === "/") getCurrentWindow().show();
@@ -92,7 +93,13 @@ function Header() {
}
function Inner(props: ParentProps) {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'(window-chrome).tsx:Inner:render',message:'Inner component rendering',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{});
+ // #endregion
onMount(() => {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'(window-chrome).tsx:Inner:onMount',message:'Inner onMount, about to show window',data:{pathname:location.pathname},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'B,C'})}).catch(()=>{});
+ // #endregion
if (location.pathname !== "/") getCurrentWindow().show();
});
diff --git a/apps/desktop/src/routes/(window-chrome)/setup.tsx b/apps/desktop/src/routes/(window-chrome)/setup.tsx
index 1b8fd5449..86c05e049 100644
--- a/apps/desktop/src/routes/(window-chrome)/setup.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/setup.tsx
@@ -39,6 +39,17 @@ const permissions = [
description:
"During recording, Cap collects mouse activity locally to generate automatic zoom in segments.",
},
+ {
+ name: "Microphone",
+ key: "microphone" as const,
+ description: "This permission is required to record audio in your Caps.",
+ },
+ {
+ name: "Camera",
+ key: "camera" as const,
+ description:
+ "This permission is required to record your camera in your Caps.",
+ },
] as const;
export default function () {
@@ -83,9 +94,18 @@ export default function () {
);
const handleContinue = () => {
- // Just proceed to the main window without saving mode to store
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'setup.tsx:handleContinue',message:'handleContinue called',data:{},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'A'})}).catch(()=>{});
+ // #endregion
commands.showWindow({ Main: { init_target_mode: null } }).then(() => {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'setup.tsx:handleContinue:then',message:'showWindow resolved, closing setup',data:{},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'A,B'})}).catch(()=>{});
+ // #endregion
getCurrentWindow().close();
+ }).catch((err) => {
+ // #region agent log
+ fetch('http://127.0.0.1:7243/ingest/1cff95e2-fcb2-4b1f-a666-2aa2ac4f0e23',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'setup.tsx:handleContinue:catch',message:'showWindow failed',data:{error:String(err)},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'A'})}).catch(()=>{});
+ // #endregion
});
};