sinelaw/fresh · error

unknown dock view

Error message

unknown dock view: ${view}

What it means

apiSetDockView sets the orchestrator dock's view mode and only accepts the two supported values "card" and "compact". Any other string (or non-string value) fails the whitelist check and the function throws immediately, before mutating dockView. The dock view is a session-pinned setting, so the guard prevents persisting an invalid mode.

Solutions

  1. Use only "card" or "compact" as the argument.
  2. Validate/normalize the value (trim, lowercase) before calling apiSetDockView.
  3. If the value comes from a settings file, fix the setting to one of the two allowed values.
  4. If a third view mode is genuinely needed, extend the union type and the guard in apiSetDockView rather than passing an unlisted string.

Example fix

// before
editor.setDockView("list");

// after
const view = "list";
if (view === "card" || view === "compact") {
  editor.setDockView(view);
} else {
  editor.setDockView("card");
}
Defensive patterns

Strategy: validation

Validate before calling

const VIEWS = ["card", "compact"];
function canSetDockView(v) {
  return typeof v === "string" && VIEWS.includes(v);
}

Type guard

function isDockView(v: unknown): v is "card" | "compact" {
  return v === "card" || v === "compact";
}

Try / catch

try {
  editor.setDockView(view);
} catch (e) {
  if (String(e.message).startsWith("unknown dock view")) {
    editor.setDockView("card"); // safe default
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the plugin API apiSetDockView (exposed as the dock's setView / 'view' API in orchestrator.ts:10760) with any value other than exactly "card" or "compact" — e.g. "list", "grid", "Card", "", or a number.

Common situations: Plugin or script authors guessing at view names instead of using the documented two; case-sensitivity mistakes ("Card"); config values wired in from settings that were never validated; passing user input straight through from a custom command palette entry.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/8795c1f3aeb9a7d7. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-editor/plugins/orchestrator.ts:10760

      }
      if (e.label === want && (!match || e.archived_at > match.archived_at)) {
        match = e;
      }
    }
    if (match && match.root === want) break;
  }
  if (!match) return false;
  const res = await unarchiveOne(match);
  if (!res.ok) throw new Error(res.err || "unarchive failed");
  // The manifest changed, so push it the same way the archive path does.
  if (res.repoRoot) triggerSyncAsync(res.repoRoot);
  refreshOpenDialog();
  return true;
}

function apiSetDockView(view: "card" | "compact"): void {
  if (view !== "card" && view !== "compact") {
    throw new Error(`unknown dock view: ${view}`);
  }
  dockView = view;
  // Pin it for the rest of the session, exactly as the toolbar's "view"
  // button does — the `defaultView` setting only decides where the dock
  // *starts*, so without the override a later re-open would undo this.
  dockViewOverride = view;
  refreshOpenDialog();
}

function apiSetDockFilter(
  options: DockFilterOptions = {},
  // Internal, and deliberately absent from the published signature: set when
  // the call comes from the filter box's own `change` event. The box already
  // holds the text and owns the caret, so the value must not be pushed back
  // (that would move the caret to the end and make mid-string editing jump).
  fromWidget?: { cursorByte?: number },
): void {
  // The row the user is looking at, so it can be kept highlighted across the

View on GitHub (pinned to 67894ca546)