Skip to content

feat(skills): the agent edits a running app through Hot Reload instead of rebuilding it, with a SessionStart hook - #205

Merged
kazo0 merged 1 commit into
mainfrom
feat/hot-reload-over-rebuild
Oct 21, 2026
Merged

kazo0 merged 1 commit into
mainfrom
feat/hot-reload-over-rebuild

Conversation

@kazo0

@kazo0 kazo0 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): #

PR Type

  • Feature
  • Bugfix
  • Documentation content changes

What is the current behavior?

The uno-dev agent often runs dotnet build, uno_app_close or uno_app_start after a .xaml or .cs edit that Hot Reload has already applied. Each one costs a build, a relaunch and the app state under test.

Root cause, from the sweep in specs/hot-reload-over-rebuild.md:

  • uno-build-app, the skill the agent treats as its rulebook, says "build and exercise" (rule 4, step 6, the Trivial edit row, new-app.md, verification.md), and the agent files repeat it.
  • The don't-build rule lives in uno-testing, loaded only when testing, and in verification.md under "Practical traps", after the build table.
  • uno-testing step 1 builds first and only then says "skip the start if the app is running", so an app that is already up gets a build that is wasted or fails on the locked bin folder.
  • The PostToolUse hook stays silent when no .sln/.slnx is found above the file, and on a compile failure tells the agent to run dotnet build against the running app.
  • Smaller nudges: INTERACTION-PATTERNS.md ("consider restarting the app"), the MSB3026/3027 remedies ("close, then build again"), the report template's Build row, and "check the generated code" in uno-mvux.

What is the new behavior?

Skill text (every host)

  • uno-build-app has a new rule, A running app is edited, not rebuilt (the running-app rule): confirm each edit with uno_app_hot_reload_status(file, waitForMs: 10000), never dotnet build, uno_app_close or uno_app_start; a start is right only for launch arguments, platform or app data, a Release build, the .csproj or packages, startup code, or a reported RudeEdit, InternalError or uncovered edit. The same wording as uno-testing.
  • Rule 4, step 6, step 7, the Trivial edit row, the resume paragraph, new-app.md, checkpoint.md, the report template and uno-mvux point at it. In verification.md the rule moved from "Practical traps" to directly under the Build table.
  • uno-testing step 1 (and the ui.md Quick Start) calls uno_app_get_runtime_info first; a connected instance is the app under test, with no build and no start.
  • The MSB3026/3027 remedies say the error usually means the build was not needed. INTERACTION-PATTERNS.md checks the Hot Reload status instead of restarting.
  • agents/uno-dev.agent.md and codex/uno-dev.toml say "build once, start it and exercise it" and name the new rule.

SessionStart hook (Claude Code)

  • New hooks/session-start.sh on startup|resume|clear|compact. In an Uno app project (Uno.Sdk in global.json, or Sdk="Uno.Sdk…" on a .csproj within 3 levels, skipping bin/obj) it adds 371 characters of context: the running-app rule, and "call uno_app_get_runtime_info before the first build". compact brings the rule back after a compaction. Elsewhere it prints nothing, so non-Uno sessions pay no context. About 20 ms.

PostToolUse hook fixes

  • No solution file above the edited file: the reminder, instead of silence.
  • Compile failure with no diagnostics: uno_app_hot_reload_status instead of dotnet build.
  • The reminder's restart list matches the rule.
  • No Bash matcher for shell edits: detecting the write target is neither cheap nor reliable, and the SessionStart hook covers those sessions.

Tests

  • Test-Hooks.ps1: the SessionStart hook on an Uno global.json folder, an Uno.Sdk-on-project folder, a non-Uno folder (with an Uno .csproj under obj/) and a missing folder, plus the 400-character budget; the no-solution path; and that the compile-failure reason no longer says dotnet build.
  • Test-Plugin.ps1: the rule is cited by alias, never by number, so the rules can be reordered; the check fails if the alias is cited but not defined on a numbered rule.
  • Test-Hooks.ps1, Test-Plugin.ps1 and claude plugin validate --strict pass locally.

PR Checklist

  • Documentation has been added/updated
  • Associated with an issue (GitHub or internal)

Additional Information

specs/hot-reload-over-rebuild.md holds the analysis, the sweep results and the eval still to run: three successive edits on a running sample app with no build or restart between them, on Claude Code and on Codex (where only the skill text applies), plus a session that starts with the app already running. Open: whether Codex plugins support hooks, and which eval suite hosts these scenarios.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JBn6JXofK5yeaG6Ls1KE3S

…d of rebuilding it, with a SessionStart hook

The uno-dev agent ran dotnet build or restarted the app after a .xaml or .cs
edit that Hot Reload had already applied. The skill it treats as its rulebook
said "build and exercise", the don't-build guidance sat in uno-testing where
the agent saw it late, and the hook spoke only after an edit.

- uno-build-app gains the running-app rule: a running app is edited and
  confirmed with uno_app_hot_reload_status, never rebuilt; a start is right
  only for the listed cases. Rule 4, step 6, the Trivial edit row, new-app.md,
  verification.md (rule moved under the Build table), the report template,
  checkpoint and uno-mvux point at it. Every place that said "build and
  exercise", "then build again", "before any rebuild" or "restart the app"
  now says the first build before a start, or Hot Reload status.
- uno-testing step 1 calls uno_app_get_runtime_info first and builds and
  starts only when no instance is connected.
- New SessionStart hook (startup, resume, clear, compact): in an Uno app
  project it puts the rule in context before the agent plans, and brings it
  back after a compaction; elsewhere it prints nothing.
- hot-reload-edit.sh reminds instead of staying silent when no solution file
  is found, points at uno_app_hot_reload_status instead of dotnet build on a
  compile failure, and its restart list matches the rule.
- The rule is cited by alias, never by number; Test-Plugin.ps1 checks the
  alias is defined. Test-Hooks.ps1 covers the new hook and the two hook fixes.
- specs/hot-reload-over-rebuild.md records the analysis and the eval still
  to run.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JBn6JXofK5yeaG6Ls1KE3S
@kazo0
kazo0 force-pushed the feat/hot-reload-over-rebuild branch from b0200fc to c6cbecc Compare October 21, 2026 20:39
@kazo0
kazo0 merged commit 40499bf into main Oct 21, 2026
6 checks passed
@kazo0
kazo0 deleted the feat/hot-reload-over-rebuild branch October 21, 2026 20:42
@vatsashah45

Copy link
Copy Markdown
Contributor

Read the whole diff and the spec. The sweep is thorough and the pieces are consistent: one named rule, cited by alias everywhere, the agent files in parity, a SessionStart hook gated to Uno projects so other sessions pay nothing, and re-injection after a compaction, which is where a rule like this is lost in a long session. The two hook fixes (Failed in no longer says dotnet build; the restart list matches the rule) are right. Two things I would change before merge, and some context from the runs.

Before merge

  1. The no-solution case should stay silent, not remind. This PR turns [ -n "$sln_dir" ] || exit 0 into || remind. fix(hooks): the Hot Reload hook says nothing before the app exists #202 went the other way for the same reason the catalog runs showed: before the first uno_app_start every scaffolding edit produced a reminder (11–17 per session, 3.2k–8.4k persistent tokens), and the agents learned to skim the hook's notes. With fix(hooks): the Hot Reload hook says nothing before the app exists #202 in, the no-app case is silent and the hook text dropped to 0.8k–2.7k tokens with no change in behaviour. A file with no solution above it is almost always one of those pre-start edits, so this change brings the noise back for the case it was removed from. If the reminder is wanted for a running app outside a solution, gate it on a connected app (the CLI answer) rather than on the solution lookup.

  2. Rebase on fix(hooks): the Hot Reload hook says nothing before the app exists #202 and feat(hooks): a PreToolUse hook denies uno_app_restart while Hot Reload applied every edit since the last start #203, which touch the same three files. hooks/hot-reload-edit.sh, hooks/hooks.json and .github/scripts/Test-Hooks.ps1 all change in fix(hooks): the Hot Reload hook says nothing before the app exists #202 (hook silent before the first start, measured) and feat(hooks): a PreToolUse hook denies uno_app_restart while Hot Reload applied every edit since the last start #203 (PreToolUse guard that denies uno_app_restart after a clean apply, measured twice). The hook in feat(hooks): a PreToolUse hook denies uno_app_restart while Hot Reload applied every edit since the last start #203 also records the verdict per session, so the Failed in and reminder edits here land on different lines. The restart list in the new rule and the guard's startup-file list (App.xaml.cs, Program.cs, .csproj, .props, appsettings, manifests) should name the same files, so that what the text allows and what the hook allows agree.

Context from the catalog runs, for the eval that is still open

  • Three sessions on a text-only version of this rule in uno-testing (private#1220) changed nothing: the skill was loaded in one of three sessions, and that session restarted after an applied edit ten times. Your own A/B (private#1217) found the same. Putting the rule in uno-build-app and in a SessionStart hook is the right correction to that, since those are in front of the agent in every session, but the effect is still to be measured.
  • What did move the numbers was the hook that denies the restart (private#1222, #1223): the restart after an applied edit is decided from what the agent believes about Hot Reload ("clean state", "resources need a restart"), and every version of the text left that belief alone. Expect this PR to reduce the dotnet build cases (which the hook does not cover) more than the restarts.
  • The eval suite the spec asks about exists: tools/skill-ab in unoplatform/private, scenario catalog, with fifteen Uno sessions on main and the hook branches as baselines, and the per-session restart, hook-note and launch counts in each results README. Three sessions on this branch, or five for a decision, is a two to three hour run; I can run it on request.

Small things

  • session-start.sh reads cwd from the hook JSON and falls back to pwd; on Windows the cwd arrives with escaped backslashes, which the sed 's/\\\\/\\/g' handles, but a path with a " or a Unicode escape would not parse. Fine for now; worth a comment.
  • The SessionStart context says "Before the first build, call uno_app_get_runtime_info". In a fresh app session there is nothing running, so that is one wasted call per session; cheap, and right for the resume case.
  • verification.md still has a Build column of dotnet build -f … per target above the moved rule; agents read tables before prose. A one-line header on the table ("before the first start") would do.

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.

2 participants