davsclaus opened a new pull request, #28220:
URL: https://github.com/apache/camel/pull/28220

   Stacked on #28213, which gives each route a checksum and a revision 
(CAMEL-25771). The route console has both, so the Camel TUI shows them where 
they help:
   
   **Routes**: a route added again changed in this run, such as by a reload of 
its file, has its revision after its id, muted: `orders rev 3`. A route that 
never changed shows just its id. `tui_get_table` has the checksum and the 
revision of each route.
   
   
![Routes](https://raw.githubusercontent.com/apache/camel/69f50484c1696d4b27b4fa7552c513438515b7ec/docs/user-manual/modules/ROOT/images/jbang/camel-tui-routes-revision.png)
   
   **Diagram**: the Info panel of a route in the topology has its checksum, and 
its revision with the changes in this run (`Revision: 3 · 2 changes`).
   
   
![Diagram](https://raw.githubusercontent.com/apache/camel/69f50484c1696d4b27b4fa7552c513438515b7ec/docs/user-manual/modules/ROOT/images/jbang/camel-tui-diagram-route-revision.png)
   
   **Source**: the bottom border says whether the integration runs the file as 
it is saved:
   - `● running as saved`: the integration loaded the file after it was last 
saved;
   - `○ reloading...`: saved a moment ago, and the integration reloads on save 
(`--dev`);
   - `○ not running yet`: saved after the integration loaded it. It says why: 
the integration runs without `--dev` (restart it), or it did not reload the 
file;
   - `⚠ the reload failed`: the integration runs what it ran before the reload, 
until a reload succeeds.
   
   `tui_get_table` on the Source tab has it as `runState`, so an AI agent can 
tell whether its edit runs.
   
   
![Source](https://raw.githubusercontent.com/apache/camel/69f50484c1696d4b27b4fa7552c513438515b7ec/docs/user-manual/modules/ROOT/images/jbang/camel-tui-source-running-as-saved.png)
   
   **Why the Source tab compares times, not checksums.** The plan was to 
compute the checksums of the saved file's routes and compare them with the 
running ones. Two things rule it out for YAML and XML:
   - Loading a route file with the Camel DSL loaders runs parts of it: the YAML 
loader creates and binds the beans of the file as it loads it. The TUI opens 
any file the user browses, and a tool that reads route sources without running 
them must not run code from them (security model).
   - An endpoint written with `parameters:` is built by its component's 
`EndpointUriFactory`, which wraps secrets in `RAW()` and places path 
parameters. The TUI does not have most components, so its checksum would differ 
from the one the route runs with, and the TUI would say "not running yet" for a 
route that runs.
   
   So the Source tab compares when the file was saved with when the integration 
loaded the routes it has from the file:
   - An integration that has not reloaded loaded its routes when it started, as 
the process start time says. A route stopped and started again by hand keeps 
what it loaded.
   - After a reload, a route that started after the save runs what is saved. 
The route console gives only the uptime as text, so this is to the second; a 
route stopped and started by hand after a reload counts as loaded then.
   - A failed reload puts back the routes that ran before it, so until a reload 
succeeds the state is the reload error.
   
   For an exact answer, route by route, `camel cmd route-structure <file>` 
gives the checksum of each route of a file and `camel get route --checksum` 
that of each running route (#28213). If the runtime ever records a hash of the 
source it loaded each route from, the Source tab can compare that with the 
saved file instead.
   
   **Tests**
   - `RouteChecksumViewsTest`: the status file values, `orders rev 3` in the 
Routes table (and none for an unchanged route), the id cut to leave room for 
the revision, the Info panel lines, and `tui_get_table`.
   - `SourceRunStateTest`: each state; a route restarted by hand without a 
reload; dev mode reloading, reloaded and not reloaded; a failed reload; only 
the started routes of the file; the uptime text; the JSON for agents; and the 
Source tab drawing it on the border.
   - The camel-jbang-plugin-tui suite: 2214 tests pass. 
`LaunchManagerOutcomeTest` failed once and passed on the rerun. It swaps the 
global CLI home folder while the module's tests run in parallel, and is not 
touched here.
   - Checked live, with the Camel CLI of #28213:
     - An integration in dev mode: after an edit of the `orders` route, the 
Routes tab has `orders rev 2`, then `rev 3`, with the new checksum in the Info 
panel. The `audit` route in the same file keeps its checksum and revision 1.
     - The Source tab went from running to reloading and back to running 
through each reload.
     - A second integration without `--dev`: after a save in the editor, it 
says `not running yet: the integration runs without --dev, restart it`.
   
   Docs: the Routes, Diagram and Source help pages, and the Diagram and Source 
Editor pages of the manual, with the screenshots.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to