different-ai/openwork · error

app.error_not_connected

Error message

app.error_not_connected

What it means

compactCurrentSession requires an active client transport; if options.client() returns null/undefined — meaning the UI has no connected server session — it throws the localized 'app.error_not_connected' before doing anything. This prevents compact requests from being issued into a dead/absent connection.

Source

Thrown at apps/app/src/react-app/domains/session/sync/actions-store.ts:642

      reason: "session action requested abort",
    });
  }

  function retryLastPrompt() {
    const text = lastPromptSent().trim();
    if (!text) return;
    void sendPrompt({
      mode: "prompt",
      text,
      parts: [{ type: "text", text }],
      attachments: [],
    });
  }

  async function compactCurrentSession(sessionIdOverride?: string) {
    const c = options.client();
    if (!c) {
      throw new Error(t("app.error_not_connected"));
    }

    const sessionID = (sessionIdOverride ?? options.selectedSessionId() ?? "").trim();
    if (!sessionID) {
      throw new Error(t("app.error_compact_no_session_id"));
    }

    const visible = options.messages();
    if (!visible.length) {
      throw new Error(t("app.error_compact_empty"));
    }

    const model = options.selectedSessionModel();
    const startedAt = perfNow();
    const modelLabel = `${model.providerID}/${model.modelID}`;
    recordPerfLog(options.developerMode(), "session.compact", "start", {
      sessionID,
      messageCount: visible.length,

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Reconnect to the server (restart or reconnect the session) and retry the compact action.
  2. Disable/gate the compact action in the UI until the client connection is ready.
  3. Check server logs for why the transport dropped if disconnection was unexpected.

Example fix

// before
async function compactCurrentSession(id?: string) {
  const c = options.client();
  if (!c) throw new Error(t("app.error_not_connected"));
// after (caller gate)
if (!isConnected()) {
  showToast("Reconnect before compacting");
  return;
}
await compactCurrentSession();
Defensive patterns

Strategy: validation

Validate before calling

const c = options.client();
if (!c) {
  showToast("Reconnect to the server first");
  return;
}
await compactCurrentSession();

Type guard

function isConnectedClient(c: unknown): boolean {
  return typeof c === "object" && c !== null;
}

Try / catch

try {
  await compactCurrentSession();
} catch (e) {
  if (e instanceof Error && e.message === "app.error_not_connected") {
    await reconnectClient();
    showToast("Was disconnected — reconnected, retry compact");
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: User triggers 'compact session' (from UI or with a sessionIdOverride) while the app is disconnected: server not started, connection dropped, or the action invoked before the client finished connecting.

Common situations: Server crashed or exited while a conversation stayed open; user ran compact during startup before the connection was ready; network outage dropped the websocket.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/cd6ddf9ffe2f2d12. Report an issue: GitHub.