{"record":{"id":"c321a32b5612cd9b","repo":"different-ai/openwork","slug":"app-error-compact-empty","errorCode":null,"errorMessage":"app.error_compact_empty","messagePattern":"app\\.error_compact_empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/app/src/react-app/domains/session/sync/actions-store.ts","lineNumber":652,"sourceCode":"      parts: [{ type: \"text\", text }],\n      attachments: [],\n    });\n  }\n\n  async function compactCurrentSession(sessionIdOverride?: string) {\n    const c = options.client();\n    if (!c) {\n      throw new Error(t(\"app.error_not_connected\"));\n    }\n\n    const sessionID = (sessionIdOverride ?? options.selectedSessionId() ?? \"\").trim();\n    if (!sessionID) {\n      throw new Error(t(\"app.error_compact_no_session_id\"));\n    }\n\n    const visible = options.messages();\n    if (!visible.length) {\n      throw new Error(t(\"app.error_compact_empty\"));\n    }\n\n    const model = options.selectedSessionModel();\n    const startedAt = perfNow();\n    const modelLabel = `${model.providerID}/${model.modelID}`;\n    recordPerfLog(options.developerMode(), \"session.compact\", \"start\", {\n      sessionID,\n      messageCount: visible.length,\n      model: modelLabel,\n      variant: options.sanitizeModelVariantForRef(model, options.modelVariant()) ?? null,\n    });\n\n    try {\n      await compactSessionTyped(c, sessionID, model, {\n        directory: options.runtimeWorkspaceRoot().trim() || options.selectedWorkspaceRoot().trim() || undefined,\n      });\n      finishPerf(options.developerMode(), \"session.compact\", \"done\", startedAt, {\n        sessionID,","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/react-app/domains/session/sync/actions-store.ts#L634-L670","documentation":"createSessionActionsStore's compact action refuses to run session compaction when the current visible message list is empty. Compaction summarizes conversation history, so there is nothing to summarize with zero visible messages. The localized message 'app.error_compact_empty' is thrown before any performance logging or server call is made.","triggerScenarios":"Calling the compact session action (via createSessionActionsStore) while options.messages() returns an empty array — e.g. compacting a brand-new session before the first message is sent, or after all messages were filtered out as invisible.","commonSituations":"A UI compact button enabled on a fresh/empty chat; messages cleared or pruned by a filter but compact invoked from a stale menu; automated scripts compacting a session id that resolved to no visible messages.","solutions":["Ensure at least one visible message exists before invoking compact; disable the compact UI affordance when messages().length === 0.","Check the messages() selector — visibility filters may be hiding messages that actually exist; fix the filter or session id.","Wrap the compact call in try/catch and surface the localized message to the user instead of crashing."],"exampleFix":"// before: await actions.compactSession(sessionID) | // after: if (actions.messages().length > 0) { await actions.compactSession(sessionID) }","handlingStrategy":"validation","validationCode":"const visible = actions.messages(); if (visible.length === 0) { return; } await actions.compactSession(sessionID);","typeGuard":null,"tryCatchPattern":"try { await actions.compactSession(sessionID); } catch (e) { if (e.message.includes('compact')) { showToast(t('app.error_compact_empty')); } else { throw e; } }","preventionTips":["Disable the compact button when the visible message list is empty.","Re-check message count after filters or session switches change visibility.","Keep compact actions tied to sessions with confirmed non-empty history."],"tags":["session","compact","precondition","ui-state"],"backgroundTag":"empty-session-compact","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}