Skip to content

Commit 59b3998

Browse files
committed
fix: desktop blank window and reload loop
1 parent db01c9d commit 59b3998

8 files changed

Lines changed: 146 additions & 16 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ tauri.windows.conf.json
5050
# Cursor
5151
.cursor
5252
.env*.local
53+
.docs/

apps/desktop/app.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,21 @@ export default defineConfig({
3737
define: {
3838
"import.meta.vitest": "undefined",
3939
},
40+
optimizeDeps: {
41+
include: [
42+
"@tauri-apps/plugin-os",
43+
"@tanstack/solid-query",
44+
"@tauri-apps/api/webviewWindow",
45+
"@tauri-apps/plugin-dialog",
46+
"@tauri-apps/plugin-store",
47+
"posthog-js",
48+
"uuid",
49+
"@tauri-apps/plugin-clipboard-manager",
50+
"@tauri-apps/api/window",
51+
"@tauri-apps/api/core",
52+
"@tauri-apps/api/event",
53+
"cva",
54+
],
55+
},
4056
}),
4157
});

apps/desktop/src-tauri/src/general_settings.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn default_enable_native_camera_preview() -> bool {
134134
}
135135

136136
fn default_enable_new_recording_flow() -> bool {
137-
true
137+
false
138138
}
139139

140140
fn no(_: &bool) -> bool {
@@ -259,10 +259,14 @@ pub fn init(app: &AppHandle) {
259259
};
260260

261261
if !store.recording_picker_preference_set {
262-
store.enable_new_recording_flow = true;
262+
store.enable_new_recording_flow = false;
263263
store.recording_picker_preference_set = true;
264264
}
265265

266+
if store.enable_new_recording_flow {
267+
store.enable_new_recording_flow = false;
268+
}
269+
266270
if let Err(e) = store.save(app) {
267271
error!("Failed to save general settings: {}", e);
268272
}

apps/desktop/src-tauri/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,8 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
26772677
async move {
26782678
if !permissions.screen_recording.permitted()
26792679
|| !permissions.accessibility.permitted()
2680+
|| !permissions.microphone.permitted()
2681+
|| !permissions.camera.permitted()
26802682
|| GeneralSettingsStore::get(&app)
26812683
.ok()
26822684
.flatten()

apps/desktop/src/App.tsx

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Router, useCurrentMatches } from "@solidjs/router";
2-
import { FileRoutes } from "@solidjs/start/router";
1+
import { Route, Router, useCurrentMatches } from "@solidjs/router";
32
import { QueryClient, QueryClientProvider } from "@tanstack/solid-query";
43
import {
54
getCurrentWebviewWindow,
65
type WebviewWindow,
76
} from "@tauri-apps/api/webviewWindow";
87
import { message } from "@tauri-apps/plugin-dialog";
9-
import { createEffect, onCleanup, onMount, Suspense } from "solid-js";
8+
import { createEffect, lazy, onCleanup, onMount, Suspense } from "solid-js";
109
import { Toaster } from "solid-toast";
1110

1211
import "@cap/ui-solid/main.css";
@@ -19,6 +18,35 @@ import { initAnonymousUser } from "./utils/analytics";
1918
import { type AppTheme, commands } from "./utils/tauri";
2019
import titlebar from "./utils/titlebar-state";
2120

21+
const WindowChromeLayout = lazy(() => import("./routes/(window-chrome)"));
22+
const MainPage = lazy(() => import("./routes/(window-chrome)/(main)"));
23+
const NewMainPage = lazy(() => import("./routes/(window-chrome)/new-main"));
24+
const SetupPage = lazy(() => import("./routes/(window-chrome)/setup"));
25+
const SettingsLayout = lazy(() => import("./routes/(window-chrome)/settings"));
26+
const SettingsGeneralPage = lazy(() => import("./routes/(window-chrome)/settings/general"));
27+
const SettingsRecordingsPage = lazy(() => import("./routes/(window-chrome)/settings/recordings"));
28+
const SettingsScreenshotsPage = lazy(() => import("./routes/(window-chrome)/settings/screenshots"));
29+
const SettingsHotkeysPage = lazy(() => import("./routes/(window-chrome)/settings/hotkeys"));
30+
const SettingsChangelogPage = lazy(() => import("./routes/(window-chrome)/settings/changelog"));
31+
const SettingsFeedbackPage = lazy(() => import("./routes/(window-chrome)/settings/feedback"));
32+
const SettingsExperimentalPage = lazy(() => import("./routes/(window-chrome)/settings/experimental"));
33+
const SettingsLicensePage = lazy(() => import("./routes/(window-chrome)/settings/license"));
34+
const SettingsIntegrationsPage = lazy(() => import("./routes/(window-chrome)/settings/integrations"));
35+
const SettingsS3ConfigPage = lazy(() => import("./routes/(window-chrome)/settings/integrations/s3-config"));
36+
const UpgradePage = lazy(() => import("./routes/(window-chrome)/upgrade"));
37+
const UpdatePage = lazy(() => import("./routes/(window-chrome)/update"));
38+
const CameraPage = lazy(() => import("./routes/camera"));
39+
const CaptureAreaPage = lazy(() => import("./routes/capture-area"));
40+
const DebugPage = lazy(() => import("./routes/debug"));
41+
const EditorPage = lazy(() => import("./routes/editor"));
42+
const InProgressRecordingPage = lazy(() => import("./routes/in-progress-recording"));
43+
const ModeSelectPage = lazy(() => import("./routes/mode-select"));
44+
const NotificationsPage = lazy(() => import("./routes/notifications"));
45+
const RecordingsOverlayPage = lazy(() => import("./routes/recordings-overlay"));
46+
const ScreenshotEditorPage = lazy(() => import("./routes/screenshot-editor"));
47+
const TargetSelectOverlayPage = lazy(() => import("./routes/target-select-overlay"));
48+
const WindowCaptureOccluderPage = lazy(() => import("./routes/window-capture-occluder"));
49+
2250
const queryClient = new QueryClient({
2351
defaultOptions: {
2452
queries: {
@@ -35,6 +63,9 @@ const queryClient = new QueryClient({
3563
});
3664

3765
export default function App() {
66+
// #region agent log
67+
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(()=>{});
68+
// #endregion
3869
return (
3970
<QueryClientProvider client={queryClient}>
4071
<Suspense>
@@ -45,10 +76,16 @@ export default function App() {
4576
}
4677

4778
function Inner() {
79+
// #region agent log
80+
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(()=>{});
81+
// #endregion
4882
const currentWindow = getCurrentWebviewWindow();
4983
createThemeListener(currentWindow);
5084

5185
onMount(() => {
86+
// #region agent log
87+
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(()=>{});
88+
// #endregion
5289
initAnonymousUser();
5390
});
5491

@@ -78,6 +115,9 @@ function Inner() {
78115
const matches = useCurrentMatches();
79116

80117
onMount(() => {
118+
// #region agent log
119+
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(()=>{});
120+
// #endregion
81121
for (const match of matches()) {
82122
if (match.route.info?.AUTO_SHOW_WINDOW === false) return;
83123
}
@@ -98,7 +138,37 @@ function Inner() {
98138
);
99139
}}
100140
>
101-
<FileRoutes />
141+
<Route path="/" component={WindowChromeLayout}>
142+
<Route path="/" component={MainPage} />
143+
<Route path="/new-main" component={NewMainPage} />
144+
<Route path="/setup" component={SetupPage} />
145+
<Route path="/settings" component={SettingsLayout}>
146+
<Route path="/" component={SettingsGeneralPage} />
147+
<Route path="/general" component={SettingsGeneralPage} />
148+
<Route path="/recordings" component={SettingsRecordingsPage} />
149+
<Route path="/screenshots" component={SettingsScreenshotsPage} />
150+
<Route path="/hotkeys" component={SettingsHotkeysPage} />
151+
<Route path="/changelog" component={SettingsChangelogPage} />
152+
<Route path="/feedback" component={SettingsFeedbackPage} />
153+
<Route path="/experimental" component={SettingsExperimentalPage} />
154+
<Route path="/license" component={SettingsLicensePage} />
155+
<Route path="/integrations" component={SettingsIntegrationsPage} />
156+
<Route path="/integrations/s3-config" component={SettingsS3ConfigPage} />
157+
</Route>
158+
<Route path="/upgrade" component={UpgradePage} />
159+
<Route path="/update" component={UpdatePage} />
160+
</Route>
161+
<Route path="/camera" component={CameraPage} />
162+
<Route path="/capture-area" component={CaptureAreaPage} />
163+
<Route path="/debug" component={DebugPage} />
164+
<Route path="/editor" component={EditorPage} />
165+
<Route path="/in-progress-recording" component={InProgressRecordingPage} />
166+
<Route path="/mode-select" component={ModeSelectPage} />
167+
<Route path="/notifications" component={NotificationsPage} />
168+
<Route path="/recordings-overlay" component={RecordingsOverlayPage} />
169+
<Route path="/screenshot-editor" component={ScreenshotEditorPage} />
170+
<Route path="/target-select-overlay" component={TargetSelectOverlayPage} />
171+
<Route path="/window-capture-occluder" component={WindowCaptureOccluderPage} />
102172
</Router>
103173
</CapErrorBoundary>
104174
</>

apps/desktop/src/entry-client.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
// @refresh reload
22
import { mount, StartClient } from "@solidjs/start/client";
3-
import { type } from "@tauri-apps/plugin-os";
43

5-
document.documentElement.classList.add(`platform-${type()}`);
6-
mount(() => <StartClient />, document.getElementById("app")!);
4+
async function initApp() {
5+
try {
6+
const { type } = await import("@tauri-apps/plugin-os");
7+
const osType = type();
8+
document.documentElement.classList.add(`platform-${osType}`);
9+
} catch (error) {
10+
console.error("Failed to get OS type:", error);
11+
}
12+
13+
mount(() => <StartClient />, document.getElementById("app")!);
14+
}
15+
16+
initApp();

apps/desktop/src/routes/(window-chrome).tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ import {
1313
WindowChromeContext,
1414
} from "./(window-chrome)/Context";
1515

16-
export const route = {
17-
info: {
18-
AUTO_SHOW_WINDOW: false,
19-
},
20-
};
21-
2216
export default function (props: RouteSectionProps) {
2317
let unlistenResize: UnlistenFn | undefined;
2418

19+
// #region agent log
20+
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(()=>{});
21+
// #endregion
22+
2523
onMount(async () => {
24+
// #region agent log
25+
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(()=>{});
26+
// #endregion
2627
console.log("window chrome mounted");
2728
unlistenResize = await initializeTitlebar();
2829
if (location.pathname === "/") getCurrentWindow().show();
@@ -92,7 +93,13 @@ function Header() {
9293
}
9394

9495
function Inner(props: ParentProps) {
96+
// #region agent log
97+
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(()=>{});
98+
// #endregion
9599
onMount(() => {
100+
// #region agent log
101+
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(()=>{});
102+
// #endregion
96103
if (location.pathname !== "/") getCurrentWindow().show();
97104
});
98105

apps/desktop/src/routes/(window-chrome)/setup.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ const permissions = [
3939
description:
4040
"During recording, Cap collects mouse activity locally to generate automatic zoom in segments.",
4141
},
42+
{
43+
name: "Microphone",
44+
key: "microphone" as const,
45+
description: "This permission is required to record audio in your Caps.",
46+
},
47+
{
48+
name: "Camera",
49+
key: "camera" as const,
50+
description:
51+
"This permission is required to record your camera in your Caps.",
52+
},
4253
] as const;
4354

4455
export default function () {
@@ -83,9 +94,18 @@ export default function () {
8394
);
8495

8596
const handleContinue = () => {
86-
// Just proceed to the main window without saving mode to store
97+
// #region agent log
98+
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(()=>{});
99+
// #endregion
87100
commands.showWindow({ Main: { init_target_mode: null } }).then(() => {
101+
// #region agent log
102+
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(()=>{});
103+
// #endregion
88104
getCurrentWindow().close();
105+
}).catch((err) => {
106+
// #region agent log
107+
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(()=>{});
108+
// #endregion
89109
});
90110
};
91111

0 commit comments

Comments
 (0)