Narrow a chat before it starts, and find a file rather than spell it

Six things, all found by using the thing rather than by reading it.

The scope menu only appeared once a chat existed, on the reasoning that there was
no row to post to. True, and the wrong conclusion: the harness puts a tool's
guidance in front of the model the moment the tool is offered, so the menu could
not be reached until after the model had been told how to keep notes and handed
the tools to do it -- and switching it off then does not un-send that turn. It is
on the new-chat screen now and writes nothing: `_scope_context` builds a stand-in
Chat, which is `draft.as_chat`'s trick again, and the switches ride along with
the first message. Checked means on and a browser submits only the ticked boxes,
so every gate also renders a hidden input naming it and `start_chat` subtracts one
list from the other; inverting the control would read backwards under a menu that
says everything is on unless you say otherwise. Only the off ones are written,
because absent means on and one representation of it is what keeps "why is this
off?" to a single answer. Nothing is validated against the offered set, since
scope_json narrows after every gate -- naming a gate that was never offered
switches off something that was not on.

Then the scheduling instructions, audited against a 4B model on this machine
rather than against my own reading of them. Ten realistic requests, ten
compiled, twice over -- so the prompt is sound. What was not sound was
`describe`, which built a phrase by joining fragments and read "Every the 1st at
09:00" for the commonest monthly schedule there is, and "Every of January" for a
month with no day. That string is the whole of what somebody sees before
approving a schedule and the whole of what the model is told about its own chat,
so a phrase nobody can parse is a review step nobody performs. It reads as
English now, collapses Monday-to-Friday to "every weekday" and seven days to
"every day", and every case in the test is a rule that model actually produced.

The one mistake it made was naming Wednesday for "every other tuesday", so the
weekday numbering is spelled out rather than left as "0-6, Monday is 0": getting
that wrong is the error here that still looks like a working schedule. Roughly
one call in six also came back empty -- a local runner swapping models under the
request will do that -- so an unusable reply is asked for once more before giving
up. Not on an LLMError: an endpoint that refused will refuse again, and the
reader is better served by the form than by waiting twice for the same answer.

Canvas asked for a typed path, which was the last control in the application
expecting somebody to remember an absolute path on another machine -- the same
complaint the folder page's directory field answered with a picker. /browse takes
pick=file and the same fragment makes files buttons, because a second copy of
that listing is a second place for the path arithmetic to be got subtly
differently. The button carries data-canvas-open rather than an hx-post since the
path is not known until the dialog closes, and ui.js posts it through htmx.ajax
so the response lands in the panel exactly as every other canvas action's does.
The key is `agent:<path>`, so a file opened by hand and one opened by the model
are one tab rather than two spellings of it. The tabs already existed and already
closed; they now square off at the bottom and the active one takes the body's
background, so which is selected is structural rather than a tint nobody can see
in a theme they did not choose. Highlighting was already there for every language
named and is checked for fifteen of them.

Three smaller ones. Tabs kept their scroll position, so switching from a long
panel to a short one left the browser clamping to that panel's bottom: the end of
it above a screen of nothing, which reads as a page that failed to load. Nothing
in CSS can reset a scroll position. The sidebar's footer and the composer sit
either side of one vertical edge and were both content-sized, so their top
borders met it at different heights and read as one line that had been broken --
`--footer-height` is a calc of the pieces the footer is built from, applied as a
min-height to both, which is exactly what `--header-height` already does at the
top of the shell. And "Add a workflow" sat flush against the list it adds to,
stated as an adjacency because `.btn-row` is right to carry no margin everywhere
else it appears.

Both pieces of JavaScript were driven under a DOM stub before committing, which
is how the tab listener's delegation and the canvas button's six behaviours were
checked at all -- `node --check` parses a file that does nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-05 22:37:47 +02:00
parent 7ff4c2c0aa
commit 4c78215e31
23 changed files with 910 additions and 72 deletions
+7 -3
View File
@@ -1651,9 +1651,13 @@ BUILTIN: tuple[Fragment, ...] = (
' "start": an ISO timestamp for the first (or only) run.\n'
' "every": one of {"minutes": n}, {"hours": n}, {"days": n}, '
'{"weeks": n} — a plain timer.\n'
' "at": {"weekdays": [0-6, Monday is 0], "days": [1-31], '
'"months": [1-12], "times": ["HH:MM"]} — a calendar. Leave a list out '
"to mean every one of them.\n"
' "at": {"weekdays": [...], "days": [1-31], "months": [1-12], '
'"times": ["HH:MM"]} — a calendar. Leave a list out to mean every one '
"of them.\n"
" Weekdays are numbered Monday=0, Tuesday=1, Wednesday=2, "
"Thursday=3, Friday=4, Saturday=5, Sunday=6. Count them off rather "
"than guessing: naming the wrong day is the one mistake here that "
"still looks like a working schedule.\n"
' "count": how many times in total, if they said a number.\n'
' "until": an ISO timestamp to stop after, if they gave one.\n'
"\n"
+30 -13
View File
@@ -135,20 +135,37 @@ async def compile_request(
"max_tokens": MAX_TOKENS,
"temperature": 0.2,
}
try:
raw = await complete(endpoint, body)
except LLMError as exc:
log.info("schedule compile failed: %s", exc)
return Compiled(
instruction=plain,
title=plain[:80],
reason="The model could not be reached, so fill this in yourself.",
)
# A model that thinks inline puts its reasoning in `content`, which is the
# field `complete` hands back verbatim -- the same trap auto-titling hit.
answered, _ = strip_reasoning(raw)
payload = _payload(answered)
# Asked twice before giving up, and only when the *reply* was unusable.
# Measured against a 4B model on this machine: the prompt itself is sound --
# ten realistic requests compiled ten times over, twice -- but roughly one
# call in six came back empty or truncated, which a local runner swapping
# models under the request will do. One retry costs a second on a screen
# somebody is already waiting at, and turns "fill this in yourself" from
# something seen regularly into something seen rarely.
#
# Deliberately not retried on an LLMError: an endpoint that refused the
# connection will refuse it again, and the reader is better served by the
# form than by waiting twice for the same answer.
payload: dict = {}
for attempt in range(2):
try:
raw = await complete(endpoint, body)
except LLMError as exc:
log.info("schedule compile failed: %s", exc)
return Compiled(
instruction=plain,
title=plain[:80],
reason="The model could not be reached, so fill this in yourself.",
)
# A model that thinks inline puts its reasoning in `content`, which is
# the field `complete` hands back verbatim -- the trap auto-titling hit.
answered, _ = strip_reasoning(raw)
payload = _payload(answered)
if payload:
break
log.info("schedule compile produced no JSON (attempt %s)", attempt + 1)
if not payload:
return Compiled(
instruction=plain,
+50 -11
View File
@@ -452,6 +452,55 @@ def _duration(delta: timedelta) -> str:
return f"{minutes} minute{'s' if minutes != 1 else ''}"
def _weekday_phrase(days: list[int]) -> str:
"""Weekdays as somebody would say them, or "" for no constraint.
Monday-to-Friday collapses because that is what a person means and what a
model writes when they say "every weekday" -- and five names in a row is the
commonest thing this function produces otherwise. All seven is no constraint
at all, and saying so is how "every day" comes out of a rule that named them.
"""
chosen = set(days or [])
if not chosen or chosen == set(WEEKDAYS):
return ""
if chosen == {0, 1, 2, 3, 4}:
return "weekday"
return _join([_DAY_NAMES[day] for day in sorted(chosen)])
def _calendar_phrase(at: dict) -> str:
"""How often a calendar rule comes round, in words that parse.
Worth the length. This is what the setup screen echoes back before anything
is saved, what the list page shows beside each schedule, and what the model
is told about its own chat -- so it is the reader's only view of a decision
taken while they were not looking. It used to build a phrase by joining
fragments, which read "Every the 1st at 09:00" for the single commonest
monthly schedule there is, and "Every of January" for a month with no day.
A row nobody can parse is one nobody checks.
"""
weekdays = _weekday_phrase(at.get("weekdays") or [])
days = at.get("days") or []
months = at.get("months") or []
month_names = _join([_MONTH_NAMES[month - 1] for month in months])
if days:
# A day of the month is the subject; the month, if any, qualifies it.
where = month_names or "each month"
lead = f"On the {_join([_ordinal(day) for day in days])} of {where}"
# Both set is an AND and is rare. Said plainly rather than smoothed into
# something that reads like an OR.
return f"{lead}, if it is a {weekdays}" if weekdays else lead
if weekdays == "weekday":
lead = "Every weekday"
elif weekdays:
lead = f"Every {weekdays}"
else:
lead = "Every day"
return f"{lead} in {month_names}" if month_names else lead
def describe(rule: dict, *, zone: tzinfo) -> str:
"""One line saying what this rule does, in the reader's own zone.
@@ -471,17 +520,7 @@ def describe(rule: dict, *, zone: tzinfo) -> str:
parts: list[str] = []
if at:
times = _join(list(at.get("times") or []))
when = []
if at.get("weekdays"):
when.append(_join([_DAY_NAMES[day] for day in at["weekdays"]]))
if at.get("days"):
when.append(f"the {_join([_ordinal(day) for day in at['days']])}")
if at.get("months"):
when.append(f"of {_join([_MONTH_NAMES[month - 1] for month in at['months']])}")
parts.append(
f"Every {' '.join(when)} at {times}" if when else f"Every day at {times}"
)
parts.append(f"{_calendar_phrase(at)} at {_join(list(at.get('times') or []))}")
# A stride over a calendar is a qualifier rather than a rewording:
# "Every Monday at 15:00, skipping to every 14 days" is clumsy but true,
# and inventing "every other Monday" for it would be a phrase that stops