compat-ui

A set of front-end interaction rules for Compat, a compatibility layer for Wails and WebView applications. It defines how controls, menus, dialogs, focus, and outside-click behavior should work.

In plain words
What is it for?
Use it when building or changing tabs, toolbars, dropdowns, dialogs, context menus, product navigation, terminals, or code-editor areas in a Compat application.
Why use it?
It prevents interaction bugs such as controls needing two clicks, menus closing unreliably, or embedded terminals and code editors stealing focus.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/wcoreing/wworkbench/compat-ui
Clone the repo
git clone --depth 1 https://github.com/wcoreing/WWorkbench

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 718 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00718
Opus 5 $0.00000 $0.00359
Sonnet 5 $0.00000 $0.00144
Haiku 4.5 $0.00000 $0.00072

Measured yesterday against content hash bbcec69327a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

compat-ui scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/compat-ui.mdc · 48 lines

What it actually says

Compat 交互层

Compat 修 Wails/WebView 兼容性,不是视觉 UI 框架。长相可继续用 wn-* 或套 Ant / shadcn。

进口

import { pressProps, Select, ModalPortal, installFocusGate, chromeProps, focusHogProps } from '../components/compat'

旧路径 utils/presscomponents/Selectcomponents/ModalPortal 仅为兼容 re-export,新代码不要再用。

硬契约

  1. 命令控件(Tab、工具条、弹窗取消/保存、右键菜单项、树节点命令)→ 必须 pressProps,禁止裸 onClick 做切换与提交。
  2. 业务下拉 → 必须用 Select,或自绘弹出并接 useOutsideDismiss;禁止原生 <select>(系统层会吞第一次外点)。
  3. 弹层 → 用 ModalPortal 挂到 document.body;弹窗内容区对 backdrop 做 onPointerDown stopPropagation。
  4. 菜单/下拉的外点关闭 → 必须听 pointerdown(见 useDismissOnPointerDown),禁止 click/mousedownpressPropspreventDefault(pointerdown) 从而取消后续 mouse 事件;用 click 关菜单会导致「产品轨要点两次」。
  5. 切产品线setActiveProductdismissOverlays();Select/菜单须 useDismissOverlays 订阅,避免隐藏页 portal 挡住产品轨。
  6. 焦点域(FocusGate)
    • 抢焦内容(xterm / Monaco)→ data-ww-focus-hogfocusHogProps() / registerFocusHog
    • 命令壳(产品轨、顶栏)→ data-ww-chromechromeProps()(浮层盖住时坐标转发)
    • AppShellinstallFocusGate():内容区持焦时点到 任意命令控件button / .wn-select-trigger / 产品轨等)先 blur,首击必达
    • 查询栏 Select、工具条、Tab 都靠这条,不必再逐个标 chrome
    • 不要再为产品轨单独写坐标 capture hack

套其他 UI 框架

// 外观用第三方,交互走 Compat
<AntButton {...pressProps(onSave)}>保存</AntButton>
<Select className="your-skin" value={v} options={opts} onChange={setV} />

不要做

  • 为每个业务再写一套 Select / press
  • 用全局事件 hack 去「修复」原生 select
  • 把颜色、布局、Form 引擎塞进 Compat
  • 在业务里重复实现「从终端失焦再点轨」逻辑(应走 FocusGate)
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 48 lines · 0 tokens per session scan A bbcec69327a0

Subscribe to this mod's changes

compat-ui is a cursor rule published in the GitHub repository wcoreing/WWorkbench (23 stars, last pushed 6d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 718 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.