diff --git a/src/backend/ipc/channels.ts b/src/backend/ipc/channels.ts index 1d422dfb..cc8f7a9a 100644 --- a/src/backend/ipc/channels.ts +++ b/src/backend/ipc/channels.ts @@ -114,7 +114,6 @@ export const IPC_CHANNELS = { PROTOCOL_ERROR: "protocol:error", // Portal API - PORTAL_GET_MY_SHAVES: "portal:get-my-shaves", PORTAL_GET_MY_PROJECTS: "portal:get-my-projects", PORTAL_CANCEL_WORK_ITEM: "portal:cancel-work-item", diff --git a/src/backend/ipc/portal-handlers.ts b/src/backend/ipc/portal-handlers.ts index 552ddfdf..ba0c99f5 100644 --- a/src/backend/ipc/portal-handlers.ts +++ b/src/backend/ipc/portal-handlers.ts @@ -1,80 +1,12 @@ -import https from "node:https"; import type { GetMyProjectsResponse } from "@shared/types/portal"; import { ipcMain } from "electron"; import { config } from "../config/env"; import type { IdentityServerAuthService } from "../services/auth/identity-server-auth"; import { fetchProjectSummaries, mapProjectsResponse } from "../services/portal/portal-projects"; -import type { GetMyShavesResponse } from "../types"; import { formatAndReportError } from "../utils/error-utils"; import { IPC_CHANNELS } from "./channels"; export function registerPortalHandlers(identityServerAuthService: IdentityServerAuthService) { - ipcMain.handle(IPC_CHANNELS.PORTAL_GET_MY_SHAVES, async () => { - try { - const accessToken = await identityServerAuthService.getAccessToken(); - if (!accessToken) { - return { success: false, error: "Failed to obtain access token" }; - } - - // Parse the portal API URL - const apiUrl = config.portalApiUrl(); - const url = new URL(apiUrl); - const hostname = url.hostname; - const port = url.port ? parseInt(url.port, 10) : url.protocol === "https:" ? 443 : 80; - const path = `${url.pathname.replace(/\/$/, "")}/me/shaves`; // Ensure no double slashes - - // Make API call to get user's shaves using HTTPS module for SSL certificate handling - const data = await new Promise((resolve, reject) => { - const options = { - hostname: hostname, - port: port, - path: path, - method: "GET", - headers: { - Authorization: `Bearer ${accessToken}`, - "Content-Type": "application/json", - }, - }; - - const req = https.request(options, (res) => { - let responseData = ""; - - res.on("data", (chunk) => { - responseData += chunk; - }); - - res.on("end", () => { - if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) { - try { - const parsedData = JSON.parse(responseData); - resolve(parsedData); - } catch (error) { - reject( - new Error( - `Failed to parse JSON response: ${formatAndReportError(error, "portal_api")}`, - ), - ); - } - } else { - reject(new Error(`API call failed: ${res.statusCode} ${res.statusMessage}`)); - } - }); - }); - - req.on("error", (error) => { - reject(error); - }); - - req.end(); - }); - - return { success: true, data }; - } catch (error) { - console.error("Portal API error:", formatAndReportError(error, "portal_api")); - return { success: false, error: formatAndReportError(error, "portal_api") }; - } - }); - // #816: list the signed-in user's projects, sourced from the portal endpoint // GET {portalApiUrl}/projects/summaries — the same project list the remote-prompts feature // already consumes in production. NOTE: that endpoint is tenant/organisation-scoped (every diff --git a/src/backend/preload.ts b/src/backend/preload.ts index 88f1b161..b189db61 100644 --- a/src/backend/preload.ts +++ b/src/backend/preload.ts @@ -130,7 +130,6 @@ const IPC_CHANNELS = { PROTOCOL_ERROR: "protocol:error", // Portal API - PORTAL_GET_MY_SHAVES: "portal:get-my-shaves", PORTAL_GET_MY_PROJECTS: "portal:get-my-projects", PORTAL_CANCEL_WORK_ITEM: "portal:cancel-work-item", @@ -385,7 +384,6 @@ const electronAPI = { onIpcEvent(IPC_CHANNELS.PROTOCOL_ERROR, callback), }, portal: { - getMyShaves: () => ipcRenderer.invoke(IPC_CHANNELS.PORTAL_GET_MY_SHAVES), getMyProjects: () => ipcRenderer.invoke(IPC_CHANNELS.PORTAL_GET_MY_PROJECTS), cancelWorkItem: (workItemId: string) => ipcRenderer.invoke(IPC_CHANNELS.PORTAL_CANCEL_WORK_ITEM, workItemId), diff --git a/src/backend/types/index.ts b/src/backend/types/index.ts index e2abf309..d446d6c8 100644 --- a/src/backend/types/index.ts +++ b/src/backend/types/index.ts @@ -83,24 +83,6 @@ export enum VideoSourceType { EXTERNAL_URL = "external_url", } -export interface ShaveItem { - id: string; - title: string; - videoFile: VideoFile; - updatedAt: string; - createdAt: string; - shaveStatus: string; - workItemType: string; - projectName: string; - workItemUrl: string; - feedback: string | null; - videoEmbedUrl: string; -} - -export interface GetMyShavesResponse { - items: ShaveItem[]; -} - // Portal-projects types (#816) are shared between the backend and the UI, so per // AGENTS.md Rule 9 they live in `@shared/types/portal`. Re-exported here for the // backend's existing `../types` import sites. diff --git a/src/ui/src/services/ipc-client.ts b/src/ui/src/services/ipc-client.ts index 87857859..0a28da23 100644 --- a/src/ui/src/services/ipc-client.ts +++ b/src/ui/src/services/ipc-client.ts @@ -21,7 +21,6 @@ import type { CustomPrompt, GetMyProjectsErrorCode, GetMyProjectsResponse, - GetMyShavesResponse, HealthStatusInfo, MCPStep, ScreenRecordingStartResult, @@ -246,11 +245,6 @@ declare global { onProtocolError: (callback: (message: string) => void) => () => void; }; portal: { - getMyShaves: () => Promise<{ - success: boolean; - data?: GetMyShavesResponse; - error?: string; - }>; getMyProjects: () => Promise<{ success: boolean; data?: GetMyProjectsResponse; diff --git a/src/ui/src/types/index.ts b/src/ui/src/types/index.ts index 38aed79c..9e9aea76 100644 --- a/src/ui/src/types/index.ts +++ b/src/ui/src/types/index.ts @@ -187,24 +187,6 @@ export interface VideoFile { isChromeExtension: boolean; } -export interface ShaveItem { - id: string; - title: string; - videoFile: VideoFile; - updatedAt: string; - createdAt: string; - shaveStatus: string; - workItemType: string; - projectName: string; - workItemUrl: string; - feedback: string | null; - videoEmbedUrl: string; -} - -export interface GetMyShavesResponse { - items: ShaveItem[]; -} - // Portal-projects types (#816) are shared between the backend and the UI, so per // AGENTS.md Rule 9 they live in `@shared/types/portal`. Re-exported here for the // UI's existing `../types` import sites.