- Restore Deep Clean, Storage, and Real-time monitor menu entries
- Group the full sidebar navigation under Maintenance and Insights
- Reorganize README around the current desktop, CLI, architecture, and release model
- Package macOS and Windows 0.1.4 installers and update manifest
- Hide up-to-date messaging in the update panel
- Simplify primary navigation to Overview, Cleanup, and Applications
- Keep Squid running in the tray with cleanup and purge actions
- Package macOS, Windows, and update manifest artifacts
Twenty-six commits went into main this week and not one of them touched
README.md, which sounds like restraint and is actually a bug: every commit made
the code more honest about Windows while the first file a stranger reads kept
saying the opposite. It opened with "macOS 磁盘清理与系统监控工具" as if the
platform layer shipped last month were a fork, and the crate map still described
squid-platform as "macOS 实现(App 清单、残留匹配、卷);Linux/Windows 占位" —
the same document that two sections later listed a working Windows registry
adapter, an IFileOperation recycle bin, thirty cleaning rules and a real machine
that had deleted files into it and restored them. A README that contradicts
itself is worse than a thin one, because the reader has to guess which half is
out of date, and the confident-looking half (the crate map, the feature table)
is exactly the half that is stale.
So this rewrites the stale claims and leaves the author's structure and tone
alone. squid-platform now says three implementations, and names what only
Windows has: the shell's recycle bin, console size and glyph-width probing,
process termination. The cleaning-rule count stops implying one number for every
platform — thirty-nine is macOS, thirty is windows.toml, and printing 39 above a
Windows install is a promise the rules directory does not keep. Uninstall says
where an app comes from on each platform, because "bundle id" means nothing to a
reader whose machine answers with a registry key, and the paths section now says
that on Windows config, rules and ledger all live under %APPDATA%\squid and that
the ledger records no physical path there — the Recycle Bin keeps the files, so
undo hands the restore to Explorer rather than renaming anything itself. Item 7
of the safety model got the same correction from the other direction, since it
used to promise "记录每条的废纸篓目标路径" unconditionally.
Two features the interface grew and the README never learned about. `x` joins
the key table: on the three file panels it is `d`, on the system panel it stops
the process under the cursor behind a dialog that repeats the sample rather than
the pid. That deserves a safety-model line as much as a key-table line, because
"the cleaner can also stop things" is the sentence a reader should meet next to
the list of processes it refuses to touch — squid itself, pid 0/1, Windows'
System Idle and pid 4, and csrss/smss/wininit/services/lsass/winlogon, an
elevated squid genuinely can open those for termination, which is the entire
reason for six names. svchost stays off the list on purpose, and the message now
says so rather than leaving the omission to be rediscovered as a bug report.
The Windows console paragraph records what the last two days of frame captures
taught: legacy conhost hands the process a window wider than the buffer behind
it, cp936 charges two cells for glyphs ratatui budgets one, and both lies arrive
as the same 花屏 — so the interface re-measures the size every beat and prices
each glyph before drawing it, and the command line deliberately buys the
pessimistic code-page answer instead of measuring, because measuring writes a
character onto whatever is on screen. SQUID_SYMBOL_CELLS and SQUID_CONSOLE_TRACE
join the environment table; they existed, they saved the port, they were
undocumented.
On the verification claim I did the opposite of what the week's momentum
suggested. The old line read "已在 Windows 10(1909)真机验证", and the machine at
192.168.2.92 was set up as a Windows 11 box, so the tempting edit was to write
"Windows 10 与 11 均已真机验证". Nothing in the repo supports that. Every
hardware check ever captured from that machine prints
`Windows 10 Pro (build 18363)`, and os_version reads ProductName,
DisplayVersion and CurrentBuildNumber straight out of the registry — there is no
code path by which a Windows 11 install produces 18363. Either the box is not
Windows 11 or its registry disagrees with whoever installed it; the README states
what the instrument reported and the roadmap carries "Windows 11 真机复验" as
pending, so the claim will be earned by a doctor run on a machine that says
22000 or newer, not asserted because it is plausible.
The remaining edits are smaller truths: release artifacts are Apple-only, so the
download section now says Windows builds from source rather than sending readers
after a nonexistent .tar.gz; the roadmap's Windows row picks up process
stopping, the highlight-that-survives-paging and the menu-that-stops-being-
overpainted fixes, and the "顶住 512 字节写入不变" settle condition that replaced
"seen twice" as the definition of a finished frame; "Linux/Windows 冒烟测试"
narrows to Linux, since Windows has a better instrument than a smoke test now —
capture on the real ConPTY, replay through pyte, measure the borders — and the
开发与测试 section shows how to run it, including --selftest, which is what keeps
the judge honest.
The Windows box came back with a ghost: the process card of the system panel
standing on top of the history panel, in a frame our own checker had certified as
a settled interface. No such layout exists in the code — the two panels are two
rectangles of one `Layout`, and one of them is cleared before the other is drawn —
so the honest reading was that `squid-tui` was painting something nobody had ever
seen on a screen. It took a round of measurement over the archived captures to
find out that the thing lying about the interface was not the interface. It was
the sentence in `tui-frame-check.py` that decides which frames are allowed to be
judged at all, and it had been lying quietly for every capture since the checker
was written.
The sentence was: a picture counts as settled once the same screen has been
sampled a second time. It reads well — crossterm patches a diff cell by cell, so
an unfinished paint keeps changing and cannot possibly be seen twice; the moment
it stops changing, the paint must be over. What it forgets is that the sampler
walks the stream every 64 bytes while one row of this interface costs about 190
bytes of it, so three samples land inside a single row; and that a paint which
has stopped is a paint whose next bytes belong to the next paint, not a verdict.
A frame cut in half is therefore guaranteed to be sampled two or three times in a
row — the same half picture, again, with nothing drawn in between. Being seen
twice was never evidence that the paint had finished. It was arithmetic, and it
cost a round spent chasing a rendering bug that cannot be written down.
Grouping the samples by how long each screen survives says it plainly. Switching
panels is one continuous write, offset 34688 to 37376, 2.7 KB without a pause;
inside that burst the screen passes through 33 states that carry both the process
card and the history card, and every one of them survives between 64 and 192
bytes of writes. The frames a human being stood in front of survive 1024 to 3840
bytes, because an idle interface repaints the same words every tick and nothing on
screen moves — which is exactly what "the user saw that" means. Lifetime is the
measurement, and it is the only one on offer: a captured stream carries no clock,
so "for a moment" has to be spelled out in bytes.
`analyze()` now cuts its samples into runs of consecutive identical screens, where
a run's length is how many bytes of stream passed while that screen sat there
unchanged, and only screens that survived `SETTLE`, 512 bytes, are judged. 512 is
not a magic number: it is comfortably above the 192 bytes that the longest-lived
half frame in that capture managed, and comfortably below the 1024 that the
shortest real one did, on the same stream, in the same second. The report says all
of it out loud — pictures painted, pictures that rested, pictures measured —
because the ratio between those numbers is the one piece of information that tells
the next reader whether the capture was worth anything at all. A stream where
nothing rests is now reported as unanswerable, with the three reasons a stream can
be unanswerable named next to it (a screen that animates forever, a capture cut
short, a screen with no borders at all) rather than being read as a clean pass.
Both new selftest cases were also run against the previous criterion, so that this
commit can be seen to bite rather than merely to look tidy. `半张画不许下判词`
paints a clean 140-column card, lets it rest, then begins a second paint mixing a
100-column card with a 70-column one and stops there, followed by 200 bytes of SGR
and cursor movement that change not one glyph. It is the same content as
`窄框和宽框叠着` above it — which is a fault, and still reported as one, because
that one rests — and under the old criterion the invisible padding is enough to
admit it and convict the capture of two frames stacked on each other. It lived 192
bytes, and under the new criterion it is not allowed to speak. `整条流没有一幅画
站得住` points the same machinery the other way: two clean pictures, neither of
them ever resting. The old criterion certified that stream as free of problems,
which is the more dangerous direction to be wrong in, since it files a measurement
that proved nothing as a pass; the new one refuses to answer. Under the old code
both cases are judged wrongly, under the new one all twelve are right.
On the archived real captures the filter is not cosmetic. The system-panel capture
went from 82 "settled" interfaces measured to 8, out of 327 screens painted; the
long kill capture from 291 to 36, out of 1198; the 140-column clean capture from
101 to 8, out of 376. All of them still come back with zero failures, which is the
point: not one verdict got worse, and every screen that no user ever saw is gone
from the docket. Sweeping every capture left in /tmp turned up one more fact worth
writing down — of the screens that the geometry rule has ever convicted, not one
survived more than 320 bytes. Every conviction this tool has ever handed down came
from a frame caught mid-sentence, which is why the overlap class of bug now has its
regression case in the selftest, where the picture is written twice on purpose and
therefore rests.
What the change gives up, named rather than glossed: a panel that animates for as
long as it is open — a scan progress line is the obvious one — never rests, so a
capture of it is now "cannot judge" instead of a verdict, and the handful of 10 KB
start-and-quit captures in /tmp moved to that verdict. That is a real narrowing.
The way through it is a marker inside the stream, since the interface knows when a
draw ended and the checker cannot infer it from bytes alone, and that belongs to a
round allowed to touch `squid-tui` and `win-tui-capture.sh`; this one only stops the
checker from inventing screens. No Rust changed: 190 tests, `cargo fmt --check`
clean.
The system panel has listed processes for a while, and a list of what is running
gets one question asked of it more than any other: this one is wedged, make it
stop. A panel that can name the hung app and then shrugs is scenery, so the
answer here is yes — spent through the machinery the interface already has for
irreversible things, a dialog that names what it is about to do and a log line
afterwards that says what it did.
The *how* is two lines and not very interesting: `kill(2)` with `SIGKILL`, or
`OpenProcess(PROCESS_TERMINATE)` followed by `TerminateProcess`. Both are the
same promise, which is why `squid_platform::process::force_stop` is called a
forced stop on every platform and the dialog says 强制结束 rather than anything
about saving. There is no TERM-then-KILL handshake in here, because there is no
polite promise to keep: the second line of the dialog is 它不会有机会保存任何内容.
`squid_stats::Sampler::stop` does not use `sysinfo`'s own `Process::kill`, and
the reason is the shape of its answer. It returns `false` for every way a stop
can fail, and two of those ways want opposite things from the reader. `ESRCH`
means the process left on its own and nothing is owed but a redraw; `EPERM`
means it is alive and the reader should go find an elevated terminal. Windows
serves the same pair up as `ERROR_INVALID_PARAMETER` and `ERROR_ACCESS_DENIED`.
A bool cannot carry that difference, so squid makes the call itself and keeps
the words the OS gave, quoted inside a sentence this program owns — the OS's
sentence arrives in the language of the OS, and translates no further than its
own frame.
The *whether* is where the damage is, so it is answered twice. First by rule, in
`squid-platform`: never this squid, never the first process of the machine, and
on Windows never one of the six names a boot rests on. Those rules exist because
the operating system does not enforce all of them. An unelevated squid on macOS
cannot reach `WindowServer` whatever it tries; an elevated squid on Windows
*can* open `csrss.exe` for termination, and the reward for one misplaced Enter
is a machine that reboots without asking. Six names is the whole cost of that
guard. `svchost` is deliberately absent from it, because it hosts services a
user may genuinely need to restart and the machine survives losing one — which
is the test a name has to pass before it belongs on that list.
Then by the operating system, whose answer is the only one with any authority
over this user, this token, this moment. Between the two sits the question the
platform module cannot answer, because it is a question about a sample rather
than about a pid: is the process holding this number still the process whose
name the user read? Pids are seat numbers, handed out again, and a process table
is drawn the moment the panel opens and read from seconds later. So
`squid_stats::Sampler::stop` reads the pid again through the new `sample_of`,
applies the rules to the process that is really there, and calls a name that no
longer matches *gone* — the thing that was pointed at really is gone, whichever
direction the pid moved. `shown_name` is why that comparison means anything:
macOS hands over a path and Windows a bare name, and the process table had been
trimming with `split('/')`, which does nothing at all to a Windows path. Nothing
was wrong on screen, because the name was already short there; it became
evidence, and evidence has to be spelled one way.
`x` is the same verb it has always been. On the three file panels it makes the
row under the cursor go away; the system panel has nothing to delete and does
have a process, so the same finger reaches the same meaning, and
`x_is_still_the_delete_key_on_a_list_of_files` pins the old meaning down so that
this one cannot push it aside. `d` still deletes everywhere. The rules are
applied in `ask_stop_process` *before* the dialog rather than after the answer:
a dialog that can only be answered "no" teaches the user that the dialog is
theatre, and the toast that names the rule says the same thing in less time.
Three crates now each hold a `sleeper()`, which is a duplication worth keeping
on purpose. The thing under test has to be a process — `sleep 60`, or
`ping -n 60 127.0.0.1` where `sleep` is not — and a kill feature tested against
a struct is a kill feature that has never killed anything. Twelve tests come
with this: five in the platform module, including the boot list and a vacant pid
reporting itself as gone; three in the sampler, one of which hands a pid to
`stop` under the wrong name and then checks that the innocent process is still
running; four in the interface, walking `x`, `y`, and a refusal from the key
press to the corpse being reaped. 190 tests green across the workspace, with
`cargo fmt --check` and `cargo clippy --workspace --all-targets` clean for the
host and for `x86_64-pc-windows-msvc` — the target where the boot list,
`TerminateProcess` and the parameter-is-incorrect mapping compile at all, which
is also where `the_processes_a_boot_rests_on_are_named_not_guessed` exists.
The Windows 10/11 box carries the part a mac can only compile. `squid.exe`
there builds with `Win32_System_Threading`, clippy clean under `-D warnings`,
185 tests green; and the dialog was read off the screen rather than off the
buffer — `TUI_COLS=140 TUI_ROWS=35 TUI_CP=936`, 2604 samples of the raw ConPTY
stream, 291 settled frames, 0 of them failing the layout judge, including the
confirm itself: `╭ 结束 iNodeCmn.exe? ╮` / `pid 9080 · 1.2% · 15.4 MB` /
`它不会有机会保存任何内容` / `回车 / y 确认 · n / esc 取消`, and 「已取消」 after `n`.
`docs/ARCHITECTURE.md` gains the module and the key, and one of its diagrams
finally admits that `squid-stats` has depended on `squid-platform` for weeks.
Uninstall came back from the Windows box saying the thing it had already said
on macOS: once there are more apps than a page, paging down leaves the list
with no highlight anywhere. Two consoles that have spent this branch being
taught what a `█` costs agree with each other about nothing, so a complaint
that survives both of them is not standing in the console. It was standing in
`draw_uninstall`, and it had been there since the panel was written.
The panel pushes its column header — `size name version source`, plus a filter
chip while a filter is standing — into the same `List` widget that holds the
apps, and paints the highlight by asking whether `row == cursor`, where `row`
counts the apps that `visible()` returned. `ListState::selected` is handed that
same `app.uninstall.cursor`: a number in the space of visible apps, in a widget
whose rows are that space plus one, plus two with the chip. ratatui spends
`selected` on exactly one thing in this configuration, because `highlight_style`
is empty on purpose — the row paints its own highlight so that a cursor survives
a terminal with no colour at all — so the disagreement cannot mispaint a row.
What it can do is decide which rows exist on screen: the scroll window is
positioned around the row one above the cursor. While the list fits in the card,
or while the cursor is high enough in a list that does not, the cursor is inside
the window either way and the header costs nothing. That is why this needed a
machine with more installed apps than a fixture has, and why the same binary
lied the same way on both platforms.
`ScanPanel::lines` has never shown the symptom, and the reason is worth naming
rather than admiring: it holds entries and nothing else, because the heading of
that card lives on the `Block`. One widget, one index space, nothing to drift.
The uninstall *plan* was taught the same lesson from the other direction — it
used to swap item zero for a bundle heading, which held only while the `.app`
was the largest thing in the plan, until a container outgrew it and every row
under the heading sat one line away from its cursor. The app list was the third
place a header had been allowed to spend a row, and the only one nobody had
asked about.
The fix declines to count anything. `chrome` and the entries are two constraints
of one vertical `Layout`: the `Paragraph` takes the first rectangle, the `List`
gets a rectangle holding entries only, and `selected` and `band()` are back to
describing the same rows. Nowhere in the file is `cursor + header_lines` written
down, because an offset is the thing that just went wrong, and the next line of
chrome added to this header would need one of its own.
`the_app_under_the_cursor_is_the_row_that_is_on_screen` is the regression test,
and it loops over every cursor position rather than picking a deep one, because
whether one deep cursor fails depends on how tall the card happens to be where
the test is running — which is a measurement of a machine, not an invariant. For
each position it draws 140x34 and asks the buffer two questions: is the app under
the cursor on the screen at all, and is the cell it landed on wearing the accent
background and the bold that a highlight paints. The series runs twice, once with
the filter chip on screen, because the chip is the second row of the two index
spaces that were drifting apart. Before the fix it stops at cursor 25 with "the
app under the cursor is off screen". Nothing on the screen had been drawn
wrongly, which is the shape of this bug: every row was correct, and the only
thing missing was the cursor.
68 tests in the interface crate, one of them this one, green; `cargo fmt
--check` and `cargo clippy --workspace --all-targets` clean for the host.
Three rounds were spent on a TUI that drew several frames over each other on
a cp936 console, and the fix worked: the interface asks the console what it
charges, per character, and draws ASCII where the console charges more than
the layout paid. Meanwhile `squid status`, printed in the same window on the
same machine, still produced a Storage table whose rows were each a screen
and a half long. Nothing in `main.rs` had ever asked what a `█` costs. It
repeats that character twenty-eight times for a gauge and lets the console
do the arithmetic, and the console's arithmetic is different.
`priced` is where a line stops being text and starts being cells, and `row!`
is the one door the body of every report prints through: the eleven places
that draw this program's chrome — the status key/value rows, the volume
gauges, the process table, the tree, the history rows, the whitelist
bullets, the rule headings and their `●`, the doctor's table — all of them
now go through it. It is a macro rather than a helper so the format
arguments stay where they were written, and one door rather than twelve
`println!`s of which eleven remember the console, because the twelfth is the
bug this whole thing is about.
Two refusals are the interesting part.
Nobody is stopped from seeing what a report actually says. Point the output
at a file or a pipe and the text comes back exactly as it was, because a
file is not a console: whatever glass reads the archive tomorrow may well
afford the `█`, and an archive of `#` is a worse record for the sake of a
screen that was never looking. The gate is the same tty question the live
progress line already asked — may this line overwrite a line — so
`live_stream_is_tty` is now `human_stream_is_tty`, since the two questions
have the same answer and deserve one function that says what it is asked.
And `--json` prints data, never through this: rewriting a person's report to
flatter their terminal is a different bug with the same fingerprint.
The price is not measured, even though measuring is what the interface does,
for the reason in `console::prices_unasked`: measurement spends characters,
and a command line is a guest on the screen it is printed to, sitting in a
pipeline or in front of a shell waiting for its next prompt. So it takes the
pessimistic answer the code page implies, which costs it a plainer gauge on
a console whose code page overcharges characters its font could have
carried. `█` becomes `#` there. A table that fits is worth more than a
prettier one that does not.
`no_line_of_chrome_escapes_the_counter` reads the file, with strings,
character literals and comments blanked, and demands that every `print!`,
`println!` and `eprintln!` either go through `priced` or print JSON or print
nothing. The scan exists because this mistake cannot be seen from the
machine it was made on: `println!(" {}", plan)` standing among eleven `row!`
calls is correct on every terminal that charges one cell for everything,
including the one it was typed on, and arrives folded over in front of
somebody else. It reads character literals as literals only when they close
again promptly, because `'static` is not the start of a character literal
and blanking from a lifetime to the next quote hides half a file from an
audit whose entire job is to look at all of it.
On the box, same pseudo-console, same 100x30 window, three reports per
capture and every one of them complete to `MARK_QUIT 0`. On cp936 — the code
page the user's own window is on — the decoded stream contains no `█`, no
`░`, no `─`, no `·`, no `…`, no arrow: the gauge reads
`[#######################.....]` and the headings are underlined with `-`.
On 65001 the same report keeps 104 `█`, 120 `░`, 236 `─`, 32 `·` and both
arrows. Same bytes of intent, two currencies, and the receipt is now in
both.
`win-tui-capture.sh` takes `TUI_ARGS=` so this evidence is repeatable rather
than hand-built: the default still captures the interface and judges it
frame by frame, and `TUI_ARGS="status"` captures a report, where the judge
is simply how many `█` survived.
The architecture document tells the story as one paragraph now, because it
is one story: `console::prices` measures and hands the answers to the
interface, `console::prices_unasked` guesses from the code page and hands
them to the command line, and each side has a test that keeps the characters
it draws and the characters it priced the same list.
178 tests here, two of them this commit's, clean under clippy for the host
and for `x86_64-pc-windows-msvc`, `cargo doc -D warnings` quiet over the
platform and the command line.
The exchange that stops the TUI overflowing lived in `squid-tui`, next to
the renderer, because that is where the bug was found: several copies of one
frame left on a cp936 console, because `─│█░·…↑↓✓` cost two cells there and
one cell in the layout. But the thing that was wrong was never specific to a
renderer. It is a fact about a console — what this glass charges for a
character whose price Unicode left unsettled — and a fact about a console is
worth exactly as much to the next program that draws on it. `squid status`
draws a volume gauge by repeating `█` twenty-eight times and rules a heading
with `─`. Same price. The difference is that the command line had nobody
asking it.
So `currency` now lives in `squid-platform`, beside `console`, and says in
its own documentation why it is there rather than beside the interface: the
command line and the interface buy the same screen at the same counter.
`Exchange` is the table — indexed by code point, holding the replacement
rather than a bit saying *this one is wrong* because the character is what
the caller needs, and built only when this console actually overcharges,
which is what makes `afford` free on the terminals where there is nothing to
repair. `disputed` says which characters are worth asking about, `cheaper`
what each is worth in characters the console accepts, `witnesses` turns
pieces of chrome into the list of questions to ask. `squid_tui::glyphs`
keeps the half that cannot travel: the walk over a finished ratatui
`Buffer`, which is a question about somebody else's library, now a `Carry`
trait implemented for `Exchange` so that the table and its spending still
read as one motion.
The tests went with their subject rather than staying where the code used to
be: what a shading block costs, and what it is worth in `.`, is a question
about prices, so those seven are in `currency` now, and what is left here is
about frames — three that draw a `Buffer` and check where the borders land,
one that reproduces the original overflow, and the two that hold the
invariant worth defending, that the glyphs this interface draws and the
glyphs it asks the price of are one list. A glyph drawn but never priced
looks correct on every terminal that charges one cell for everything,
including the one it was typed on.
176 tests here — the same number as before the move, which is what a move
ought to leave behind — clean under clippy for the host and for
`x86_64-pc-windows-msvc`, and `cargo doc -D warnings` quiet over both crates.
On the box, with only this commit applied: `RESULT: OK`, and the interface
regression at 140x35 on the code page the complaint came from — 890 samples,
90 settled frames, every one measured and none rejected, box-drawing intact.
One drive-by: `Prices::implied` documented itself by linking to a private
function, which `cargo doc -D warnings` refuses, so the link names the
function instead of promising a URL to something nobody outside the module
can reach.
Three ways this pipeline produced a verdict that was not about the TUI.
The frame judge required every right border on a screen to land in the same
column. That was written when the widest window anyone captured was 100 columns
and the interface drew one card. At 140 columns the menu column and the panel
are two frames side by side — the menu ends at column 31, the panel at 140 — and
the rows where the panel has already finished genuinely do end at 31. A tidy
140-column screen was therefore garbled on every single capture, which is a
mistake the judge makes rather than the console, and mistakes the judge makes
should not have to be re-litigated on real hardware. The rule is now the one that
survives both layouts: the border columns of the widest rows are the picture, and
a row with a border column that appears nowhere in that picture means two
pictures of different sizes are stacked on one screen. `side_by_side` and the
narrow-card-under-wide-card case are both in `--selftest`, so whoever tightens
that rule again finds out there, in a millisecond, rather than on the box.
`win-tui-run.ps1` always ran `chcp 65001`, because UTF-8 comes back through the
capture with no decoding guess involved. It also means the probe always measured
a UTF-8 console, while the window being complained about sits on cp936 — and
which code page a console is on is exactly what decides what an unasked-for
character costs. `$SQUID_TUI_CP` picks the code page now, the runner reports it
as `MARK_CODEPAGE`, and the judge prints it on the first line of every report,
because a frame is only evidence for the console it was taken from. Both routes
are green on the box with the price list as it now stands: 140x35 on 65001, 101
settled frames, none of them overflowing, box-drawing intact; 100x32 on 936, 54
frames, same. The comments that claimed the ConPTY measures one cell because
UTF-8 is forgiving have been corrected too — it measures one cell on 936 as
well, which is a fact about a console with no font, not about a code page.
And when the runner itself fails to parse, the stream still contains a console:
a PowerShell error block, and then nothing. The judge said "no settled frame with
a border was ever drawn", which is true and useless, and it read like a rendering
regression badly enough that drawing code got changed because of it. A
`CategoryInfo` in the stream is now reported as what it is — the capture script
never started the interface — and it is a selftest case, so the excuse is on
record as belonging to the harness.
`symbol_cells` asked the console one question — what does a box-drawing bar
cost — and spent the answer on sixty characters. That was already the wrong
shape of answer: what decides a price is the code page and the font the console
was left on, and nothing promises the box-drawing set and the block-shading set
land on the same side of it. But the measurement was worse than the shape, and
this is the part worth writing down.
To price a character the probe asked the console to move the cursor to an
anchor, wrote the character, read the cursor back, and computed `after.X -
at.X`: the distance from the anchor it had *requested*. On the console this was
chased on, `SetConsoleCursorPosition` returns success without moving anything.
Every read therefore returned the same cursor, and the "cost" of the nth
character was n. The temporary trace said it plainly: 1, 2, 3, and on up to 60.
`match cost { 0 => None, 1 => Single, _ => Double }` then read every character
from the third onwards as two cells wide, which is how a UTF-8 console that
charges one cell for the lot ended up with its rounded card downgraded to
ASCII, and how the earlier "this console prices bars one cell and blocks two"
found its evidence. That split was never measured. It was a counter.
The distance between two reads is the only number here that means what it looks
like, so that is what is read now: ask where the cursor is, write, ask again,
and the step is the price. A step that cannot be a price is no answer at all —
`price_from_step` accepts one cell and two cells and refuses zero, negatives,
three, and sixty, so a cursor that never moved produces a code page's guess
rather than a layout believing a number with no cells behind it. A read that
changed rows is no answer either, and neither is a row with fewer than two
columns left to answer in, and `SetConsoleCursorPosition` is still called but
its return value is deliberately ignored: a ruler that is obeyed asks all sixty
questions of the same cell, and a ruler that is ignored walks one row, which the
characters get wiped out of either way.
Because a ruler can lie in ways that still produce plausible numbers, `prices`
asks for `A` first. `A` costs one cell in every table that measures characters,
so an answer of anything else means the probe is not reading cells, and it says
"symbols unreadable: A does not cost one cell" and takes the code page's answer
instead of laying a screen out against the lie.
The answers are kept as a price list, not a verdict, and `squid-tui` asks it
only about the characters it means to draw (`witnesses`), so a console that
overcharges the shading but not the rules keeps its rounded card and gives up
only the gauges inside it. The module documentation no longer claims a split
price was measured on cp936: what the ConPTY measured there, as on 65001, is one
cell for all sixty. What remains from the real window is the symptom — a card
that fit and a gauge inside it that did not — which is the reason for the list,
not evidence about that box.
Tests: the fair-priced-and-dishonestly-priced console still downgrades only the
disputed set, and `a_step_that_cannot_be_a_price_is_not_an_answer` keeps sixty
from ever being a price again.
The roadmap row claimed the TUI renders correctly "under the real console". It
was verified under the ConPTY that sshd allocates, which is a real console but
not the one being complained about: that one charges two cells per box-drawing
bar and the capture pipeline could not see it. The claim now names the
instrument instead of the impression, because there is one — a frame is judged
by which column its right borders land in, and the judge tests itself.
`docs/ARCHITECTURE.md` still introduced `squid-platform` as a placeholder for
Windows and counted 86 tests, both of which stopped being true a while ago.
`squid-platform::console` now refuses to trust a console's answer about its own
size or about the price of a glyph. It is entitled to that refusal only because
somebody measured both, on the machine, with scripts that could not cheat.
`win-tui-resize.py` grows the console *underneath* a running interface and reads
the screen back, then asks how many columns the right-hand borders sit in: one
column means a screen, two means two frames drawn on top of each other. That is
the resize bug made countable, and its header keeps the five facts about Windows
OpenSSH that shaped it — including that the resize has to be driven on `CONOUT$`,
because after the alternate screen went up, the process asking for the resize is
still describing the buffer nobody is looking at.
`win-tui-widths.ps1` is the same trick applied to a single character: park the
cursor on a known column, write one glyph, read the cursor back, and the cells it
travelled are that glyph's width *in this console*. It measures both write paths
separately — `WriteConsoleW` into the buffer, and encoded bytes through stdout —
because they genuinely disagree, and it reads the cell's contents back too, so a
character the code page quietly replaced cannot hide inside a width that happens
to look right. This is the measurement `symbol_cells` now performs in-process;
the script is what proved the answer was worth asking for, and it still answers
for a console the program cannot see.
`win-tui-clean.ps1` keeps the harness honest: a remote PowerShell left behind by
a dropped ssh session keeps the release binary's file handle open, so the next
build cannot overwrite it, and it later writes its `MARK_QUIT` into whichever
report file exists — a previous round testifying on behalf of this one. It kills
the tested binary and its own grower by command line, and nothing else.
`tui-frame-check.py` is the part of `win-tui-capture.sh` that decides whether a
run passed, taken out of the shell script so that fixing the judgement does not
require the real machine to run again — `TUI_REUSE=1` re-reads a saved byte
stream, which is how both bugs in this branch were confirmed fixed against
captures taken before the fix existed. `--selftest` feeds it six screens it made
up — two good ones and four broken ones, including a screen where every Chinese
character makes `len()` measure the frame too narrow — and fails if the judge
goes quiet on a bug or shouts at a good screen.
The four rules it encodes were each paid for with a false verdict:
* the right border is only trusted on rows whose *first* character is a border
character, because the box-drawing bar also appears in prose and in ASCII mode
as `|`, and reading the last one on a row found the wrong column;
* columns are counted by accumulated display width, not by `len()`, because a
terminal emulator keeps one character for a glyph that occupies two cells;
* only a screen that was painted at least eight rows and seen twice is judged,
so a half-drawn frame cannot be mistaken for a torn one;
* a row that ends in a border but starts with prose is a row sitting *on* a
border — the shape the toast produced — which is how the judge caught a bug
nobody had thought to look for.
`win-tui-run.ps1` was missing from the repository while `win-tui-capture.sh`
depended on it, so the proof the last commit described was not in fact
repeatable. It exists here, and it is the reason the captures are trustworthy:
`mode con cols=100 lines=30` fails silently on the ConPTY that Windows OpenSSH
allocates, so every earlier "capture at 100 columns" was a 120-column frame
reflowed by the emulator. It sets the size through `[Console]::WindowWidth` and
reports the size it ended up with, and the emulator replays that rather than the
one we asked for.
Found while reading a captured Windows screen against the machine that produced
it: the Power card printed `LENOVO 20SDA09HCD · macOS 15.1` on a Windows 10 box,
because the operating system was hardcoded in the `format!` while the platform
layer had been answering correctly all along. `host.os_version` is already
`Windows 10 Pro (build 18363)` there and `macOS 15.1 (24B83)` here, so the card
was naming a system twice and getting one of them wrong.
Truncation had it backwards too. The row squeezed whichever half it liked, and
the half that fell off the end on a narrow console was the build number — the one
number that decides whether Windows Terminal exists, whether the buffer can be
resized, whether the glyphs cost one cell or two. The machine model is now the
half asked to give room, and when fewer than six characters of it survive it
leaves the row entirely.
The other half of the 花屏 report, and it had nothing to do with Windows: the
same coordinates are drawn on every platform, and on a console a repaint is what
the user reads as the screen.
The toast was pinned to `height - 3` of the *frame*, which is the panel card's
bottom border. `Clear` then removed as many cells as the text needed and left the
untouched tail of the border standing behind it, so the row read
`功能菜单 — 上下键选择,回车返回 ------╯`: half a sentence, half a frame, the
border turning into prose halfway across the screen. It appeared the moment the
menu opened and tore again on every key that answers with a toast, which is what
choosing a function does — hence "pressing 1 shows it twice".
The chip now floats on the card's last inner row, one cell inside each border, so
it may still cover a row of the list (that is what a toast is for) but cannot
reach an edge. It also draws *under* the popups: a four-second message must never
be the reason a dialog loses a border. The test draws the frame with and without
a toast and compares every row that starts a bottom border, which is the
invariant the bug broke — a border has to survive a toast unchanged — plus that
the toast is still readable, and still inside the card that carries it.
Both numbers an interface is laid out against used to be taken on trust: the
size the terminal reported, and the one column per glyph that a layout measured
in columns pays for. On the Windows console in front of us, both were wrong,
and both failures arrive at the same place — cells written past the end of a row
reappear at the start of the next one, so the screen becomes several copies of
itself at several offsets and looks like a renderer that cannot count.
`squid-platform::console` measures instead of trusting. It asks three questions
because a console has three ways to be too optimistic — the window, the buffer
behind it, and the largest window it could show at all — and it asks them of the
buffer being *shown*, because entering the alternate screen on a legacy console
activates a second buffer while the process keeps holding the handle it started
with, which then describes a screen nobody is looking at. A window wider than
the cells that exist is where the wrapping starts, so `repair` asks the console
for the cells it does have; a window that slid down its own scrollback moves the
picture without moving the size, which is why the renderer watches the offset too
and wipes rather than diffs when the screen moved under it.
The second measurement is what makes a whole screen break at once. East Asian
Ambiguous characters have no agreed price, and a console left on a Far-Eastern
code page charges two cells for exactly the class of characters an interface is
built out of: the rules, the shading, the arrows, the ticks, the middot. ratatui
charges one, so every row of the layout is longer than the glass by the symbols
it contains. `symbol_cells` writes one box-drawing bar and reads how far the
cursor moved, because the two things that decide the price — code page and
font — are both set outside this program, and `chcp 65001` moves the same bar
back to one cell on the box that charges two.
`squid-tui::glyphs` then rewrites the finished frame one column for one column:
the rules become `|-+`, the gauges `#`, the arrows `<^>v`, so the rows fit
without the layout moving at all. Chinese text and ordinary letters are left
alone — neither is ambiguous, so neither caused the overflow, and a person's
paths and process names are not what an alignment bug should be allowed to
rewrite. `SQUID_SYMBOL_CELLS` overrides the measurement for the case the
measurement cannot reach: over ssh this program measures the console sshd made
for it, not the one on the glass. `SQUID_CONSOLE_TRACE` writes the two buffer
answers side by side, since a hand-made resize leaves no other evidence.
`cargo fmt --all --check` had opinions about three call sites that were already
wide enough to need breaking, and the incoming Windows work touches all three
files. Split off so the commits after this one contain only the changes they
are about.
`win-tui-capture.sh` drives the real binary over `ssh -tt`, which is the only
way to render the TUI the way a Windows console does: sshd allocates a
pseudoconsole, crossterm takes its Windows backend, and the bytes it emits are
decoded back into a frame locally. The existing smoke script cannot do this
because it forks its own pty, which is POSIX-only.
It now takes a key sequence, so the interesting case — a populated list, not an
empty panel — is the one that gets checked, and it keeps the fullest frame
rather than the last one, because quitting wipes the screen. It reports where a
replacement character appeared, since mid-stream means the console could not
draw the glyph and at the tail only means ssh truncated a frame on disconnect.
`win-hwcheck.ps1` measures the volume before and after a real deletion, counts
entries in the shell's Recycle Bin, and asserts the two agree; that is what
caught the missing undo flag. Its fixtures clean themselves up.
Windows moves from "cross-compile only" to verified on real hardware in the
roadmap. UAC elevation, the long-path manifest, and publishing stay pending.
Found by pointing the hardware checks at the binary they were meant to test.
`purge --json --yes` printed a human plan on stdout before its JSON, so the
first thing a machine reading that output saw was `Invalid JSON primitive`.
The design already had the right rule — `diag`/`shout`/`heading` go to stderr
under `--json` — but anything that printed an already-formatted line bypassed
it. `say` is now that one writer, and the `\r` progress spinner writes to
stderr whenever `--json` owns stdout, so a progress bar can no longer land
inside a document.
Being quiet on stdout is only useful if the document is still complete, and it
was not: the early return was conditioned on `!yes`, so `--json --dry-run`
printed no JSON at all, and the nothing-to-do paths returned before the
summary existed. Both now emit one document; `undo` keeps its own shape because
it always reaches the remove plan and would otherwise print twice.
`undo` also lied. It reported "1 could not be put back (path in use)" for every
entry, because the ledger's recycle-bin destination is always empty on Windows:
`IFileOperation` moves the file and the shell takes over the bookkeeping, so
squid never has a destination to move back from. The run had succeeded. It now
checks the session's mode and says the true thing — those files are in the
Recycle Bin, restore them there.
Finally, the copy that named the wrong operating system: `--trash` help, the
confirmation prompt, `history` and `doctor` all said Trash on a box whose shell
says Recycle Bin. The history column widens for the longer name instead of
eliding it.
Measured by driving the real binary through a pseudoconsole that sshd hands out
(`scripts/win-tui-capture.sh`), then decoding the bytes it emitted.
The lock glyph was U+1F512. Every astral-plane character comes back out of a
conhost/ConPTY session as U+FFFD followed by the glyph, i.e. one cell too many,
which shifted every locked row in the list by one column. `⊘` is in the BMP,
one cell wide, and survives the same session; the other glyphs in use were
checked the same way.
A row wider than its card used to spill: `joined` collapsed the filler to
nothing and the terminal cut off whatever came last, which is the right half —
the delete mode the user is about to act on. Now the left half yields, giving
up whole spans before cutting one in half. This is what the longer Windows name
for the recycle bin exposed at 100 columns, where "empties only with the
Recycle Bin" had swallowed "delete to · Recycle Bin" whole.
The status row's trailing note is the one part of that line the user is not
acting on, so it is dropped rather than allowed to push the mode off the card.
Both languages were re-checked on the box afterwards: no replacement characters
left, and the note still shows wherever it fits.
`the_recycle_bin_is_called_what_the_os_calls_it` pins the new copy rule; the
group-name test now expects the operating system's word for that one group,
which is why it fails on Windows and passes on macOS until the rule is stated.
Three things the interface used to assume from its own build rather than from
the machine it was on.
`device()` says whether to address the user's machine as a Mac, a PC, or a
machine. The status line asked the locale, so the Chinese interface on a
Windows box told people to press `s` to scan 这台 Mac.
`bin_noun()` says what the operating system calls the place deleted files wait
in. Windows calls it the Recycle Bin and has no Trash folder to open, so copy
promising "empty the Trash" there sends the user to a control that does not
exist — in the header, in the mode chip, in the group list, in `history`, in
`doctor`, and in the `--trash` help.
`trash_target()` for Linux now resolves the XDG Trash instead of falling back
to "no trash here", which made `doctor` claim deletions were permanent on any
desktop that does have one.
`windows_allocation` built its UTF-16 argument with `to_string_lossy`, so a
path that an `OsString` can hold but a `String` cannot arrived at
`GetCompressedFileSizeW` with replacement characters in it, and any path past
the 260-character legacy limit was answered with `ERROR_PATH_NOT_FOUND` — the
deep `node_modules` trees this tool exists to measure cross that line
routinely. `wide_path` keeps every UTF-16 unit and adds the verbatim prefix
only where it is honest (absolute, no `.` or `..`), because the prefix also
switches off normalisation.
The scratch-directory fixture now removes itself even when an assertion
panics halfway through. That is not housekeeping: a file extended with
`set_len` is charged as if written in full, and one surviving fixture sat on
the test machine's disk at 11 GB — in `AppData\Local\Temp`, where squid then
correctly offered it back as junk.
`FileStandardInfo.AllocationSize` turned out to be the wrong question. Measured
against `fsutil` and `compact` on a real Windows 10 volume:
- it returns the cluster-rounded logical length for ordinary files, including
1 GiB files extended by `SetEndOfFile` (NTFS does hand over the whole tail,
and free space moves accordingly) and sub-cluster files living in `$MFT`;
- it reported the full 8 MiB for a file `compact` accounts as 1,572,864 stored
bytes, i.e. it is blind to NTFS compression, which is the one way Windows
really does hide size on disk;
- `FSCTL_QUERY_ALLOCATED_RANGES` reported that same compressed file as fully
allocated, so "which clusters exist" is not "what do they weigh".
`GetCompressedFileSizeW` answers 1,572,864, matching `compact` byte for byte.
It takes the path we already hold instead of a handle, so it is one query per
file rather than a `CreateFileW` pair, and it keeps answering while another
process holds the file open exclusively — the normal state of a cache file.
That also removes the `ALLOCATION_PROBE_MIN` cutoff: it existed to avoid a
handle per small file, and small files on a compressed volume need the honest
number just as much.
Guard the zero answer behind `FILE_ATTRIBUTE_COMPRESSED`/`SPARSE_FILE` (free
from the `Metadata` we already have) so a deleted-but-still-open file cannot
zero out a total the user is about to act on, and read `GetLastError` to tell
failure from a genuine 4 GiB-minus-one length.
Tests: each platform now gets the fixture that provokes its own divergence —
POSIX holes for `st_blocks`, and a `compact`-compressed file for the Windows
path. The old Windows sparse fixture proved nothing: extending a file does not
hole out on NTFS, and `FSCTL_SET_SPARSE` is refused outright on this volume
(`ERROR_INVALID_FUNCTION`), as is `FSCTL_SET_COMPRESSION`
(`ERROR_ACCESS_DENIED`) even for a file we created ourselves.
The purge test compared rendered path strings against `demo/node_modules` and
friends, so on Windows every positive assertion failed and the negative one —
`loose/dist` must not be offered — passed for the wrong reason. Assertions now
compare trailing components, which is what they meant all along and holds on
both separators.
`category_index` made the same assumption in production: it lowercased the path
and looked for `/library/caches`, so a leftover root was only ever reclassified
on the OS whose separator it was written for.
Real Windows 10 hardware turned up two failures the macOS and cross-compile
checks could not see:
- squid-core::fs reported every file's logical length as its allocated size,
because `allocated_bytes` returned 0 on non-Unix and `on_disk()` then fell
back to logical. NTFS only answers the allocation question through a handle,
so ask `GetFileInformationByHandleEx(FileStandardInfo)` for files big enough
to distort a total. Files below the cutoff keep counting as their length,
which is also what keeps MFT-resident entries — they report an allocation of
0 — from shrinking a cache cleanup down to nothing.
- the "a plain user can still uninstall into /Applications" safety test hard
coded a Unix path, so on Windows it asserted that a folder the policy never
looked at was refused. The fixture now comes from the policy's own shared
install folder, `/Applications` on Unix and the machine-wide program-data
folders on Windows.
Also added:
- `a_written_file_reports_what_the_volume_gave_it`, the cross-platform
invariant the missing backend silently violated.
- the sparse-file test now marks its file sparse via `fsutil` on Windows and
skips when the volume will not cooperate, instead of pretending a hole
exists.
- `scripts/win-sync.sh`, `scripts/win-check.ps1` and `scripts/win-hwcheck.ps1`
for iterating against a LAN Windows host over SSH without git credentials.
- new squid_core::elevation_hint(): sudo on Unix, elevated Administrator
terminal on Windows; used by the locked-item notes in clean/uninstall
and the user-only safety refusal.
- the Permission error no longer tells Windows users to grant Full Disk
Access (a macOS-only concept).
- paths: platform-semantic comparisons. Component keys are lower-cased
and canonical \\?\\ verbatim prefixes folded away on Windows, so
is_within/same_path/depth_below/relative_below match how the OS
actually resolves paths; pretty() got the same treatment.
- safety: drive roots and UNC roots are hard-denied (is_root_like);
Windows hard-deny grows env-derived entries (SystemRoot, ProgramFiles,
ProgramData, USERPROFILE, ...); DENY_EXACT gains the AppData tree and
shell folders; OUTSIDE_HOME_OK becomes platform-supplied
(%ProgramData%, %PUBLIC% mirror /Applications); a path containing
$Recycle.Bin / System Volume Information / Recovery is always refused;
the canonicalize-vs-expected symlink probe now compares with
platform semantics instead of raw equality.
- rules: $VAR heads stop at backslashes too; ${VAR} resolves in every
occurrence; glob component matching is case-insensitive on Windows;
protect patterns normalise \\ to / so protections keep working there;
anchor_for keeps drive prefixes instead of bailing out, and folds
Prefix+RootDir into a rooted C:\ anchor.
- rules/windows.toml: 30 rules for Win10/11 (temp, WER/crash dumps,
browser caches, shell caches, dev caches, Windows.old, Package Cache)
embedded under cfg(windows) and parse-checked on every host.
- squid-core: trash moves behind a platform seam — Windows recycles via
IFileOperation (shell owns $Recycle.Bin bookkeeping; ledger records no
physical path there), Unix keeps the rename/copy path untouched
- squid-core: default cleanup anchors per platform; Unix-only helpers
(getuid, statvfs-style trash dirs, symlink copy) gated
- squid-platform: windows.rs rewritten — installed apps from the uninstall
registry (HKLM 64/32-bit views + HKCU, SystemComponent/patch filtering),
BIOS/NT version keys for hardware/OS strings, sysinfo for volumes and
running processes; winreg replaces the PowerShell stub
- squid-stats: COMPUTERNAME hostname off-unix; battery parsers gated
- CI: .gitlab-ci.yml with a Linux job that cross-checks the whole workspace
against x86_64-pc-windows-msvc, plus a manual tagged Windows job driven by
scripts/ci-windows.ps1 (build + test on a real machine)
- host (macOS) tests, clippy -D warnings and fmt stay green