Skip to content

Admin bar: floating chat panel across every wp-admin screen#70

Merged
lezama merged 1 commit into
mainfrom
feat/admin-bar-panel
May 19, 2026
Merged

Admin bar: floating chat panel across every wp-admin screen#70
lezama merged 1 commit into
mainfrom
feat/admin-bar-panel

Conversation

@lezama
Copy link
Copy Markdown
Owner

@lezama lezama commented May 19, 2026

Summary

Adds a global floating chat panel reachable from a toolbar item on every wp-admin screen. Click the chat icon in the admin bar → a slide-in drawer opens on the right edge with the same chat surface as the wp-admin → openclaWP → Chat page.

  • Hooks: admin_bar_menu for the toolbar item, admin_enqueue_scripts for the panel script, admin_footer for the React mount point + inline toggle bridge.
  • Reuses @automattic/agenttic-ui (<AgentUI>) and @wordpress/components (Button, Notice, SelectControl) — no new dependencies.
  • Extracts the inner chat surface into blocks/chat-shared/ChatSurface.jsx so the block view and the panel view share one component (tool-call confirmation, session handling, agent picker).
  • Drawer open/closed state persists in localStorage (openclawp:panel:open) so the panel re-opens on page nav. Esc closes.
  • Gated on manage_options for v1; an openclawp_admin_bar_panel_enabled filter lets hosts switch it off.
  • Same agent-filtering rules as the chat block (workflow drafter excluded; openclawp_chat_block_agents filter respected).

Why

Today openclaWP's chat only lives at /wp-admin/admin.php?page=openclawp — you have to navigate there to talk to the agent. The floating panel makes the agent reachable from any admin context (editing a post, browsing plugins, etc.), which is the surface a regular admin actually uses.

Test plan

  • Open any wp-admin page. The chat icon appears in the admin bar (right-side, before the user menu).
  • Click the icon. A drawer slides in from the right edge with the chat UI.
  • Send a message; the agent responds the same way the existing block does.
  • Close and re-open the panel — conversation persists.
  • Navigate to a different admin page — the panel re-opens if it was open before.
  • Press Esc while the drawer is open — it closes.
  • Set the openclawp_admin_bar_panel_enabled filter to false — the toolbar item disappears.
  • Tool-call confirmation card still works inside the panel (any gated ability the agent tries to call surfaces the Allow/Deny/Always-allow UI).
  • Existing Chat page (/wp-admin/admin.php?page=openclawp) still renders identically — the shared component extraction didn't regress.

Verified locally

  • npm run build — all bundles emit cleanly.
  • npm run lint — clean.
  • vendor/bin/phpunit --testsuite unit — 169/169 (was 169, no regression).

🤖 Generated with Claude Code

Adds a global toolbar item + slide-in drawer so the agent is reachable
from any wp-admin context (post editing, plugin browsing, etc.), not
only from /wp-admin/admin.php?page=openclawp.

- New `OpenclaWP_Admin_Bar_Panel` class wires three hooks:
  `admin_bar_menu` (toolbar node, priority 90, top-secondary),
  `admin_enqueue_scripts` (panel script + style on every admin screen),
  `admin_footer` (React mount point + inline toggle-script bridge).
- New React entry at `blocks/chat-panel/src/view.js` mounts a 480px
  right-edge drawer with open/closed state persisted to localStorage
  (`openclawp:panel:open`). Escape closes; the toolbar `<a>` dispatches a
  `openclawp:panel:toggle` event the drawer listens for.
- Refactor: inner conversation UI extracted to
  `blocks/chat-shared/ChatSurface.jsx`; both the chat block view and the
  new panel view import it so tool-call confirmation, session handling,
  and agent picking all live in one place.
- Same agent-filtering rules as the chat block (workflow drafter
  excluded; `openclawp_chat_block_agents` filter respected).
- Gated on `manage_options` by default; an
  `openclawp_admin_bar_panel_enabled` filter lets hosts switch it off.
- Zero new dependencies — only `@automattic/agenttic-ui` (existing) and
  `@wordpress/components`/`@wordpress/icons` (already provided by wp).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lezama lezama merged commit 1d866b7 into main May 19, 2026
4 of 6 checks passed
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