Skip to content
Closed
5 changes: 5 additions & 0 deletions apps/code/src/main/di/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import type {
import type { OAuthService } from "@posthog/core/oauth/oauth";
import type { PROVISIONING_SERVICE } from "@posthog/core/provisioning/identifiers";
import type { ProvisioningService } from "@posthog/core/provisioning/provisioning";
import type { QUICK_ENTRY_SERVICE as CORE_QUICK_ENTRY_SERVICE } from "@posthog/core/quick-entry/identifiers";
import type { SLEEP_SERVICE } from "@posthog/core/sleep/identifiers";
import type { SleepService } from "@posthog/core/sleep/sleep";
import type { UI_AUTH, UI_SERVICE } from "@posthog/core/ui/identifiers";
Expand Down Expand Up @@ -244,6 +245,7 @@ import type { DevMetricsService } from "../services/dev-metrics/service";
import type { DevNetworkService } from "../services/dev-network/service";
import type { DiscordPresenceService } from "../services/discord-presence/service";
import type { EncryptionService } from "../services/encryption/service";
import type { QuickEntryService } from "../services/quick-entry/service";
import type { SecureStoreService } from "../services/secure-store/service";
import type { settingsStore } from "../services/settingsStore";
import type { WorkspaceServerService } from "../services/workspace-server/service";
Expand Down Expand Up @@ -279,6 +281,7 @@ import type {
POSTHOG_PLUGIN_SERVICE as MAIN_POSTHOG_PLUGIN_SERVICE,
PROCESS_TRACKING_SERVICE as MAIN_PROCESS_TRACKING_SERVICE,
PROVISIONING_SERVICE as MAIN_PROVISIONING_SERVICE,
QUICK_ENTRY_SERVICE as MAIN_QUICK_ENTRY_SERVICE,
REPOSITORY_REPOSITORY as MAIN_REPOSITORY_REPOSITORY,
SCOUT_LINK_SERVICE as MAIN_SCOUT_LINK_SERVICE,
SECURE_STORE_BACKEND as MAIN_SECURE_STORE_BACKEND,
Expand Down Expand Up @@ -458,6 +461,8 @@ export interface MainBindings {
[LOGS_SERVICE]: ILogsService;
[MAIN_ENCRYPTION_SERVICE]: EncryptionService;
[MAIN_DISCORD_PRESENCE_SERVICE]: DiscordPresenceService;
[MAIN_QUICK_ENTRY_SERVICE]: QuickEntryService;
[CORE_QUICK_ENTRY_SERVICE]: QuickEntryService;

// Dev toolbar diagnostics
[MAIN_DEV_FLAGS_SERVICE]: DevFlagsService;
Expand Down
5 changes: 5 additions & 0 deletions apps/code/src/main/di/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import {
import { oauthModule } from "@posthog/core/oauth/oauth.module";
import { PROVISIONING_SERVICE } from "@posthog/core/provisioning/identifiers";
import { ProvisioningService } from "@posthog/core/provisioning/provisioning";
import { QUICK_ENTRY_SERVICE as CORE_QUICK_ENTRY_SERVICE } from "@posthog/core/quick-entry/identifiers";
import { SLEEP_SERVICE } from "@posthog/core/sleep/identifiers";
import { SleepService } from "@posthog/core/sleep/sleep";
import { UI_AUTH } from "@posthog/core/ui/identifiers";
Expand Down Expand Up @@ -254,6 +255,7 @@ import { DevMetricsService } from "../services/dev-metrics/service";
import { DevNetworkService } from "../services/dev-network/service";
import { DiscordPresenceService } from "../services/discord-presence/service";
import { EncryptionService } from "../services/encryption/service";
import { QuickEntryService } from "../services/quick-entry/service";
import { SecureStoreService } from "../services/secure-store/service";
import { settingsStore } from "../services/settingsStore";
import { WorkspaceServerService } from "../services/workspace-server/service";
Expand Down Expand Up @@ -292,6 +294,7 @@ import {
POSTHOG_PLUGIN_SERVICE as MAIN_POSTHOG_PLUGIN_SERVICE,
PROCESS_TRACKING_SERVICE as MAIN_PROCESS_TRACKING_SERVICE,
PROVISIONING_SERVICE as MAIN_PROVISIONING_SERVICE,
QUICK_ENTRY_SERVICE as MAIN_QUICK_ENTRY_SERVICE,
REPOSITORY_REPOSITORY as MAIN_REPOSITORY_REPOSITORY,
SCOUT_LINK_SERVICE as MAIN_SCOUT_LINK_SERVICE,
SECURE_STORE_BACKEND as MAIN_SECURE_STORE_BACKEND,
Expand Down Expand Up @@ -737,6 +740,8 @@ container.bind(LOGS_SERVICE).toDynamicValue((ctx) => {
});
container.bind(MAIN_ENCRYPTION_SERVICE).to(EncryptionService);
container.bind(MAIN_DISCORD_PRESENCE_SERVICE).to(DiscordPresenceService);
container.bind(MAIN_QUICK_ENTRY_SERVICE).to(QuickEntryService);
container.bind(CORE_QUICK_ENTRY_SERVICE).toService(MAIN_QUICK_ENTRY_SERVICE);

// Canvas / dashboards (project-bluebird). The host-agnostic dashboard services
// live in @posthog/core (bound via canvasCoreModule) and resolve through
Expand Down
3 changes: 3 additions & 0 deletions apps/code/src/main/di/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export const WORKSPACE_SERVER_SERVICE = Symbol.for(
export const DISCORD_PRESENCE_SERVICE = Symbol.for(
"posthog.host.main.discord-presence.service",
);
export const QUICK_ENTRY_SERVICE = Symbol.for(
"posthog.host.main.quick-entry.service",
);
export const DEV_FLAGS_SERVICE = Symbol.for(
"posthog.host.main.dev-flags.service",
);
Expand Down
17 changes: 16 additions & 1 deletion apps/code/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TypedEventEmitter } from "@posthog/shared";
import type { WorkspaceClient } from "@posthog/workspace-client/client";
import { createWorkspaceClient } from "@posthog/workspace-client/client";
import type { FileWatcherEvent } from "@posthog/workspace-client/types";
import { app, BrowserWindow, dialog } from "electron";
import { app, BrowserWindow, dialog, globalShortcut } from "electron";
import log from "electron-log/main";
import "./utils/logger";
import "./services/index.js";
Expand Down Expand Up @@ -62,6 +62,7 @@ import {
FS_SERVICE as MAIN_FS_SERVICE,
NEW_TASK_LINK_SERVICE,
POSTHOG_PLUGIN_SERVICE,
QUICK_ENTRY_SERVICE,
SCOUT_LINK_SERVICE,
TASK_LINK_SERVICE,
UPDATES_SERVICE,
Expand All @@ -78,6 +79,7 @@ import {
focusSessionStore,
focusWorktreePaths,
} from "./services/focus/desktop-adapters";
import type { QuickEntryService } from "./services/quick-entry/service";
import type { WorkspaceServerService } from "./services/workspace-server/service";
import {
collectMemorySnapshot,
Expand Down Expand Up @@ -384,6 +386,7 @@ app.whenReady().then(async () => {
container.bind(FS_SERVICE).toService(MAIN_FS_SERVICE);
await initializeServices();
initializeDeepLinks();
initializeQuickEntry();

if (process.env.POSTHOG_E2E_UPDATE_FEED) {
const updates = container.get<UpdatesService>(UPDATES_SERVICE);
Expand All @@ -399,10 +402,22 @@ app.whenReady().then(async () => {
}
});

function initializeQuickEntry(): void {
try {
container.get<QuickEntryService>(QUICK_ENTRY_SERVICE).initialize();
} catch (err) {
log.error("Failed to initialize quick entry", err);
}
}

app.on("window-all-closed", () => {
app.quit();
});

app.on("will-quit", () => {
globalShortcut.unregisterAll();
});

const teardownContainer = async (): Promise<void> => {
try {
await container.unbindAll();
Expand Down
Loading
Loading