diff --git a/AGENTS.md b/AGENTS.md index a9467e3..482a094 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,7 +9,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord ## Key Decisions - Runtime: Cloudflare Workers via the Nitro `cloudflare_module` preset (`_worker.js`), H3 event handlers in `server/routes/` -- UI: Vue 3 + Tailwind CSS v4 (`@tailwindcss/vite`) + `@elysola/ui` (Nuxt module, `Rc` prefix); admin console is a client-side SPA (`routeRules: "/admin/**": { ssr: false }`), home/legal pages render server-side; app-level composites (`ConfirmDialog`) are built on the reka-ui primitives that `@elysola/ui` ships (same copy, pre-bundled via `vite.optimizeDeps.include` so dev keeps a single instance and dialogs/popovers stack correctly) and styled like their Rc counterparts +- UI: Vue 3 + Tailwind CSS v4 (`@tailwindcss/vite`) + `@elysola/ui` (Nuxt module, `Rc` prefix); admin console is a client-side SPA (`routeRules: "/admin/**": { ssr: false }`), home/legal pages render server-side; app-level composites (`FilterCombobox`, `ConfirmDialog`) are built on the reka-ui primitives that `@elysola/ui` ships (same copy, pre-bundled via `vite.optimizeDeps.include` so dev keeps a single instance and dialogs/popovers stack correctly) and styled like their Rc counterparts - Styling: Elysola UI supplies semantic components and blue theme tokens; `app/assets/css/main.css` retains `--wh-*` RGB-triplet aliases for app-specific Tailwind utilities and bespoke layouts (avoiding collision with Elysola's `--surface`/`--text`/`--border` hex tokens); theme switching supports auto/light/dark via `useTheme` / `ThemeToggle`, toggling `.dark` with inline anti-flash head script - Discord interactions: HTTPS Interactions Endpoint (`POST /discord/interactions`, Ed25519-signed) — no Discord Gateway / Durable Object; bot stays offline, messages always sent via REST - Storage: D1 is the source of truth for config (routes/groups via `d1_routes`/`d1_groups`, see `server/lib/storage/config-store.ts`; each route's per-group order lives in `d1_routes.position` — migration 0012 — and routes load ordered by `group_id, position, id`, falling back to id order on an unmigrated database), send/audit logs, dedup (`dedup_keys`), delivery state (`delivery_state`) and message tracking (`message_tracking` via `server/lib/storage/d1.ts` `canUseD1` gate). KV keeps only cache + short-lived/ephemeral state (tokens, OAuth state, admin sessions, `msg:*`-adjacent locks, per-group secrets `tenant:*`, invites, i18n overrides) with explicit TTLs. R2 parks oversized queue payloads (`webhooks/YYYY/MM/DD/*.json`, `server/lib/storage/payload.ts`) instead of KV. A `storage-prune` scheduled task cleans up expired dedup/delivery/message-tracking rows diff --git a/app/assets/css/main.css b/app/assets/css/main.css index c68bee5..b9bba67 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -795,6 +795,232 @@ grid-area: name; } + /* ---- Filter combobox (FilterCombobox.vue; its popover is portaled, so not scoped) ---- */ + .filter-combo { + position: relative; + width: 100%; + min-width: 0; + } + .filter-combo-anchor { + display: flex; + min-height: 2.25rem; + width: 100%; + align-items: center; + gap: 0.25rem; + border-radius: 0.5rem; + background: rgb(var(--wh-surface)); + padding: 0 0.375rem 0 0.75rem; + box-shadow: + inset 0 0 0 1px rgb(var(--wh-border-strong)), + 0 1px 2px rgb(0 0 0 / 0.05); + cursor: text; + transition: box-shadow 150ms ease; + } + .filter-combo-anchor:focus-within { + box-shadow: inset 0 0 0 2px rgb(var(--wh-accent)); + } + .filter-combo-anchor.is-invalid { + box-shadow: inset 0 0 0 1px rgb(var(--wh-bad)); + } + .filter-combo-anchor.is-invalid:focus-within { + box-shadow: inset 0 0 0 2px rgb(var(--wh-bad)); + } + .filter-combo-anchor.is-multi { + flex-wrap: wrap; + padding: 0.25rem 0.375rem 0.25rem 0.375rem; + } + .filter-combo-chip { + display: inline-flex; + max-width: 100%; + align-items: center; + gap: 0.25rem; + border-radius: 0.375rem; + background: rgb(var(--wh-accent-dim)); + padding: 0.125rem 0.25rem 0.125rem 0.5rem; + color: rgb(var(--wh-accent-text)); + font-family: var(--font-mono); + font-size: 0.72rem; + font-weight: 500; + line-height: 1.25rem; + } + .filter-combo-chip.is-invalid { + background: rgb(var(--wh-bad-dim)); + color: rgb(var(--wh-bad)); + text-decoration: line-through; + text-decoration-color: rgb(var(--wh-bad) / 0.6); + } + .filter-combo-chip.is-invalid .filter-combo-chip-x { + color: rgb(var(--wh-bad)); + } + .filter-combo-chip-text { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .filter-combo-chip-x { + display: grid; + flex: none; + width: 1.125rem; + height: 1.125rem; + place-items: center; + border-radius: 9999px; + color: rgb(var(--wh-accent)); + cursor: pointer; + } + .filter-combo-chip-x:hover { + background: rgb(var(--wh-accent) / 0.15); + } + .filter-combo-chip-x:focus-visible { + outline: 2px solid rgb(var(--wh-accent)); + outline-offset: 1px; + } + .filter-combo-input { + min-width: 4rem; + flex: 1 1 4rem; + border: 0; + background: transparent; + padding: 0.375rem 0; + color: rgb(var(--wh-text)); + font-size: 0.8125rem; + outline: none; + } + .filter-combo-anchor.is-multi .filter-combo-input { + padding-left: 0.375rem; + } + .filter-combo-input.is-mono { + font-family: var(--font-mono); + font-size: 0.78rem; + } + .filter-combo-input::placeholder { + color: rgb(var(--wh-faint)); + } + .filter-combo-trigger { + display: grid; + flex: none; + width: 1.5rem; + height: 1.5rem; + place-items: center; + border-radius: 0.375rem; + color: rgb(var(--wh-faint)); + } + .filter-combo-trigger:hover { + color: rgb(var(--wh-text)); + } + .filter-combo-error { + margin: 0.3rem 0 0; + color: rgb(var(--wh-bad)); + font-size: 0.72rem; + } + .filter-combo-pending { + margin: 0.3rem 0 0; + color: rgb(var(--wh-warn)); + font-size: 0.72rem; + } + .filter-combo-content { + z-index: 55; + width: max(var(--reka-combobox-trigger-width), 17rem); + max-width: calc(100vw - 1rem); + overflow: hidden; + border-radius: 0.5rem; + background: rgb(var(--wh-surface)); + box-shadow: + inset 0 0 0 1px rgb(var(--wh-border)), + 0 4px 6px -1px rgb(0 0 0 / 0.1), + 0 2px 4px -2px rgb(0 0 0 / 0.1); + color: rgb(var(--wh-text)); + } + .filter-combo-content[data-state="open"] { + animation: filter-combo-in 120ms ease-out; + } + @keyframes filter-combo-in { + from { + opacity: 0; + transform: translateY(-2px); + } + } + .filter-combo-viewport { + max-height: min(18rem, var(--reka-combobox-content-available-height, 18rem)); + overflow-y: auto; + padding: 0.25rem; + overscroll-behavior: contain; + } + .filter-combo-group { + padding: 0.5rem 0.625rem 0.25rem; + color: rgb(var(--wh-faint)); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; + } + .filter-combo-item { + position: relative; + display: flex; + min-height: 2rem; + align-items: center; + gap: 0.75rem; + border-radius: 0.375rem; + padding: 0.375rem 2rem 0.375rem 0.625rem; + font-size: 0.8125rem; + outline: none; + cursor: pointer; + user-select: none; + } + .filter-combo-item[data-highlighted] { + background: rgb(var(--wh-surface-3)); + } + .filter-combo-item-value { + flex: none; + font-family: var(--font-mono); + font-size: 0.78rem; + } + .filter-combo-item-hint { + min-width: 0; + flex: 1 1 auto; + overflow: hidden; + color: rgb(var(--wh-muted)); + font-size: 0.75rem; + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; + } + .filter-combo-item-check { + position: absolute; + right: 0.5rem; + display: grid; + place-items: center; + color: rgb(var(--wh-accent)); + } + .filter-combo-item.is-create { + color: rgb(var(--wh-accent)); + font-weight: 600; + } + .filter-combo-item-create { + min-width: 0; + overflow-wrap: anywhere; + } + .filter-combo-note { + margin: 0; + padding: 0.75rem 0.625rem; + color: rgb(var(--wh-faint)); + font-size: 0.75rem; + text-align: center; + } + .filter-combo-note.is-error { + color: rgb(var(--wh-bad)); + text-align: left; + } + @media (pointer: coarse) { + .filter-combo-item { + min-height: 2.5rem; + } + } + @media (prefers-reduced-motion: reduce) { + .filter-combo-content[data-state="open"] { + animation: none; + } + } + .node-editor { @apply mb-1; } diff --git a/app/components/FilterCombobox.vue b/app/components/FilterCombobox.vue new file mode 100644 index 0000000..5d16d11 --- /dev/null +++ b/app/components/FilterCombobox.vue @@ -0,0 +1,416 @@ + + + + + + {{ v }} + + + + + + + + + + + {{ t(commitError) }} + + {{ t("combo.pending", { value: draftText }) }} + + + + + + + + {{ section.name }} + + + {{ opt.value }} + {{ opt.hint }} + + + + + + + + {{ + t("combo.useValue", { value: draftText }) + }} + + + {{ t(liveError) }} + + + {{ creatable ? t("combo.typeToAdd") : t("combo.empty") }} + + + + + + + + diff --git a/app/composables/useI18n.ts b/app/composables/useI18n.ts index 9673157..14a29ea 100644 --- a/app/composables/useI18n.ts +++ b/app/composables/useI18n.ts @@ -283,6 +283,11 @@ const en: Dict = { "routeEditor.errPath": "Field filters need a path", "routeEditor.errValues": "Add at least one value", "routeEditor.errGroupEmpty": "Group needs at least one condition", + "combo.empty": "No matches", + "combo.typeToAdd": "Type a value to add it", + "combo.useValue": "Use “{value}”", + "combo.remove": "Remove {value}", + "combo.pending": 'Not added yet: press Enter to add "{value}"', "valid.tooLong": "Patterns longer than 200 characters never match", "valid.regex": "Invalid regular expression", "valid.number": "Comparison operators need a number", @@ -702,6 +707,11 @@ const zh: Dict = { "routeEditor.errPath": "字段过滤需要路径", "routeEditor.errValues": "至少需要一个值", "routeEditor.errGroupEmpty": "分组至少需要一个条件", + "combo.empty": "无匹配项", + "combo.typeToAdd": "输入内容后即可添加", + "combo.useValue": "使用“{value}”", + "combo.remove": "移除 {value}", + "combo.pending": "尚未添加:按回车添加“{value}”", "valid.tooLong": "超过 200 个字符的模式永远不会匹配", "valid.regex": "无效的正则表达式", "valid.number": "比较运算需要数字",
{{ t(commitError) }}
+ {{ t("combo.pending", { value: draftText }) }} +
+ {{ t(liveError) }} +
+ {{ creatable ? t("combo.typeToAdd") : t("combo.empty") }} +