Skip to content

fix: enforce lowered disk limit, keep attached output, show UI on reopen and quit - #21

Merged
tieuanhquoc merged 3 commits into
masterfrom
fix/reopen-shows-dashboard
Oct 7, 2026
Merged

tieuanhquoc merged 3 commits into
masterfrom
fix/reopen-shows-dashboard

Conversation

@tieuanhquoc

Copy link
Copy Markdown
Collaborator

What & why

Four user-reported problems, each fixed at the layer every instance goes through:

  • Disk limit not enforced when lowered. The VM disk only ever grew, so a disk created at 64 GB kept using 64 GB after the limit was set to 16 GB. Apply & Restart now stops Docker → shrinks the disk offline in the builder VM (e2fsck, resize2fs with headroom, GPT rewritten for the new size) → truncates → starts Docker. An APFS clone is kept until success and restored on failure or interruption; data that doesn't fit is refused with a limit that would fit. DockZ shrink-disk does the same headless. Monitor shows used vs. limit (orange ≥80%, red ≥95%) plus the Mac's free space.
  • docker run lost output after 0.5 s. The guest's socat relays used the default -t 0.5; the docker CLI half-closes hijacked streams right after attaching, so later output was cut (echo start; sleep 3; echo end printed only start). All relays now keep the other direction open. Because guest rootfs/ files are baked into disk.img, every boot now syncs the app's copy into the VM (boot-path files excluded) and restarts changed services — existing installs get this and future guest fixes.
  • Reopening DockZ showed nothing when the menu bar icon was hidden. Reopen / user launch now shows the dashboard; Launch at Login stays quiet.
  • Quit looked frozen. A "Shutting down DockZ…" window lists what is being stopped.

Checklist

  • swift run -c release DockzApp test passes locally (321 checks, 61 new)
  • No new external Swift dependencies
  • New pure logic has checks in test-runner.swift
  • Verified the affected flow in the running app

How I verified it

On a throwaway data root (-dockz.storageRoot /tmp/dzs):

  • New disk created exactly at the limit (24 GB → 24 GiB disk.img).
  • With 7.9 GB of random data: shrink to 8 GB refused in 17 s, disk unchanged; shrink to 16 GB done in 18 s; after boot both files' sha256 match, vda 16.0 GiB, no GPT warnings, fs grown to fill. shrink-disk refuses while DockZ holds the data folder.
  • Old-image VM got the new dockz-agent on first boot; run with 6 s gap, exec, piped stdin (-i, EOF still delivered) and logs -f stream fully; second boot rewrites nothing.
  • Output fix confirmed on a real install (start / end).
  • Cold launch opens the dashboard; quit with a running VM shows the shutdown window until the VM stops.

Not clicked through: the Settings Apply → confirm → shrink overlay path in the GUI (it calls the same DiskShrinker tested above), and reopen-while-running end-to-end.

🤖 Generated with Claude Code

tieuanhquoc and others added 2 commits October 7, 2026 18:25
…pen and quit

- Disk limit: the VM disk only ever grew, so lowering the limit (64 → 16 GB)
  was ignored. Apply & Restart now stops Docker, shrinks the disk offline in
  the builder VM (e2fsck, resize2fs with headroom, GPT rewritten for the new
  size), truncates the image and starts Docker again. An APFS clone is kept
  until it succeeds and put back on failure or an interrupted run; data that
  does not fit is refused with a limit that would fit, and the setting goes
  back to the real disk size. `DockZ shrink-disk` does the same headless.
  Monitor shows used space against the limit (80% / 95% colours) plus the
  Mac's free space.
- Attached output: the guest's socat relays used the default -t 0.5, so a
  docker CLI half-close cut hijacked streams after half a second (`docker
  run` without -d lost everything printed later). All relays now keep the
  other direction open. Guest rootfs files baked into disk.img never got
  such fixes, so every boot now syncs the app's copy into the VM (boot-path
  files excluded) and restarts changed services.
- Reopening DockZ while its menu bar icon is hidden shows the dashboard; a
  user launch opens it, Launch at Login stays quiet.
- Quitting shows a "Shutting down DockZ…" window listing what is stopped.

Tests: 321 checks pass (61 new). Verified on a throwaway data root: new
disks are created at the limit; shrink 24 → 8 GB refused with the disk
unchanged, 24 → 16 GB done in 18 s with file checksums intact after boot;
an old-image VM got the new agent on its first boot and `echo start; sleep
6; echo end`, exec, piped stdin and logs -f all stream fully. The output
fix was also confirmed on a real install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Deploying dockz with  Cloudflare Pages  Cloudflare Pages

Latest commit: a183fe3
Status: ✅  Deploy successful!
Preview URL: https://e0a1caa1.dockz.pages.dev
Branch Preview URL: https://fix-reopen-shows-dashboard.dockz.pages.dev

View logs

…data folder

- The post-shrink e2fsck ran with its output discarded, so a failure seen
  once on a real disk (and not reproduced in 6 later runs on a copy of it)
  left only "did not check clean". Its output and exit code now go to
  builder/shrink.log.
- Tests ran against the default data root, so code under test wrote into
  the user's ~/.dockz/host.log (and settings loads could save a default
  config there). The test runner now points every DockzPaths() in its
  process at a temporary folder, with a check that it did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tieuanhquoc
tieuanhquoc merged commit c915872 into master Oct 7, 2026
3 checks passed
@tieuanhquoc
tieuanhquoc deleted the fix/reopen-shows-dashboard branch October 7, 2026 12:19
@tieuanhquoc tieuanhquoc mentioned this pull request Oct 7, 2026
4 tasks done
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.

1 participant