3 Commits
Author SHA1 Message Date
Jean-Pierre MartineauandClaude Opus 5 2790159d04 Ask for a window MeshTerm fits in, rather than taking whatever is open
Installers / windows-x64 (push) Canceled after 0s
Installers / macos-x64 (push) Canceled after 0s
Installers / macos-arm64 (push) Canceled after 0s
Installers / linux-x64 (push) Canceled after 0s
Installers / linux-arm64 (push) Canceled after 0s
GitHub release / build (push) Canceled after 0s
GitHub release / create the release (push) Canceled after 0s
JP saw the PicoCalc's wordmark on a desktop session. The splash picks the
widest mark that fits, the desktop one is 71 columns, and below that it swaps
to the 53 drawn for the handheld -- so the app was announcing itself as the
handheld and truncating every menu description onto the pager underneath.

The window was 64 columns. reopen() passed no window argument, so wt.exe put
the session in a *tab* of whatever window happened to be open and it inherited
that size; with no window open it would instead have taken the reader's global
launch size, which is a setting about their shell and nothing to do with this
app. Either way the app could land somewhere too small for it, and the failure
was quiet and cosmetic rather than anything that announced itself.

It now asks for a window of its own at the platform's stated minimum plus a
margin -- 80x30 on the desktop, derived from readable_cols/readable_rows so it
follows them. Windows Terminal clamps to what the display can show, so a small
screen degrades exactly as it did before.

The tab is titled MeshTerm too. It was showing the executable's full path,
which on a downloaded build is a line of Downloads folder. The icon is not ours
to set -- Windows Terminal takes that from a profile and a bare command line is
not one.

Release 0.2.8.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 20:28:54 -04:00
Jean-Pierre MartineauandClaude Opus 5 690807370b Take them to the better terminal instead of asking permission to
Installers / windows-x64 (push) Canceled after 0s
Installers / macos-x64 (push) Canceled after 0s
Installers / macos-arm64 (push) Canceled after 0s
Installers / linux-x64 (push) Canceled after 0s
Installers / linux-arm64 (push) Canceled after 0s
GitHub release / build (push) Canceled after 0s
GitHub release / create the release (push) Canceled after 0s
The classic Windows console cannot draw a single MeshTerm icon whatever font
it is given, so "reopen in Windows Terminal?" had exactly one sensible answer
-- and was being put to someone who had not seen the app yet and so had nothing
to weigh it against, at the one moment nothing had been drawn.

So it moves. It still says what it is doing and still names the way to stop it,
because a program that opens a window you did not ask for should say so.

Installing a font keeps its consent, and the split is deliberate: moving window
costs nothing and undoes itself by closing, while a font is a file written to
someone's machine that Windows will not let go of until their next logon.

The console_setup preference reads auto/off now rather than ask/off, and its
help says what it does. An older stored "ask" is not "off", so it keeps working
and simply means auto.

JP's call, and it is the right one -- the reference experience should be what
an end user gets, not what they think to ask for.

Release 0.2.7.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 19:42:46 -04:00
Jean-Pierre MartineauandClaude Opus 5 564e051d1a The reopened session must not inherit the bundle's own bookkeeping
Installers / windows-x64 (push) Canceled after 0s
Installers / macos-x64 (push) Canceled after 0s
Installers / macos-arm64 (push) Canceled after 0s
Installers / linux-x64 (push) Canceled after 0s
Installers / linux-arm64 (push) Canceled after 0s
GitHub release / build (push) Canceled after 0s
GitHub release / create the release (push) Canceled after 0s
Found by testing the release artifact rather than the repo. A PyInstaller
one-file build unpacks itself and re-runs itself, the halves coordinating
through _PYI* environment variables. reopen() handed the whole environment to
the new copy, so its bootloader concluded it was stage two of a launch nobody
had made, checked that its parent was the same executable, found wt.exe, and
aborted:

    [PYI-33368:ERROR] Security validation failure: parent process has
    different executable!
    [process exited with code 4294967295]

A new window holding a message nobody can act on, with the window that offered
the move already gone. Strictly worse than not offering.

child_environment() strips them, and restores the loader paths the bootloader
parks aside. Verified against a locally frozen build: before, the bootloader
error; after, the session comes up in Windows Terminal with its emoji and its
charts.

The source build could never have shown this. Same shape as 0.2.2's empty tool
registry -- the packaged build is a platform of its own, and the only way to
test it is to run it.

Release 0.2.6.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 17:57:10 -04:00
7 changed files with 279 additions and 48 deletions

No files matched your search

+47
View File
@@ -17,6 +17,53 @@ allowed to change behaviour, not just add to it.
## [Unreleased]
## [0.2.8] — 2026-09-07
### Fixed
- **The window MeshTerm opened for itself was too small, and it showed.** The startup
wordmark is 71 columns wide; below that the splash quietly swaps to the narrow one drawn
for the PicoCalc — so a desktop session came up wearing the handheld's mark, with every
menu description truncated onto the pager underneath it.
MeshTerm was opening a *tab* in whatever Windows Terminal window happened to be around,
inheriting its size (64 columns on the machine this was found on). It now asks for a
window of its own, sized from the platform's own minimum plus a margin. Windows Terminal
clamps that to what the display can show, so a small screen degrades exactly as before.
- The tab it opens is titled **MeshTerm**, not the executable's full path — which on a
downloaded build was a line of Downloads folder.
## [0.2.7] — 2026-09-07
### Changed
- **MeshTerm moves to Windows Terminal rather than asking to.** It still says so, and
still tells you how to stop it, but it doesn't put the question. The classic console
can't draw a single icon whatever font it's given, so there was only one sensible
answer — and it was being asked of someone who hadn't seen the app yet and had nothing
to judge it by.
Installing a **font** still asks, because that writes a file to your machine. Moving
window doesn't. Preferences → Display → Console setup stops both.
## [0.2.6] — 2026-09-07
### Fixed
- **Accepting "reopen in Windows Terminal" killed the session** in the downloadable
builds. A new window opened, printed `Security validation failure: parent process has
different executable!`, and exited — while the window that made the offer had already
closed. Worse than never offering.
A one-file build unpacks itself and re-runs itself, the two halves coordinating through
private environment variables. Those were being handed to the new copy, which concluded
it was the second half of a launch it never made, checked that its parent was the same
program, found Windows Terminal instead, and stopped. They are stripped now.
It worked perfectly when run from source, which is the whole lesson: the packaged build
is its own platform.
## [0.2.5] — 2026-09-07
### Fixed
+13 -14
View File
@@ -68,14 +68,14 @@ if anything goes wrong at startup the window closes before you can read why.
**Windows** — open Windows Terminal or PowerShell, `cd` to your downloads, then:
```powershell
.\meshterm-0.2.5-windows-x64.exe
.\meshterm-0.2.8-windows-x64.exe
```
**macOS and Linux** — open Terminal, `cd` to your downloads, then:
```bash
chmod +x meshterm-0.2.5-*
./meshterm-0.2.5-*
chmod +x meshterm-0.2.8-*
./meshterm-0.2.8-*
```
### A word about terminals, on Windows
@@ -91,20 +91,19 @@ doesn't borrow. It draws what its one font holds and empty boxes for everything
no font fixes the icons there: the only two fonts on a Windows machine with emoji in them
are proportional, and a console won't take a proportional font.
So when MeshTerm lands in that console it offers to move: **reopen in Windows Terminal**,
one keypress, nothing installed and nothing changed. That's the whole app, exactly as the
screenshots show it. Windows Terminal is already on every Windows 11 machine and is a free
install on Windows 10.
So when MeshTerm lands in that console it just **moves to Windows Terminal** — it says
so, and opens there. Nothing is installed and nothing is changed; it's one window instead
of another, and it's the whole app exactly as the screenshots show it. Windows Terminal is
already on every Windows 11 machine and is a free install on Windows 10.
Stay in the classic console and MeshTerm offers the next best thing instead — the charts
and marks, without the icons. It ships
Where there's no Windows Terminal to move to, MeshTerm offers the next best thing instead
— the charts and marks, without the icons. It ships
[Cascadia Mono PL](https://github.com/microsoft/cascadia-code), Microsoft's own console
font and one of the very few monospace faces that carries braille at all, and will install
it just for you: no administrator rights, nothing downloaded. If you already have Cascadia
it simply switches to it.
You can decline both and MeshTerm still runs. Preferences → Display → Console setup is
where you change your mind.
Preferences → Display → Console setup turns all of this off if you'd rather stay put.
Rename it to something you don't mind typing and put it somewhere on your `PATH`, and it
becomes just `meshterm` from anywhere.
@@ -114,7 +113,7 @@ becomes just `meshterm` from anywhere.
> project.
>
> - **macOS**: *"cannot be opened because the developer cannot be verified"*. Clear it with
> `xattr -d com.apple.quarantine meshterm-0.2.5-*` and run it again.
> `xattr -d com.apple.quarantine meshterm-0.2.8-*` and run it again.
> - **Windows**: *"Windows protected your PC"*. Click **More info → Run anyway**.
>
> Every release ships a `SHA256SUMS` file if you'd rather check the download first.
@@ -124,10 +123,10 @@ becomes just `meshterm` from anywhere.
> MeshTerm uses that same folder. Set `MESHTERM_HOME` to try one in isolation:
>
> ```bash
> MESHTERM_HOME=~/meshterm-test ./meshterm-0.2.5-* # macOS, Linux
> MESHTERM_HOME=~/meshterm-test ./meshterm-0.2.8-* # macOS, Linux
> ```
> ```powershell
> $env:MESHTERM_HOME = "$HOME\meshterm-test"; .\meshterm-0.2.5-windows-x64.exe
> $env:MESHTERM_HOME = "$HOME\meshterm-test"; .\meshterm-0.2.8-windows-x64.exe
> ```
>
> Same variable if you run two radios and want them kept apart.
+1 -1
View File
@@ -5,7 +5,7 @@ Supports USB, Bluetooth and TCP companion connection. For Windows, macOS and Lin
from datetime import datetime
__version__ = "0.2.5"
__version__ = "0.2.8"
__author__ = "Jean-Pierre Martineau"
#: The year MeshTerm was first published; the copyright span starts here.
+30 -24
View File
@@ -222,16 +222,21 @@ def main_callback(
def _offer_a_console_that_can_draw_meshterm(console: Console, prefs: Preferences) -> bool:
"""On the classic Windows console, offer the reader something better than it.
"""On the classic Windows console, get the reader somewhere better than it.
Two offers, in the order of how much they buy. **Windows Terminal** first, because it
is the only one that gets the whole app: emoji icons included, which no font can put
on the classic console — the only Windows fonts carrying emoji are proportional, and
a console will not take one. Then, for a reader who stays, **a font** that can at
least draw the charts and the marks.
Two remedies, and they are not asked the same way.
**Windows Terminal** first, and simply done. It is the only thing that gets the whole
app — emoji icons included, which no font can put on that console, the only Windows
fonts carrying any being proportional and a console taking none of them. Moving there
installs nothing and changes nothing, so there is one sensible answer to a question
that would be put to someone who has not seen the app yet and cannot judge it.
**A font** second, only where the move was not possible, and that one *is* asked —
it writes a file onto someone's machine, which is theirs to agree to.
Args:
console: The console to ask on.
console: The console to report and ask on.
prefs: The preference set, read for a previous refusal and written on a new one.
Returns:
@@ -241,24 +246,30 @@ def _offer_a_console_that_can_draw_meshterm(console: Console, prefs: Preferences
if not classic_console() or prefs.get("console_setup") == "off":
return False
if _offer_windows_terminal(console):
if _move_to_windows_terminal(console):
return True
_offer_a_font_this_console_can_draw(console, prefs)
return False
def _offer_windows_terminal(console: Console) -> bool:
"""Offer to reopen the session in Windows Terminal, where the app looks like itself.
def _move_to_windows_terminal(console: Console) -> bool:
"""Reopen the session in Windows Terminal, where the app can draw all of itself.
Asked with yes as the default, which is not how the font offer is asked: this one
changes nothing on the machine — no install, no setting, one new window — and it is
the only answer that gets the reader the app as it was drawn.
Done rather than offered. The classic console cannot show a single icon whatever it is
given, so "reopen there?" is a question with one sensible answer, asked of someone who
has not seen the app yet and so cannot judge it — and asked at the worst moment, before
anything has been drawn. Moving costs nothing and changes nothing: no install, no
setting, one window instead of another.
It is announced rather than silent, and the announcement names the way to stop it,
because a program that opens a window you did not ask for should at least say so.
``console_setup`` set to ``off`` keeps the session here for good.
Args:
console: The console to ask on.
console: The console to report on.
Returns:
Whether Windows Terminal was started and this session should stand down.
Whether Windows Terminal took over and this session should stand down.
"""
from .core import winterminal
@@ -266,17 +277,12 @@ def _offer_windows_terminal(console: Console) -> bool:
return False
console.print()
console.print("[accent]•[/accent] This is the classic Windows console, and it can only")
console.print(" draw part of MeshTerm — no icons, and no charts.")
console.print("[accent]•[/accent] Opening in [accent]Windows Terminal[/accent] — this console")
console.print(" can't draw MeshTerm's icons or charts.")
console.print("[muted] Preferences → Display → Console setup keeps it here instead.[/muted]")
console.print()
console.print(" [accent]Windows Terminal[/accent] draws all of it, and you have it.")
console.print(" MeshTerm can reopen itself there now. Nothing is installed")
console.print(" and nothing is changed; it is just a better window.")
console.print()
if not _asks_yes(console, " Reopen in Windows Terminal? [Y/n] ", default=True):
return False
if winterminal.reopen():
console.print("[ok]✓[/ok] Reopening in Windows Terminal.")
get_logger().info("reopened the session in Windows Terminal")
return True
console.print("[warn]⚠[/warn] Windows Terminal would not start. Staying here.")
+8 -6
View File
@@ -131,7 +131,7 @@ _WIDTH_CHOICES: dict[str, str] = {"auto": "auto", "yes": "yes", "no": "no"}
#: What MeshTerm may offer when it lands in a console that cannot draw it. Only ever
#: consulted on the classic Windows console, the one host with no font fallback of its own.
_CONSOLE_SETUP_CHOICES: dict[str, str] = {
"ask": "Ask",
"auto": "Automatic",
"off": "Leave it alone",
}
@@ -305,13 +305,15 @@ PREFERENCES: tuple[PrefSpec, ...] = (
PrefSpec(
key="console_setup",
label="Console setup",
help="Offer a better terminal or font when this console can't draw MeshTerm",
help="Move to a better terminal when this console can't draw MeshTerm",
group="Display",
value_type="enum",
# "ask", not "always": changing the font of a window someone else opened is not
# ours to do unasked. Declining twice writes "off" here, which is how the offer
# stops being made rather than being made every launch.
default="ask",
# Reopening in Windows Terminal is done, not asked: the classic console cannot
# draw a single icon whatever font it is given, so there is only one sensible
# answer and the reader has not seen the app yet to judge it. Installing a *font*
# still asks, because that writes to their machine. Declining that twice writes
# "off" here, which turns both off for good.
default="auto",
choices=_CONSOLE_SETUP_CHOICES,
),
# --- Diagnostics ---------------------------------------------------------------
+79 -3
View File
@@ -61,6 +61,45 @@ def own_command() -> list[str]:
return [sys.executable, "-m", "meshterm", *sys.argv[1:]]
def child_environment() -> dict[str, str]:
"""The environment for a fresh launch of MeshTerm, minus this bundle's bookkeeping.
A PyInstaller one-file build runs in two stages: the executable unpacks itself into a
temporary directory and then runs itself again as a child, the two halves coordinating
through ``_PYI*`` environment variables. Those must not reach a *new* launch of the
executable. The bootloader would find them, conclude it is the second stage of a launch
it never made, check that its parent is the same program — find Windows Terminal
instead — and abort::
[PYI-33368:ERROR] Security validation failure: parent process has different
executable!
Which is the whole session gone, in a brand new window holding a message nobody can act
on, while the window that offered the move has already closed. Removing them makes the
new process a first stage, which is what it actually is.
Returns:
The environment to start the new process with.
"""
environment = dict(os.environ)
environment[REOPENED_ENV] = "1"
if not getattr(sys, "frozen", False):
return environment
for key in [key for key in environment if key.startswith("_PYI")]:
del environment[key]
environment.pop("_MEIPASS2", None) # the name older bootloaders used
# The bootloader points the loader at the unpacked bundle and parks the caller's own
# value beside it. The new process unpacks its own copy, so it wants the original.
for name in ("LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH"):
original = environment.pop(f"{name}_ORIG", None)
if original is not None:
environment[name] = original
else:
environment.pop(name, None)
return environment
def reopen() -> bool:
"""Start this session again in Windows Terminal, in the same directory.
@@ -74,17 +113,54 @@ def reopen() -> bool:
terminal = available()
if terminal is None:
return False
environment = dict(os.environ, **{REOPENED_ENV: "1"})
try:
# `--` ends wt's own option parsing, so MeshTerm's flags reach MeshTerm rather
# than being read as Windows Terminal's (verified: `--mock` and `--profile x`
# arrive intact). `-d` keeps the working directory, which relative paths given
# on the command line depend on.
subprocess.Popen( # noqa: S603 - the argv is ours, not the reader's
[terminal, "-d", os.getcwd(), "--", *own_command()],
env=environment,
[
terminal,
"-w",
"new",
"--size",
_wanted_size(),
# Otherwise the tab is titled with the executable's full path, which on a
# downloaded build is a line of Downloads folder. The icon is not ours to
# set: Windows Terminal takes that from a profile, and a bare command line
# is not one, so it gets the generic console glyph.
"--title",
"MeshTerm",
"-d",
os.getcwd(),
"--",
*own_command(),
],
env=child_environment(),
close_fds=True,
)
return True
except OSError:
return False
def _wanted_size() -> str:
"""The window to ask Windows Terminal for, as ``cols,rows``.
Asked for, because a window MeshTerm opens should be one MeshTerm fits in. Without
``-w new`` the session lands as a *tab* in whatever window happens to be open and
inherits its size; without ``--size`` a new window takes the reader's global launch
size, which is a setting about their shell and not about this app. Either way the app
can arrive in a window too small for it, and the failure is quiet and cosmetic: the
startup wordmark is 71 columns, so at 70 it silently swaps to the narrow one drawn for
the PicoCalc, and a short window truncates every description onto the pager.
The numbers come from the platform's own stated minimum plus a margin, so they follow
it rather than repeating it. Windows Terminal clamps to what the display can show, so
this is a request and not a demand — on a small screen the app degrades exactly as it
would have anyway.
"""
from ..platforms import get_platform
platform = get_platform()
return f"{platform.readable_cols + 8},{platform.readable_rows + 6}"
+101
View File
@@ -73,3 +73,104 @@ def test_the_program_name_is_never_passed_on_as_an_argument(
monkeypatch.setattr(sys, "executable", r"C:\meshterm.exe")
monkeypatch.setattr(sys, "argv", [r"C:\some\other\name.exe"])
assert winterminal.own_command() == [r"C:\meshterm.exe"]
def test_the_bundles_own_bookkeeping_never_reaches_the_new_process(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""The bug the frozen build found, and the only one the source build could not.
A PyInstaller one-file executable unpacks itself and re-runs itself, the two halves
talking through ``_PYI*`` variables. Passing those on made the reopened MeshTerm think
it was the second half of a launch it never made; it checked its parent, found Windows
Terminal, and killed itself with a bootloader error in a window that had just opened.
"""
monkeypatch.setattr(sys, "frozen", True, raising=False)
monkeypatch.setenv("_PYI_ARCHIVE_FILE", r"C:\Downloads\meshterm.exe")
monkeypatch.setenv("_PYI_PARENT_PROCESS_LEVEL", "0")
monkeypatch.setenv("_MEIPASS2", r"C:\Temp\_MEI123")
monkeypatch.setenv("MESHTERM_HOME", r"C:\mine")
environment = winterminal.child_environment()
assert not [key for key in environment if key.startswith("_PYI")]
assert "_MEIPASS2" not in environment
assert environment["MESHTERM_HOME"] == r"C:\mine" # the reader's own settings survive
assert environment[winterminal.REOPENED_ENV] == "1"
def test_a_source_run_keeps_the_environment_it_was_given(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Nothing is stripped when there is no bundle, so a dev run is passed through whole.
``LD_LIBRARY_PATH`` is the one to watch: unfrozen it is the reader's, and dropping it
would change how the new process loads its libraries for no reason at all.
"""
monkeypatch.delattr(sys, "frozen", raising=False)
monkeypatch.setenv("LD_LIBRARY_PATH", "/opt/mine/lib")
assert winterminal.child_environment()["LD_LIBRARY_PATH"] == "/opt/mine/lib"
def test_the_loader_path_the_bootloader_replaced_is_put_back(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""The bootloader points the loader at its own unpacked copy and parks the original.
The new process unpacks a bundle of its own, so it wants the value the reader started
with — and where there was none, none.
"""
monkeypatch.setattr(sys, "frozen", True, raising=False)
monkeypatch.setenv("LD_LIBRARY_PATH", "/tmp/_MEI999")
monkeypatch.setenv("LD_LIBRARY_PATH_ORIG", "/opt/mine/lib")
monkeypatch.setenv("DYLD_LIBRARY_PATH", "/tmp/_MEI999")
monkeypatch.delenv("DYLD_LIBRARY_PATH_ORIG", raising=False)
environment = winterminal.child_environment()
assert environment["LD_LIBRARY_PATH"] == "/opt/mine/lib"
assert "LD_LIBRARY_PATH_ORIG" not in environment
assert "DYLD_LIBRARY_PATH" not in environment
def test_the_window_asked_for_fits_the_startup_wordmark() -> None:
"""The size request exists because a too-small window fails quietly, not loudly.
The startup wordmark is 71 columns; below that the splash silently swaps to the narrow
one drawn for the PicoCalc, which is how this was found — a desktop session showing the
handheld's mark. The request has to clear that, not merely the platform's minimum.
"""
from meshterm.platforms import REGULAR, set_platform
from meshterm.ui.logo import load_logo, logo_width
set_platform(REGULAR)
cols, rows = (int(part) for part in winterminal._wanted_size().split(","))
assert logo_width(load_logo(cols)) == 71, "the window asked for would get the narrow mark"
assert cols >= REGULAR.readable_cols
assert rows >= REGULAR.readable_rows
def test_the_session_gets_its_own_window_at_that_size(monkeypatch: pytest.MonkeyPatch) -> None:
"""Both halves matter, and each was a separate way to arrive somewhere too small.
Without ``-w new`` the session lands as a tab in whatever window is already open and
inherits its size — measured at 64 columns on a real machine, which is why the wrong
mark appeared. Without ``--size`` a new window takes the reader's global launch size,
a setting about their shell rather than about this app.
"""
started: list[list[str]] = []
monkeypatch.setattr(sys, "platform", "win32")
monkeypatch.delenv(winterminal.REOPENED_ENV, raising=False)
monkeypatch.setattr(winterminal.shutil, "which", lambda _: r"C:\wt.exe")
monkeypatch.setattr(
winterminal.subprocess, "Popen", lambda argv, **_: started.append(argv) or None
)
assert winterminal.reopen() is True
argv = started[0]
assert argv[:3] == [r"C:\wt.exe", "-w", "new"]
assert "--size" in argv
assert argv[argv.index("--size") + 1] == winterminal._wanted_size()
# `--` must still separate wt's options from MeshTerm's, or `--mock` becomes wt's.
assert "--" in argv and argv.index("--") > argv.index("--size")