Skip to content

Improve authorized writing and in-app results - #1

Merged
fanny7d merged 4 commits into
mainfrom
agent/in-app-authorized-writing
Aug 14, 2026
Merged

fanny7d merged 4 commits into
mainfrom
agent/in-app-authorized-writing

Conversation

@fanny7d

@fanny7d fanny7d commented Aug 14, 2026

Copy link
Copy Markdown
Owner

What changed

  • Replaced the Terminal and sudo handoff with the macOS system authorization UI.
  • Streams validation, diskutil, dd, sync, eject, and failure output into the app.
  • Reworked the workspace into one preparation card and one state-aware activity card.
  • Removed copy-log actions from both the workspace and the completion sheet.
  • Made the primary window user-resizable with bounded 840×600 to 1240×900 content sizing.
  • Reset the previously oversized saved frame while preserving future user-selected size and position.
  • Uses a fixed-width sidebar and a centered, capped workspace so wide windows remain balanced.
  • Truncates long image and device names inside their rows without changing the window size; full values remain available through hover help.
  • Lets the activity log absorb extra vertical space while preserving controls at the minimum size.
  • Keeps a successful run visible as image written, safely ejected, and complete instead of reverting to the empty-device prompt.
  • Added a native completion sheet with image, target, elapsed time, and eject status.
  • Prevents ordinary app termination while a destructive write is active.
  • Revalidates image size and whole, external, removable, writable disk identity after authorization.
  • Updated the app version to 1.2.0 and refreshed English and Chinese documentation.

Why

Opening Terminal, requesting a password again, and splitting progress across two apps made the flow feel untrusted and difficult to follow. The earlier workspace also behaved like a rigid form: the window could not be resized, an oversized autosaved frame was restored, long filenames contributed their full intrinsic width, the sidebar expanded with the window, and the log could not use added vertical space.

The revised layout groups preparation choices together, makes current activity the primary status surface, and follows a predictable desktop resizing policy: dynamic text truncates first, critical controls remain visible, and logs receive flexible space.

Security and compatibility

The current certificate-free build uses the legacy Authorization Services execution bridge. It does not collect or store credentials. A persistent privileged helper is intentionally deferred until Developer ID signing is available so an SMAppService XPC client can be authenticated reliably.

Validation

  • xcrun swift-format lint --strict Sources/USBBootableDriveTool/main.swift
  • ./script/test.sh
  • git diff --check
  • ./script/build_and_run.sh --verify
  • foreground accessibility and visual review at the default 960×660 size
  • long-image-name review at default and minimum 840×600 sizes
  • enlarged-window review confirming fixed sidebar, capped content width, and flexible log height
  • real disposable-media write acceptance from the earlier commit:
    • Ubuntu ISO: 4,762,707,968 bytes
    • whole external removable writable USB target
    • dd: 4,762,707,968 bytes written in 47.8 seconds
    • sync and safe eject completed
    • in-app result reported total elapsed time of 54 seconds

Booting the completed media on target hardware remains a separate acceptance step.

@fanny7d
fanny7d marked this pull request as ready for review August 14, 2026 10:26
@fanny7d
fanny7d merged commit 4316256 into main Aug 14, 2026
1 check passed
@fanny7d
fanny7d deleted the agent/in-app-authorized-writing branch August 14, 2026 10:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91ffdd8d6e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

let script = makePrivilegedScript(image: image, imageSize: imageSize, disk: disk)
let rawArguments = ["-c", script]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Invoke the privileged shell without user startup files

When the authorized child inherits the user's HOME or ZDOTDIR, invoking zsh -c lets it load the user-writable .zshenv before this script performs validation; the zsh startup-file documentation specifies that every invocation reads $ZDOTDIR/.zshenv. An unprivileged process can therefore plant commands there and have them execute as root when the user approves this otherwise legitimate write. Invoke zsh with -f before -c, or avoid a startup-file-aware shell at this privilege boundary.

Useful? React with 👍 / 👎.

}
imageURL = url
imageField.stringValue = url.path
writePhase = .idle

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the writing phase when image selection is invoked

During an active write, the File-menu “选择系统镜像…” item and its Cmd-O shortcut remain enabled because beginWriting() disables only chooseButton. Invoking that menu reaches this unconditional assignment and changes the UI to the idle/readiness state even though the privileged dd process is still running, potentially prompting the user to disconnect the target. Guard this selector while isWriting or disable/validate the corresponding menu item.

Useful? React with 👍 / 👎.

Comment thread script/package_dmg.sh
exit 1
fi

"$ROOT_DIR/script/build_and_run.sh" --build-only

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Build the release binary for the advertised macOS target

When this DMG is produced on a macOS version newer than 13, the invoked build has no explicit deployment target, so swiftc records its default target in the Mach-O binary and the download can be rejected by dyld on the advertised macOS 13 systems; setting only LSMinimumSystemVersion in Info.plist does not lower that load command. I checked the swiftc invocation in script/build_and_run.sh, and swiftc --help identifies -target <triple> as the option that generates code for a specified OS target. Pass an arm64 macOS 13 target (or MACOSX_DEPLOYMENT_TARGET=13.0) and validate it with otool during packaging.

Useful? React with 👍 / 👎.

Comment thread script/package_dmg.sh
}

/bin/mkdir -p "$OUTPUT_DIR"
/usr/bin/ditto "$APP_BUNDLE" "$STAGING_DIR/$APP_NAME.app"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Package from a clean application bundle

When an existing USB启动盘工具.app contains files left by an older build or local experiment, build_and_run.sh only creates its directories and overwrites the currently known files; this ditto then copies every stale file into the release DMG. Consequently the claimed reproducible artifact depends on local build history and can ship obsolete or unintended resources. Remove the bundle before building or assemble the release into a fresh bundle directory before copying it to staging.

Useful? React with 👍 / 👎.

Comment thread script/package_dmg.sh
/usr/bin/ditto "$APP_BUNDLE" "$STAGING_DIR/$APP_NAME.app"
/bin/ln -s /Applications "$STAGING_DIR/Applications"

/usr/bin/hdiutil create \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detach an existing output image before overwriting it

When a developer has the previously generated DMG mounted—a common state after inspecting a release—this hdiutil create runs before detach_created_image_if_needed, so the mounted backing image remains open and creation fails rather than reaching the detach call. The hdiutil create -help description of -ov only permits overwriting an existing file; it does not detach a mounted image. Call the detach helper before creation as well as in cleanup so packaging can be rerun while the prior artifact is mounted.

Useful? React with 👍 / 👎.

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.

2 participants