{"record":{"id":"f3ecfa02315ca8c4","repo":"iOfficeAI/AionUi","slug":"scm-port-not-configured","errorCode":null,"errorMessage":"scm port not configured","messagePattern":"scm port not configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop/src/renderer/pages/conversation/SourceControl/scmStore.ts","lineNumber":615,"sourceCode":"\n/** Dismiss the current report without touching anything else. */\nexport const clearScmActionReport = (): void => {\n  actionReport = null;\n  commit();\n};\n\n/** The last action's inputs, for `retry`. Survives a panel remount. */\nexport const getLastScmAction = (): { action: ScmActionKind; repoId: string; resources: ScmResource[] } | null =>\n  lastAction;\n\n/** Request a file diff (`scm/diff`). Request-driven: not part of the subscription. */\nexport const fetchScmDiff = async (params: {\n  repository: string;\n  file: ScmFileRef;\n  from: ContentRef;\n  to: ContentRef;\n}): Promise<ScmDiffResult> => {\n  if (!port) throw new Error('scm port not configured');\n  return port.diff(params);\n};\n\n/**\n * Reconnect: the backend dropped this connection's whole subscription set, so\n * clear the declared set and re-declare from the repo list (mirrors the\n * explorer's `current = ∅` re-declare). Statuses are kept as stale paint until\n * the fresh first frames arrive.\n *\n * `appliedSeq` is cleared too: seq is per-repo *per backend runtime* and a\n * reconnect may hit a restarted backend whose seq restarts at 1 — keeping the old\n * high-water mark would make the guard discard every fresh frame, leaving the\n * panel permanently stale.\n */\nexport const onScmReconnect = (): void => {\n  subscribed = new Set();\n  appliedSeq = new Map();\n  if (repositories.length > 0) void subscribeRepos(repositories.map((r) => r.repo_id));","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/renderer/pages/conversation/SourceControl/scmStore.ts#L597-L633","documentation":"`fetchScmDiff` requires a live port to the source-control backend; this error fires when the module-level `port` variable is unset, i.e. the SCM IPC/connection was never initialized (or was torn down) before a diff was requested.","triggerScenarios":"Calling `fetchScmDiff` before `connect`/init has established the SCM port, or after the port was cleared (disconnect/reset). Any diff request against a repository file without an active SCM bridge connection.","commonSituations":"Component mounts and immediately requests a diff before the SCM connection lifecycle completes; the SCM backend service failed to start so init never assigned the port; calling diff after a deliberate disconnect (e.g. in tests or during window teardown).","solutions":["Ensure the SCM store connect/initialization (which assigns `port`) is awaited before rendering diff views","Check why `port` is unset: backend SCM service crash, failed IPC handshake, or skipped init","Reconnect via the store's reconnect path (re-declare subscriptions from the repo list) before retrying the diff","In tests, mock/seed the port instead of invoking fetchScmDiff cold"],"exampleFix":"// before\nexport const fetchScmDiff = async (params) => {\n  if (!port) throw new Error('scm port not configured');\n  return port.diff(params);\n};\n\n// after\nexport const fetchScmDiff = async (params) => {\n  if (!port) {\n    await connectScmPort(); // establish connection lazily\n    if (!port) throw new Error('scm port not configured');\n  }\n  return port.diff(params);\n};","handlingStrategy":"validation","validationCode":"if (!isScmConnected()) await connectScmPort();\n// then call fetchScmDiff","typeGuard":"const hasScmPort = (): boolean => port !== null && port !== undefined;","tryCatchPattern":"catch (e) { if (e.message === 'scm port not configured') await reconnectScm(); else throw e; }","preventionTips":["Await SCM store initialization before mounting diff views","Subscribe to disconnect events to gate diff requests"],"tags":["scm","ipc","port","initialization","source-control"],"backgroundTag":"service-not-initialized","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}