fix(webconfig): correct reply classification and the missing MyMesh commands

Two things hardware turned up.

The whole terminal came back red. The endpoint decided a command had succeeded
by testing its reply for an "OK" prefix — the convention the config batch relies
on, and a safe one there because every allowlisted setter uses it. The CLI
reaches the whole surface, where success has no single shape: setters answer
"OK...", getters answer "> value", `erase` answers "File system erase: OK". Only
failure is uniform ("Err", "ERR:", "Error:"), so that is what the CLI now tests
for.

Colour was the visible half. The other half was worse: _batch_all_ok went false
the moment a sequence contained a `get`, so a script ending in `reboot` was told
some commands had failed and the reboot was withheld.

Replies are green now and red means the node said no, which is what red should
have meant all along. The "> " a getter prefixes its value with is dropped for
display — on the serial console it sets the value apart, here it collides with
the prompt glyph that means "you typed this". The mock emits that marker too;
had it done so from the start, this would have shown up before the flash.

Second: discover.neighbors and discover.scopes did not autocomplete, because
MyMesh::handleCommand intercepts a few commands before delegating to CommonCLI
and the table was built by reading CommonCLI alone. setperm, `get acl` and
`shutdown` were missing for the same reason.

The audit could not have caught that: it drove every command the table offered
and checked the mock answered, which only finds gaps in one direction. It now
also reads the command literals the firmware dispatches on — across CommonCLI,
CommonCLI_Observer and MyMesh — and fails on any the table does not offer. That
check found `shutdown` immediately.

122 commands, all answered, none missing. 22 batch + 14 keys tests pass.
This commit is contained in:
agessaman committed 2026-08-08 08:14:54 -07:00
1 parent d7109c185c
commit d532e4ea86
4 files changed
+100 -13

No files matched your search

+18 -4
View File
@@ -150,7 +150,9 @@ body.tab-cli{padding-bottom:0}
.term-out>div{white-space:pre-wrap;word-break:break-word}
.term-out .cmd{color:#fff}
.term-out .cmd:before{content:"> ";color:var(--tgrn)}
.term-out .rep{color:#a9b7c6}
/* A reply is green because it succeeded; red is reserved for a node that said
no. Anything else reads every `get` as a failure. */
.term-out .rep{color:#7ee787}
.term-out .err{color:var(--terr)}
.term-out .sys{color:var(--tdim)}
.term-out .gap{height:.55em}
@@ -1444,6 +1446,11 @@ var CLI_VERBS=[
["memory","Heap and PSRAM free/min/largest block"],
["neighbors","Nodes heard recently, with RSSI and age"],
["neighbor.remove ","Drop one neighbour {64-hex-char-key}"],
// Handled by MyMesh before it delegates to CommonCLI — a whole second
// command surface the table missed until discover.* turned up absent.
["discover.neighbors","Ask neighbours to identify themselves"],
["discover.scopes","Collect neighbour scopes (needs the neighbors build)"],
["setperm ","Set a node's ACL permissions {64-hex-char-key} {int8}"],
["advert","Send an advert now (flooded)"],
["advert.zerohop","Send an advert neighbours will not repeat"],
["tempradio ","Try radio params without saving {freq,bw,sf,cr}"],
@@ -1480,6 +1487,7 @@ var CLI_VERBS=[
["reboot","Restart the node"],
["clkreboot","Restart the node, preserving the clock"],
["poweroff","Power the node off"],
["shutdown","Power the node off (same as poweroff)"],
["erase","Erase the filesystem — settings and identity"]
];
/* [key, description, mode, values]
@@ -1490,6 +1498,7 @@ var CLI_KEYS=[
["lat","Advert latitude",0],
["lon","Advert longitude",0],
["public.key","This node's public key",1],
["acl","Access control list (per-node permissions)",1],
["prv.key","Restore an identity {64-hex-char-key}",2],
["role","Node role",1],
["radio","Radio parameters {freq,bw,sf,cr}",0],
@@ -1975,9 +1984,14 @@ function cliPoll(reqid,cmds,from,status,errs,idles){
// The node never echoes the command back — it may hold a password or a
// token, and we already have the sequence we sent. Match by index.
cliEcho("cmd",cmds[from+i]||"");
// `ok` is advisory; the node's own OK/Error convention is authoritative
var ok=(x.ok!=null)?x.ok:!/^\s*(err|error)\b/i.test(x.reply||"");
if(x.reply)cliEcho(ok?"rep":"err",x.reply);
// `ok` is advisory; the node's own convention is authoritative, and only
// failure has a fixed shape there ("Err"/"ERR:"/"Error:").
var ok=(x.ok!=null)?x.ok:!/^\s*err/i.test(x.reply||"");
// Getters answer "> value" — that leading marker is the serial console's
// way of setting a value apart, and here it collides with the prompt glyph
// that means "you typed this". Drop it; the colour already says "reply".
var reply=(x.reply||"").replace(/^>\s?/,"");
if(reply)cliEcho(ok?"rep":"err",reply);
});
from+=(r.results||[]).length;
// "running" also covers "finished, but more results are still to be paged