different-ai/openwork · error
app.error_connect_first
app.error_connect_first
Error message
app.error_connect_first
What it means
Thrown by the remote workspace connection editor when saving an OpenWork-type connection without an established client. The hook only has a connected client after a successful connection check; if the form is in 'new/edit OpenWork connection' mode and `client` is still null, saving is rejected with 'app.error_connect_first' telling the user to test/connect first.
Source
Thrown at apps/app/src/react-app/domains/workspace/use-remote-workspace-connection-editor.ts:110
try {
const displayName = fields.displayName?.trim() || null;
const directory = fields.directory?.trim() || null;
const openworkToken = fields.openworkToken?.trim() ?? "";
if (isDesktopRuntime()) {
await workspaceUpdateRemote({
workspaceId: id,
baseUrl,
openworkHostUrl: baseUrl,
openworkToken,
openworkClientToken: "",
openworkHostToken: "",
displayName,
directory,
remoteType: "openwork",
});
await onSaved(id);
} else {
if (!client) throw new Error(t("app.error_connect_first"));
const connectionChanged = baseUrl !== (initialValues.openworkHostUrl?.trim() ?? "") ||
openworkToken !== (initialValues.openworkToken?.trim() ?? "") ||
directory !== (initialValues.directory?.trim() || null);
if (connectionChanged) {
const result = await client.createRemoteWorkspace({
baseUrl,
openworkHostUrl: baseUrl,
openworkToken: openworkToken || null,
displayName,
directory,
remoteType: "openwork",
});
await onSaved(result.activeId ?? id);
} else {
await client.updateWorkspaceDisplayName(id, displayName);
await onSaved(id);
}
}View on GitHub (pinned to 2b7df46e8a)
Solutions
- Run the connection check (connect/test) so a client is created before saving.
- Verify the OpenWork host URL and token are correct if the check failed.
- Ensure network access to the remote host; retry the connect step.
Example fix
// before
if (!client) throw new Error(t("app.error_connect_first"));
// after — auto-run the check instead of throwing
let activeClient = client;
if (!activeClient) activeClient = await runConnectionCheck(baseUrl, openworkToken);
const connectionChanged = /* unchanged */; Defensive patterns
Strategy: validation
Validate before calling
const canSave = remoteType !== "openwork" || client != null;
if (!canSave) { showHint(t("app.error_connect_first")); return; } Type guard
function hasClient(c: Client | null | undefined): c is Client {
return c != null;
} Try / catch
try {
await editor.save();
} catch (error) {
if (error.message === t("app.error_connect_first")) {
await editor.runConnectionCheck(); // recover by connecting
} else throw error;
} Prevention
- Disable the save button until the connection check has succeeded.
- Auto-run the connection check on blur of host/token fields.
- Show inline validation state (untested / connected / failed).
When it happens
Trigger: Submitting the connection editor form with remoteType 'openwork' when the user has not run the connect/check step (or the check failed), so the `client` variable from the connection check is still undefined.
Common situations: User types a host URL and token but skips pressing the connect/test button; connection check failed silently (wrong token, unreachable URL); editing a connection and changing fields without re-validating.
Related errors
- Select a local workspace before starting the local server/en
- invalid_path
- OpenWork server is unavailable. Reconnect the server before
- Workspace runtime is not connected.
- Workspace export is only supported for local workspaces
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/2ac615c7c4e7c5c1.
Report an issue: GitHub.