mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-24 14:26:29 +01:00
Compare commits
2 Commits
480a8bdd82
...
b9e54380db
| Author | SHA1 | Date | |
|---|---|---|---|
| b9e54380db | |||
| b4f1b32cef |
28
unified-design-system/PHASE2-PROMPT.md
Normal file
28
unified-design-system/PHASE2-PROMPT.md
Normal file
@ -0,0 +1,28 @@
|
||||
Implement Phase 2 of the shared component work: extend `~/utils/gatelock` (Python/Tk) with the composite widgets that four guard apps each reimplemented. Treat this as `override` on the spec gate — the spec is below, it is complete, and I do not want a round of questions before you start.
|
||||
|
||||
**Goal.** gatelock already owns the design tokens (`LockConfig`) and the Tk plumbing, and has four consumers. Its scope stops short of composite widgets, so each consumer grew its own. Move those into gatelock and retire the copies in two proof consumers.
|
||||
|
||||
**This is NOT a new package.** Add to `~/utils/gatelock`, which already exists and is consumed as `gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.4.1#subdirectory=gatelock`.
|
||||
|
||||
**Build these four, in order:**
|
||||
|
||||
1. `gatelock/widgets.py` — `make_button(parent, *, text, variant, command)`. Canonical implementation is diet-guard's `_gatelock_buttons.py::make_button`: its `variant` API picks the text colour *from* the fill, which structurally prevents the `fg`-vs-`on_fill` contrast bug the README documents. leetcode-guard's `_button` (no `<Return>` binding) and screen-locker's inline `tk.Button` are the regressions being retired. Two non-obvious traps both copies had to solve independently and which the shared version must keep: `<Return>` is unbound on `tk.Button` under X11, and the default focus ring is 1px black, invisible on `#211D1B`.
|
||||
2. `gatelock/widgets.py` — `heading()` and `row()`, from `leetcode_guard/_status_sections.py`.
|
||||
3. **Export the existing `ScrollableSurface`** and delete `leetcode_guard/status_view.py::_scrollable`, a hand-rolled reimplementation that lost `takefocus` and the focus ring the shared version already fixes. This one is a straight accessibility regression repair, not a refactor.
|
||||
4. `gatelock/widget_group.py` — `WidgetGroup`, the per-output fan-out reimplemented four times (~916 lines total: screen-locker 173, leetcode-guard 105, diet-guard 309, wake-alarm 329). Highest line-count win on this stack.
|
||||
|
||||
**Proof consumers: `diet-guard` and `leetcode-guard`** — the donor and the worst offender, so the API is validated against both ends. Bump **only these two**. Leave screen-locker and wake-alarm on their current pin: Phase 2 is additive, untouched consumers keep working, and restarting more live services than necessary is blast radius for no gain. Ask me before restarting anything live.
|
||||
|
||||
**Extraction criterion.** Build a component only where two or more repos already contain a structurally similar implementation. Shipping a widget nobody imports is the failure mode to avoid. Corollary I learned the hard way in Phase 1: when you extract something, **retire the donor copies in the same pass**, or you have shipped a duplicate rather than removed one.
|
||||
|
||||
**Verification gate — non-negotiable.** gatelock backs live systemd services; a bad import takes 3–4 of them down at once.
|
||||
|
||||
- `/usr/bin/python3 -c "import gatelock"` against the **real** interpreter, not a dev venv. The library is tag-pinned in site-packages while the apps are editable, so a cwd-relative check will lie to you.
|
||||
- Then diet-guard's and leetcode-guard's test suites.
|
||||
- Then launch each gate under `xvfb-run -s "-screen 0 1366x768x24"` and confirm buttons render **and `<Return>` activates them** — that is the specific regression this phase repairs, so it is the specific thing to observe.
|
||||
- Do **not** touch the gate window's X-grab path. Those fullscreen surfaces carry input-hijack invariants; a deadlock there has frozen the PC before.
|
||||
- `pre-commit run --files <changed>` in every touched repo, respect the 250-line file cap, and keep each repo's coverage bar.
|
||||
|
||||
**Done means:** the four items exist in gatelock with tests, the two proof consumers import them with their local copies deleted, `<Return>` verifiably activates a button in each gate under xvfb, and everything is committed and pushed.
|
||||
|
||||
Context, if you want it: `~/utils/unified-design-system/nielsen-audit.md` has the full grid and the Phase 1 record. Phase 1 (`~/utils/design_system`, Dart) is done — 7 exports, 100% coverage, six consumers — and is the pattern to imitate: `publish_to: none`, own analysis config, own tests, own coverage gate, tag-pinned git dep.
|
||||
28
unified-design-system/PHASE3-PROMPT.md
Normal file
28
unified-design-system/PHASE3-PROMPT.md
Normal file
@ -0,0 +1,28 @@
|
||||
Implement Phase 3 of the shared component work: create `~/utils/web_ui/` (TypeScript) and migrate two proof consumers onto it. Treat this as `override` on the spec gate — the spec is below, it is complete, and I do not want a round of questions before you start.
|
||||
|
||||
**Goal.** Seven web repos define seven different vocabularies for the same palette: `--surface-1` vs `--panel` vs `--card`; `--text` vs `--ink` vs `--fg` vs `--bone`; spacing as `--space-N` vs `--sp-N` vs `--sp-xs`. Two of them additionally carry the same two components, drifted. Give the web stack the token + component layer that Dart already has.
|
||||
|
||||
**Build these three:**
|
||||
|
||||
1. `tokens.css` — one `:root` block using the canonical variable names from `~/utils/unified-design-system/README.md` and `tokens.md`. The palette is frozen: ink `#211D1B`, ink-raised-1 `#2B2624`, ink-raised-2 `#38312E`, line-dark `#463E3A`, text-on-dark `#ECEAE9`, muted-on-dark `#AAA09A`, paper `#F6F4F3`, paper-raised `#FCFBFB`, line-light `#E0DAD7`, muted-on-light `#70625B`, accent `#B8862E`, success `#8A9A3C`, warning `#E0A63C`, danger `#E2585F`, on-fill `#211D1B`. Spacing 4/8/16/24/32/48, radius 8/12/16, type 12/14/16/20/24/32. Do not invent new values; these are the same numbers `~/utils/design_system` ships for Dart.
|
||||
2. `RangeSlider` — canonical is **dufs-cloud's**, whose pure `fractionFromPointer(rect, clientX)` is testable without layout (jsdom has none). awesome-mcp-explorer's copy has drifted 196 lines. Keep the pure function pure; that is the whole reason this one is the donor.
|
||||
3. `FilterBar` + `filter-sort.ts` — reconcile dufs-cloud (174 lines) vs awesome-mcp-explorer (225).
|
||||
|
||||
**Consumption mechanism — already decided, do not re-litigate.** A git dep `"@kuhyx/web-ui": "github:kuhyx/utils#web_ui-v0.1.0"`, matching the Dart/Python tag convention rather than introducing npm workspaces. **Ship a prebuilt `dist/` (tsc → ESM + `.d.ts`) committed in the tag.** Raw `.tsx` in `node_modules` would need per-repo bundler config, because Vite does not transpile dependencies by default; a committed `dist/` keeps consumers at zero config. This is the only stack with no existing precedent — verified: no `workspaces` key and no `file:`/`link:`/`github:kuhyx` dep anywhere — so the mechanism is the risky part, not the components.
|
||||
|
||||
**Proof consumers: `dufs-cloud` and `awesome-mcp-explorer`** — the only two with confirmed shared components. Migrate both; do not stop at one.
|
||||
|
||||
**Extraction criterion.** Build a component only where two or more repos already contain a structurally similar implementation. Nielsen's ten elements are the audit grid, not a build list — shipping a widget nobody imports is the failure mode to avoid. Two traps from Phase 1: a **name collision is not a duplicate** (judge structurally — the three `FilterSheet`s share a name but one uses no chips at all), and when you extract something, **retire the donor copies in the same pass**, or you have shipped a duplicate rather than removed one.
|
||||
|
||||
**An open question you will hit.** The design system has one accent and therefore no answer for "N mutually distinguishable hues" — a categorical ramp for charts, tags and category dots. billsplit's four category colours were deliberately left unmapped for this reason. If `FilterBar` or anything else needs categorical colour, **do not invent a ramp inline**; raise it with me as its own decision.
|
||||
|
||||
**Verification.**
|
||||
|
||||
- `npm test` in both proof consumers.
|
||||
- Verify at `1366x768` and `1024x600` with no horizontal scroll, and confirm `:focus-visible` is styled — an unstyled focus ring is the accessibility regression this layer is supposed to prevent.
|
||||
- Confirm the migrated repos actually render from `tokens.css`: grep that their old bespoke custom properties are gone, not merely shadowed.
|
||||
- `pre-commit run --files <changed>` in every touched repo; respect the 250-line file cap.
|
||||
|
||||
**Done means:** `~/utils/web_ui` exists with a committed `dist/`, tagged `web_ui-v0.1.0`; both proof consumers import it, with their local `RangeSlider`/`FilterBar`/token blocks deleted; tests pass in both; and everything is committed and pushed.
|
||||
|
||||
Context, if you want it: `~/utils/unified-design-system/nielsen-audit.md` has the full grid, the deferred clusters, and the Phase 1 record. Phase 1 (`~/utils/design_system`, Dart) is done — 7 exports, 100% coverage, six consumers — and is the pattern to imitate: `publish_to: none`, own lint config, own tests, own coverage gate enforced in CI, tag-pinned dep.
|
||||
@ -76,6 +76,9 @@ exists to prevent, so the honest status per export:
|
||||
| `EmptyState` | **none yet** — donor is home_inventory (3 sites), unmigrated |
|
||||
| `AppStatusColors` | **none yet** — 4 donors, all unmigrated |
|
||||
|
||||
Palette/token consumers beyond the two proof apps, added the same day:
|
||||
`focus_owner`, `kuhylog`, `epopeja_karta` (tokens only) and `billsplit`.
|
||||
|
||||
The last two ship ahead of their consumers. That is defensible (both have
|
||||
real donors waiting, and `AppStatusColors` must exist for `showError` to read
|
||||
the danger hue off the theme) but it is not *validated*, and it should be
|
||||
@ -129,30 +132,46 @@ The five `GitHubMirrorScreen` copies each carry a near-verbatim "kept
|
||||
app-local rather than folded into `sync_settings_ui`" comment. That decision
|
||||
deserves revisiting **on its own**, not smuggled into a component extraction.
|
||||
|
||||
### Flutter — palette drift to correct
|
||||
### Flutter — palette drift: DONE 2026-08-14
|
||||
|
||||
Standing decision (2026-08-14): every app uses **exactly** the frozen palette;
|
||||
where copies disagree, the most popular wins. That is unambiguous — 9 of 10
|
||||
theme files use the gold `#B8862E` family.
|
||||
Standing decision: every app uses **exactly** the frozen palette; where copies
|
||||
disagree, the most popular wins. That was unambiguous — 9 of 10 theme files
|
||||
already used the gold `#B8862E` family. All four drifted repos are migrated.
|
||||
|
||||
| Repo | Drift | Fix |
|
||||
| Repo | Drift that was fixed | How |
|
||||
|---|---|---|
|
||||
| `testsAndMisc/focus_owner` | **entirely off-palette**: cool `#5B9DD9` accent, `#1B1D21` field, `#D9776B` danger, `#E8EAED` text. Its doc comment claims it matches the other `com.kuhy.*` apps; it does not. Worse, the same six constants are **duplicated verbatim** in `main.dart:16-21` as `_kField`…`_kDanger` — the file says they were "lifted out of main.dart", but the originals were never deleted. | adopt `design_system`; delete both copies |
|
||||
| `kuhylog` | the only repo using `ColorScheme.fromSeed` (seed `#3B82F6`, blue) — the opposite of the convention every other theme file explicitly documents. Also has `scoreColor(ColorScheme, int)`, which is `AppStatusColors`' job done as a function. | adopt `design_system` + `AppStatusColors` |
|
||||
| `epopeja_karta` | no `theme.dart` at all; `ColorScheme` inlined in `app.dart:12-20` | adopt `design_system` |
|
||||
| `billsplit` | `ColorScheme.fromSeed(seedColor: Colors.teal)` in `main.dart:31`, plus 16 ad hoc literals | adopt `design_system` |
|
||||
| `diet-guard`, `macro-cam` | scales drifted from the six-repo consensus | adopt `design_system` |
|
||||
| `testsAndMisc/focus_owner` | **entirely off-palette**: cool `#5B9DD9` accent, `#1B1D21` field, `#D9776B` danger. Its doc comment claimed it matched the other `com.kuhy.*` apps; it did not. The same six constants were also **duplicated verbatim** in `main.dart:16-21` — the file said they had been "lifted out", but the originals were never deleted. | `theme.dart` now aliases `AppPalette`, so the ~80 call sites keep their names; both copies gone. Literals 15 → 2 (`Colors.transparent`). Verified on the Pixel 6a. |
|
||||
| `kuhylog` | the only repo using `ColorScheme.fromSeed` (blue `#3B82F6`) — the opposite of what every other theme file documents. | `KuhylogTheme.of()` delegates to `buildLightTheme`/`buildDarkTheme`. Kept as a wrapper for its `visualDensity`, flat `cardTheme` and `scoreColor`. Literals 1 → 0. |
|
||||
| `epopeja_karta` | `ColorScheme` inlined in `app.dart`, no `theme.dart`. | Imports **tokens only** — see below. Literals 9 → 0. |
|
||||
| `billsplit` | `ColorScheme.fromSeed(Colors.teal)` plus 15 ad hoc literals that mostly bypassed the theme entirely. | `buildLightTheme()`; error family → `error`/`onError`/`errorContainer`, muted text → `onSurfaceVariant`. Literals 15 → 4. |
|
||||
| `diet-guard`, `macro-cam` | scales drifted from the six-repo consensus | **still outstanding** — adopt `design_system` |
|
||||
|
||||
`focus_owner` is a live enforcement surface, so its visual change wants a
|
||||
human look rather than a blind migration — it is the one item here that is
|
||||
deferred for a reason beyond time.
|
||||
Two deliberate exceptions, so nobody "fixes" them back:
|
||||
|
||||
- **`epopeja_karta` adopts `AppPalette`, not `buildDarkTheme()`.** Its nine
|
||||
slots were already byte-identical to the frozen palette, so only the
|
||||
transcription was local. It is one dense screen with a test asserting
|
||||
nothing scrolls, and the shared theme's larger type scale plus
|
||||
`dividerTheme.space` overflows it by 34px. Typography there is a product
|
||||
decision; colour is the identity, and colour is what the system owns.
|
||||
Importing tokens leaves the rendered `ThemeData` identical, so the no-scroll
|
||||
test passes by construction rather than by hitting a pixel target.
|
||||
- **`billsplit` keeps its four category-dot colours** (`deepOrange`/`amber`/
|
||||
`blueGrey`/`teal` for alcohol/mixer/deposit/other). They encode *category
|
||||
identity*, not a theme role, and a single-accent system has no four distinct
|
||||
hues to lend. Folding them into `primary`/`secondary`/`tertiary` would make
|
||||
the categories stop being distinguishable, which is their only job. **This
|
||||
is the open categorical-ramp question** — the design system currently has no
|
||||
answer for "N mutually distinguishable hues", and it needs one before any
|
||||
chart, tag or category UI can be built on it.
|
||||
|
||||
### Remaining Flutter adopters
|
||||
|
||||
`home_inventory`, `dufs-cloud`, `habit_stack`, `diet-guard`, `macro-cam`,
|
||||
`wake-alarm/phone_app`, `kuhylog`, `epopeja_karta`, `billsplit`,
|
||||
`focus_owner`. Each drops its local `theme.dart` for the tag-pinned dep, as
|
||||
todo and untools now do.
|
||||
`wake-alarm/phone_app`. Each drops its local `theme.dart` for the tag-pinned
|
||||
dep, as todo, untools, focus_owner, kuhylog, epopeja_karta and billsplit now
|
||||
do. These six were never off-palette — they transcribe the right values by
|
||||
hand — so this is duplication cleanup, not a visual fix.
|
||||
|
||||
### Phase 2 — Python/Tk (`~/utils/gatelock`), not started
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user