Skip to content

feat: a routing page built around keys, with rules edited in order and a dry run that says which route it used - #47

Merged
fylorn merged 3 commits into
devfrom
feat/routing-page
Sep 19, 2026
Merged

fylorn merged 3 commits into
devfrom
feat/routing-page

Conversation

@fylorn

@fylorn fylorn commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Routes are assigned to keys: each key uses one route, and keys without one use the default route. The routing page now reads that way, following the layout of the upstream page.

What was wrong with the old page

  • The default route appeared twice (a card and a list row).
  • The rule and __all__ group that the gateway synthesises were shown as if they were in the file, with delete and locate buttons that could never work.
  • "Add rule" appended after the catch-all, so the new rule's forward or deny was never chosen.
  • Rules could not be edited or reordered.
  • The dry run silently evaluated the first key in the config.

What the page does now

  • Two tabs, Routes and Groups. Lists are read-only; edits happen in dialogs opened from the row menu, the context menu or a double click. Every save is one config version.
  • Routes list: the default route comes first and names the keys that follow it. Each row lists the rules that decide where requests go, and flags a missing catch-all or rules shadowed by one. Row menu: edit, dry run, duplicate, set as default (confirming which keys move), locate in config file, delete (choosing which route its keys move to, the default route preselected).
  • Route dialog: name, the keys that use this route (writes the same clients[].route field a key stores), and the rules in order. Reorder by dragging or from the row menu. New rules go before the catch-all, and shadowed rules can be moved above it in one click.
  • Rule dialog: conditions with an input per field type (model with suggestions and a count of matching known models, comparisons, yes/no, formats, assistant request classes, keys, chosen upstream), then forward / deny / continue, then rewrite and guard add-ons. If a condition targets assistant requests that are not routed yet, the dialog says so and can route them in the same save.
  • Groups: the built-in all-upstreams group is labelled as built in and cannot be edited. Select groups can switch their preferred upstream from the row menu. A group that rules still reference cannot be deleted, and the dialog links to those routes. The group dialog sets strategy, members and their order, the preferred member and stickiness.
  • Dry run is a dialog. Pick a key, a route, or the unsaved draft from the route dialog. It recomputes as the request changes and lists every rule with the reason it did or did not decide.

The built-in group is labelled as all upstreams in request details too. The routing section of Config.tsx and the old Routes.tsx / DryRun.tsx are removed.

Key editing itself is out of scope here; the keys page will be redesigned separately. This page only relies on keys referencing a route.

Core dependency

Needs ThinkWatch-Core v0.8.0 or later (ThinkWatchProject/ThinkWatch-Core#44). After rebasing onto dev, this uses the v0.8.1 pin that #48 brought in. That version provides:

  • /routes, /groups, /default_route and /models endpoints;
  • key assignment and assistant-request routing on route save;
  • reassign_to on route delete;
  • full rule views;
  • dry-run targets by route and by draft.

Test plan

  • pnpm typecheck, pnpm vitest run (102, including 10 new routing model tests), pnpm build
  • cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test against the v0.8.0 tag
  • Clicked through in the isolated preview (mockIPC) at 1100×720, light and dark:
    • list and initial state (synthesised default only);
    • new, edit and duplicate route;
    • drag reorder and moving a shadowed rule above the catch-all;
    • rule conditions, the phase-two constraint, continue plus guard;
    • key assignment and save;
    • dry run for a key, a route and a draft;
    • groups tab, preferred-upstream submenu, group dialog;
    • blocked group delete with jump to the referencing route;
    • route delete with key reassignment, set as default.

🤖 Generated with Claude Code

fylorn and others added 3 commits September 19, 2026 18:57
…d a dry run that says which route it used

The old page repeated the default route in a card and in the list, showed the
synthesised default rule and __all__ group as if they were in the file (with
delete and locate buttons that could never work), and appended every new rule
after the catch-all, where its forward or deny is never chosen. Rules could not
be edited or reordered, and the dry run silently evaluated the first key.

The page now follows the upstream page:

- Two tabs, routes and groups. Lists are read-only; everything is done in
  dialogs from the row menu, the context menu or a double click, and every
  save is one config version.
- Routes: the default route leads the list and names the keys that follow it.
  Each row spells out the rules that decide where requests go, and flags a
  missing catch-all or rules shadowed by one. Row menu: edit, dry run,
  duplicate, set as default (confirming which keys move), locate, delete
  (choosing where its keys go, the default route by default).
- Route dialog: name, which keys use the route (the same field a key's route
  is stored in), and the rules in order. Drag or use the row menu to reorder;
  new rules go before the catch-all; shadowed rules can be lifted in one click.
- Rule dialog: conditions with a control per kind (model with suggestions and
  a count of matching known models, comparisons, yes/no, formats, assistant
  request classes, keys, chosen upstream), then forward / deny / continue,
  then rewrite and guard add-ons. A condition on assistant requests that are
  not routed says so and can route them in the same save.
- Groups: the built-in all-upstreams group is listed as such and cannot be
  edited; select groups can switch their preferred upstream from the row
  menu; a group still referenced cannot be deleted. The group dialog sets
  strategy, members and their order, the preferred member and stickiness.
- Dry run is a dialog: pick a key (or run a route, or the unsaved draft from
  the route dialog), it recomputes as the request changes and lists every
  rule with why it did or did not decide.

The built-in group is labelled as all upstreams in request details too. The
routing section of Config.tsx and the old Routes/DryRun components are gone.

Pins ThinkWatch-Core v0.8.0, which adds the route and group endpoints this
page saves through and the dry run's route and draft targets.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… group member

- The model suggestion list was portaled to <body>, which a modal Radix
  dialog makes inert (pointer-events: none), so clicking a suggestion did
  nothing. The list now renders inside the dialog it belongs to.
- Pressing Escape with the suggestion list open closed the whole dialog and
  dropped unsaved edits. It now only closes the list.
- Group members wrap instead of being clipped.
- The default route row no longer adds a line about keys without a route;
  the default badge already says it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…list changes

Suggestions were read again only when the config version changed, so models
core fetched in the background after startup never showed up in them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit ddf6367 into dev Sep 19, 2026
2 checks passed
@fylorn
fylorn deleted the feat/routing-page branch September 19, 2026 11:04
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