Skip to content
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
34 changes: 19 additions & 15 deletions apps/desktop/src/main/main.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1524,7 +1524,7 @@ app.whenReady().then(async () => {
}

try {
if (ctx.sessionService?.list({ status: "running", limit: 1 }).length > 0) {
if ((ctx.sessionService?.list({ status: "running", limit: 1 }).length ?? 0) > 0) {
return true;
}
} catch (error) {
Expand DownExpand Up@@ -4232,7 +4232,7 @@ app.whenReady().then(async () => {
builtInBrowserService,
macosVmService,
usageTrackingService,
} as AppContext;
};
};

const createDormantProjectContext = (projectRoot = ""): AppContext => {
Expand DownExpand Up@@ -4291,6 +4291,10 @@ app.whenReady().then(async () => {
laneWorktreeLockService: null,
laneEnvironmentService: null,
laneTemplateService: null,
portAllocationService: null,
laneProxyService: null,
oauthRedirectService: null,
runtimeDiagnosticsService: null,
rebaseSuggestionService: null,
autoRebaseService: null,
sessionService: null,
Expand DownExpand Up@@ -4348,7 +4352,7 @@ app.whenReady().then(async () => {
linearIngressService: null,
linearSyncService: null,
configReloadService: null,
} as unknown as AppContext;
};
};

const disposeContextResources = async (ctx: AppContext): Promise<void> => {
Expand DownExpand Up@@ -4381,7 +4385,7 @@ app.whenReady().then(async () => {
// Flush DB before disposing services so that any pending writes are persisted.
// Services may write during disposal, so we flush again at the end as a safety net.
try {
ctx.db.flushNow();
ctx.db?.flushNow();
} catch {
// ignore
}
Expand All@@ -4391,7 +4395,7 @@ app.whenReady().then(async () => {
// ignore
}
try {
ctx.prPollingService.dispose();
ctx.prPollingService?.dispose();
} catch {
// ignore
}
Expand All@@ -4416,7 +4420,7 @@ app.whenReady().then(async () => {
// ignore
}
try {
ctx.automationService.dispose();
ctx.automationService?.dispose();
} catch {
// ignore
}
Expand DownExpand Up@@ -4461,12 +4465,12 @@ app.whenReady().then(async () => {
// ignore
}
try {
ctx.jobEngine.dispose();
ctx.jobEngine?.dispose();
} catch {
// ignore
}
try {
ctx.fileService.dispose();
ctx.fileService?.dispose();
} catch {
// ignore
}
Expand All@@ -4486,22 +4490,22 @@ app.whenReady().then(async () => {
// ignore
}
try {
ctx.testService.disposeAll();
ctx.testService?.disposeAll();
} catch {
// ignore
}
try {
ctx.processService.disposeAll();
ctx.processService?.disposeAll();
} catch {
// ignore
}
try {
ctx.ptyService.disposeAll();
ctx.ptyService?.disposeAll();
} catch {
// ignore
}
try {
await ctx.agentChatService.disposeAll();
await ctx.agentChatService?.disposeAll();
} catch {
// ignore
}
Expand All@@ -4526,8 +4530,8 @@ app.whenReady().then(async () => {
// ignore
}
try {
ctx.db.flushNow();
ctx.db.close();
ctx.db?.flushNow();
ctx.db?.close();
} catch {
// ignore
}
Expand DownExpand Up@@ -4581,7 +4585,7 @@ app.whenReady().then(async () => {
recent?: RecentProjectInspection | null,
): Promise<SyncMobileProjectSummary> {
let laneCount = recent?.summary.laneCount ?? 0;
if (!recent?.summary.laneCount) {
if (!recent?.summary.laneCount && ctx.laneService) {
try {
laneCount = (await ctx.laneService.list({ includeArchived: false })).length;
} catch {
Expand Down
Loading
Loading