koala73/worldmonitor · error · Error

Country brief panel is not initialised

Error message

Country brief panel is not initialised

What it means

Thrown by the WebMCP open_country_brief tool binding in App.ts. After awaiting this.waitForUiReady(), the binding requires this.state.countryBriefPage to exist; if the general UI finished initializing but the country brief page never mounted, invoking the tool throws this error rather than silently doing nothing.

Source

Thrown at src/App.ts:1793

  }

  public async init(): Promise<void> {
    const initStart = performance.now();
    markLcpDebug('wm:boot:app-init-start');

    // WebMCP — register synchronously before any init awaits so agent
    // scanners (isitagentready.com, in-browser agents) find the tools on
    // their first probe. No-op in browsers without document.modelContext.
    // Bindings await `this.uiReady` (resolves after Phase-4 UI init) so
    // a tool invoked during the startup window waits for the target
    // panel to exist instead of throwing. A 10s timeout keeps a genuinely
    // broken state from hanging the caller. Store the returned controller
    // so destroy() can unregister every tool on teardown.
    this.webMcpController = registerWebMcpTools({
      openCountryBriefByCode: async (code, country) => {
        await this.waitForUiReady();
        if (!this.state.countryBriefPage) {
          throw new Error('Country brief panel is not initialised');
        }
        await this.countryIntel.openCountryBriefByCode(code, country);
      },
      resolveCountryName: (code) => CountryIntelManager.resolveCountryName(code),
      openSearch: async () => {
        // openSearch() awaits UI readiness internally and throws on failure when
        // throwOnFailure is set, so the agent receives a real success/failure.
        // (Re-checking searchModal here would spuriously throw if a concurrent
        // Cmd+K closed it between open and the check — #4403 review ADV-4.)
        await this.openSearch({ throwOnFailure: true });
      },
      getDashboardContext: async () => {
        await this.waitForDashboardReady();
        return getWebMcpDashboardContext(this.state, SITE_VARIANT);
      },
      applyDashboardAction: async (action) => {
        return runDashboardActionBinding(this.state, action, {
          waitForUiReady: () => this.waitForDashboardReady(false),

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Enable/mount the country brief page before offering open_country_brief to agents — verify state.countryBriefPage is set
  2. Make tool registration or the tool result conditional: return a structured 'panel unavailable' result instead of throwing when this.state.countryBriefPage is falsy
  3. If the panel should be there, check the browser console for country-intel chunk load failures and fix the underlying mount error

Example fix

// before
openCountryBriefByCode: async (code, country) => {
  await this.waitForUiReady();
  if (!this.state.countryBriefPage) throw new Error('Country brief panel is not initialised');
  await this.countryIntel.openCountryBriefByCode(code, country);
},

// after (graceful result instead of throw):
openCountryBriefByCode: async (code, country) => {
  await this.waitForUiReady();
  if (!this.state.countryBriefPage) {
    return { ok: false, status: 'denied', reason: 'country_brief_disabled' } as const;
  }
  await this.countryIntel.openCountryBriefByCode(code, country);
  return { ok: true } as const;
},
Defensive patterns

Strategy: try-catch

Validate before calling

// In the tool host, before dispatching to the panel:
if (!app.state.countryBriefPage) {
  return { ok: false, status: 'denied', reason: 'country_brief_unavailable' };
}

Type guard

function isCountryBriefReady(app: { state: { countryBriefPage: unknown } }): boolean {
  return app.state.countryBriefPage != null;
}

Try / catch

try { await openCountryBrief(code, country); } catch (e) { if (e instanceof Error && e.message === 'Country brief panel is not initialised') informAgent('country brief disabled in this session'); else throw e; }

Prevention

When it happens

Trigger: An agent (browser MCP client) calls open_country_brief during or after startup while the country brief page is disabled in panel settings, failed to mount, or is not part of this build/variant. It is NOT the startup-timeout path: waitForUiReady already resolved, so the UI as a whole is up and only this panel is missing.

Common situations: User disabled the country brief panel in settings before an agent session; the country-intel lazy chunk failed to load (network error) leaving the dashboard otherwise functional; a stripped-down variant that ships WebMCP tools but not every panel.

Related errors


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/8c9591f8ad3f8b94. Report an issue: GitHub.