Gabriel's form prompt-shortcuts-into-a-plugin_dkhipt: everything moves — the owner's library, its editor and audience matrix, the guest sharing, guests' own shortcuts and prefs, the built-in Changes chip. The core keeps the composer's chips engine, the always-on notify line and the prompt pills. Platform hooks (generic, reused by the keyboard-shortcuts move): - ui.pages[].nav "settings" (+ group, after): a Settings entry routed at /settings/p/<id>/<page>, listed in the panel, the drawers, the search and the palette, right after the entry `after` names (a core id or another plugin page's id; else the end of its group). - top-level "seed": true: an app plugin installed once from the seed dir at start, like provider-* / harness-*. - composer.shortcuts: "position": "first", runners: [] and hidden kept, 64 chips; a POSTed action of a provider drops its cache and publishes composer-shortcuts (guests too) so every composer refetches. - frame bridges aiAgentPlugin.pickIcon (the app's glyph picker in a host dialog) and iconSvg(keys); a page's init.lang. The move: - carryover.prompt_shortcuts: the owner's promptShortcuts (audience made explicit, a pre-v4 blob folding the old guest list) → library.json, each guest's promptShortcuts + shortcutPrefs → their personal.json, once. - settings v7 drops promptShortcuts / shortcutPrefs; settings/shortcuts.py, /api/me sharedShortcuts and guest-defaults promptShortcuts are gone. - Settings → Skills & agents (/settings/setup) is its own entry; /settings/shortcuts forwards to the plugin's page (#skills → setup), saved panel and drawer layouts keep the old slot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
"""
|
|
The composer's un-send sweep curve — the owner's, for every user.
|
|
|
|
The owner edits it in Settings → Composer (``@gabvdl/ui``'s ``CurveEditor``);
|
|
it lives in their settings store (``ui-state`` ``ai-agent-settings`` →
|
|
``state.unsendCurve``, ``null`` = the library's default). Guests don't edit it:
|
|
their composers read it **live** from ``/api/me`` (``unsendCurve``), and an
|
|
owner save that changes it pings their clients to refetch
|
|
(``settings/routes.py``). The window's
|
|
*length* is each user's own (``state.unsendMs``), so it isn't here.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import math
|
|
|
|
SETTINGS_KEY = "ai-agent-settings"
|
|
# A curve is a handful of keyframes; anything longer isn't one the editor made.
|
|
MAX_POINTS = 32
|
|
|
|
|
|
def _num(v) -> bool:
|
|
return isinstance(v, (int, float)) and not isinstance(v, bool) and math.isfinite(v)
|
|
|
|
|
|
def clean_curve(curve) -> dict | None:
|
|
"""``curve`` as a well-formed ``AnimationCurve`` (the frontend's
|
|
``parseCurve`` rules: ≥ 2 points, x non-decreasing from 0 to 1, one
|
|
cubic-bézier per segment with its x handles in 0 → 1), else ``None``."""
|
|
if not isinstance(curve, dict):
|
|
return None
|
|
points, easings = curve.get("points"), curve.get("easings")
|
|
if not isinstance(points, list) or not isinstance(easings, list):
|
|
return None
|
|
if not 2 <= len(points) <= MAX_POINTS or len(easings) != len(points) - 1:
|
|
return None
|
|
out_p, prev = [], -math.inf
|
|
for p in points:
|
|
if not isinstance(p, dict) or not _num(p.get("x")) or not _num(p.get("y")):
|
|
return None
|
|
x, y = float(p["x"]), float(p["y"])
|
|
if x < prev or not 0 <= x <= 1 or abs(y) > 10:
|
|
return None
|
|
prev = x
|
|
out_p.append({"x": x, "y": y})
|
|
if out_p[0]["x"] != 0 or out_p[-1]["x"] != 1:
|
|
return None
|
|
out_e = []
|
|
for e in easings:
|
|
if not isinstance(e, list) or len(e) != 4 or not all(_num(v) for v in e):
|
|
return None
|
|
if not (0 <= e[0] <= 1 and 0 <= e[2] <= 1) or abs(e[1]) > 10 or abs(e[3]) > 10:
|
|
return None
|
|
out_e.append([float(v) for v in e])
|
|
return {"points": out_p, "easings": out_e}
|
|
|
|
|
|
def curve_of(value: str | None) -> dict | None:
|
|
"""The un-send curve a settings blob holds (``None``: the default)."""
|
|
try:
|
|
blob = json.loads(value) if value else None
|
|
except ValueError:
|
|
return None
|
|
state = blob.get("state") if isinstance(blob, dict) else None
|
|
return clean_curve(state.get("unsendCurve")) if isinstance(state, dict) else None
|
|
|
|
|
|
def owner_curve(deps) -> dict | None:
|
|
"""The owner's un-send curve — what every guest's composer sweeps on."""
|
|
return curve_of(deps.ui_state.get(SETTINGS_KEY))
|