Skip to content

wp-admin: hide-when-empty submenu items#68

Merged
lezama merged 1 commit into
mainfrom
ux/menu-hide-when-empty
May 19, 2026
Merged

wp-admin: hide-when-empty submenu items#68
lezama merged 1 commit into
mainfrom
ux/menu-hide-when-empty

Conversation

@lezama
Copy link
Copy Markdown
Owner

@lezama lezama commented May 19, 2026

Summary

A fresh install of openclaWP shows 13 submenu items, most pointing to empty pages. This PR makes most capability surfaces appear in the sidebar only when they have at least one entry — the system reacts to its own state rather than imposing a taxonomy on the user.

Always visible (the conceptual primitives every install needs):

  • Chat, Channels, Workflows, Custom Tools, Settings

Hide-when-empty:

  • Routines, Usage, Knowledge Base, MCP Servers, WhatsApp, Connected Clients, Tool activity, MCP Clients

Deep-link URLs still work — only the menu visibility is affected. An openclawp_admin_menu_always_visible filter lets host installs override.

Why

Found during a UX review of the full plugin tour (finding #4). The "Advanced" / collapse alternative was rejected because:

  • Each capability is its own encapsulated primitive — no editorial meta-group needed.
  • Grouping rots as the plugin grows; data-driven visibility doesn't.

Test plan

  • On a fresh install, the openclaWP submenu shows only Chat, Channels, Workflows, Custom Tools, Settings.
  • Create one MCP server → MCP Servers appears in the menu next pageload.
  • Create one Custom Tool, delete it → Custom Tools remains visible (it's always-visible).
  • Delete all MCP servers → MCP Servers disappears from the menu next pageload.
  • Direct URL admin.php?page=openclawp-mcp-servers still works when hidden from the menu.
  • Adding a slug to the openclawp_admin_menu_always_visible filter keeps that item visible regardless of population.

Follow-up (not in this PR)

  • Add a "Discover" / Quick-start panel on the Chat page so first-time users can see all capabilities even when their menu items are hidden.

🤖 Generated with Claude Code

A fresh install of openclaWP shows 13 submenu items, most pointing to
empty pages. This commit makes most capability surfaces appear in the
sidebar only when they have at least one entry — the system reacts to
its own state instead of imposing a taxonomy on the user.

Always visible: Chat, Channels, Workflows, Custom Tools, Settings.
Hide-when-empty: Routines, Usage, Knowledge Base, MCP Servers, WhatsApp,
Connected Clients, Tool activity, MCP Clients.

Pages remain reachable via their `?page=…` URL even when hidden — only
the menu entry is gated. An `openclawp_admin_menu_always_visible` filter
lets host installs force-show a surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lezama lezama merged commit 03e1468 into main May 19, 2026
5 of 6 checks passed
@lezama lezama deleted the ux/menu-hide-when-empty branch May 19, 2026 15:06
lezama added a commit that referenced this pull request May 19, 2026
…#68) (#69)

Adds a "Discover capabilities" panel below the chat UI on the openclaWP
Chat admin page. Each row shows one capability surface with a one-line
description, a population count or "Not set up yet" hint, and a link to
that page.

This is the discovery anchor that complements #68 (hide-when-empty
submenu items): with the menu condensed, a first-time user now has one
obvious place to see what openclaWP can do.

Refactor:
- `OpenclaWP_Admin_Menu_Visibility::is_surface_populated( string $slug )
  : bool` and `surface_count( string $slug ): ?int` extracted as public
  static methods so the menu gating and the Discover panel share one
  source of truth (no risk of disagreeing about whether a capability is
  set up).
- New `parent_for_slug()` convenience wrapper centralises the
  `add_submenu_page` parent-resolution pattern; 8 admin classes updated
  to use it.

The panel is dismissible per user (stored in
`openclawp_discover_dismissed` user meta). Settings page exposes a
"Show it again" affordance.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
lezama added a commit that referenced this pull request May 19, 2026
Adds an `openclawp_agent_file` CPT and a wp-admin → openclaWP → Agent
files surface for authoring markdown documents (AGENTS.md, SOUL.md,
BOOTSTRAP.md, …) that customise agent behaviour without touching PHP.
Files target a specific agent via the `agent_slug` meta, or apply
globally when that meta is empty.

The new submenu is hide-when-empty (PR #68 pattern) and the Discover
panel (PR #69) picks up the new surface automatically through the shared
`OpenclaWP_Admin_Menu_Visibility::surface_count()` helper.

A follow-up PR will wire the file contents into the runtime prompt
assembler so the agent actually reads them — this PR ships the CPT +
admin UI first so admins can start authoring while the runtime side
bakes (TODO note in the store class header).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant