mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
app: add Command-O and show file-picker errors (#252)
The inspector had an Open Executable… button but no app-level Open command, and the file importer's completion ignored failures, so a picker error was never shown. - File > Open Executable… with Command-O, after New Window. It calls the same requestImport() as the button, so it opens the same read-only importer and the chosen file reaches inspect(), the path shared with drag and drop and Finder Open With. - importFinished(_:) handles the importer result: success inspects, a user cancellation (CocoaError.userCancelled) shows nothing, and any other failure is shown in red with the error's description. The message clears on the next request or selection. - --smoke-import-result checks cancellation, a shown failure and its clearing without opening files; scripts/build-app.sh runs it after --smoke. It fails with the previous importer handling and without the cancellation check. Opening a file still never starts guest execution, the DBT or the JIT. Ported from XenoraOSS/Xenora#424. Signed-off-by: maridogolpeador <354308468+maridogolpeador@users.noreply.github.com>
This commit is contained in:
1 parent
67b8cff9df
commit
64e7b16983
3 files changed
+60
-2
No files matched your search
@@ -10,6 +10,7 @@ Guest execution uses original, purpose-built test programs. Commercial Xbox game
|
||||
remains unsupported.
|
||||
|
||||
### Added
|
||||
- Added File > Open Executable… with Command-O to the app (#252). It opens the same read-only file importer as the inspector's button, and the chosen file goes through the same inspection path as the button, drag and drop and Finder Open With; nothing is executed. A file-importer failure is now shown in red with the system's description instead of being ignored, a cancelled picker shows nothing, and the message clears on the next selection. `BetterXen --smoke-import-result`, run by `scripts/build-app.sh`, checks cancellation, a shown failure and its clearing; it fails on the previous importer handling. Checked locally on Apple Silicon in the running app (Command-O and the menu item open the picker, cancel shows no error, a second Command-O opens it again); not yet independently reviewed.
|
||||
- Rewrote the README around the six development phases and the first-launchable-application target (#311), with colour-coded Mermaid diagrams (system flow, milestone roadmap, CPU, runtime-service and shader-form charts built from the generated registries), badges, a repository overview, a contributing section and corrected texture-sampling wording. The older X1–X25 capability map is kept in a collapsible section. The diagrams were not render-tested locally.
|
||||
- Added a fast "Repository hygiene" check (`.github/workflows/hygiene.yml`, `scripts/audit/docs_hygiene.py`). It runs on Ubuntu without a Rust toolchain or network access and fails only on merge-conflict markers, broken relative Markdown links and invalid workflow YAML in tracked files. A separate advisory step warns, without failing, when source or script changes have no changelog entry. A local run over the 626 tracked files found no problems, and planted failures of each kind were caught; it has not yet run on GitHub.
|
||||
|
||||
|
||||
@@ -639,8 +639,30 @@ final class InspectionModel: ObservableObject {
|
||||
@Published var status: Int32 = Int32(XENORA_OK)
|
||||
@Published var busy = false
|
||||
@Published var importing = false
|
||||
/// Why the last file selection could not be used, shown until the next selection.
|
||||
@Published var selectionError: String?
|
||||
|
||||
/// Shows the read-only file importer, from the button or File > Open Executable….
|
||||
func requestImport() {
|
||||
selectionError = nil
|
||||
importing = true
|
||||
}
|
||||
|
||||
/// Handles the importer's completion. A cancelled picker is not a failure.
|
||||
func importFinished(_ result: Result<URL, Error>) {
|
||||
switch result {
|
||||
case .success(let url):
|
||||
inspect(url)
|
||||
case .failure(let error):
|
||||
if let cocoa = error as? CocoaError, cocoa.code == .userCancelled {
|
||||
return
|
||||
}
|
||||
selectionError = "The selected file could not be opened: \(error.localizedDescription)"
|
||||
}
|
||||
}
|
||||
|
||||
func inspect(_ url: URL) {
|
||||
selectionError = nil
|
||||
fileName = url.lastPathComponent
|
||||
busy = true
|
||||
Task {
|
||||
@@ -691,9 +713,12 @@ struct InspectorView: View {
|
||||
var body: some View {
|
||||
Section("Executable inspection (read-only)") {
|
||||
HStack {
|
||||
Button("Open Executable…") { model.importing = true }
|
||||
Button("Open Executable…") { model.requestImport() }
|
||||
Text("or drop a file on this window").foregroundStyle(.secondary)
|
||||
}
|
||||
if let error = model.selectionError {
|
||||
Text(error).foregroundStyle(.red)
|
||||
}
|
||||
if let name = model.fileName {
|
||||
LabeledContent("File", value: model.busy ? "\(name) (inspecting…)" : name)
|
||||
ScrollView {
|
||||
@@ -823,7 +848,7 @@ struct ContentView: View {
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.fileImporter(isPresented: $inspection.importing, allowedContentTypes: [.item]) { result in
|
||||
if case .success(let url) = result { inspection.inspect(url) }
|
||||
inspection.importFinished(result)
|
||||
}
|
||||
.dropDestination(for: URL.self) { urls, _ in
|
||||
guard let url = urls.first, url.isFileURL else { return false }
|
||||
@@ -841,6 +866,12 @@ struct BetterXenApp: App {
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup("BetterXen") { ContentView(model: model, loop: loop) }
|
||||
.commands {
|
||||
CommandGroup(after: .newItem) {
|
||||
Button("Open Executable…") { InspectionModel.shared.requestImport() }
|
||||
.keyboardShortcut("o")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1009,6 +1040,31 @@ if CommandLine.arguments.contains("--smoke-frame") {
|
||||
exit(frame.status == XENORA_OK ? 0 : 1)
|
||||
}
|
||||
|
||||
// `--smoke-import-result` checks how a file-importer result reaches the inspector:
|
||||
// a cancelled picker shows nothing, a failure is shown, and a new selection clears it.
|
||||
// No file is opened or read.
|
||||
if CommandLine.arguments.contains("--smoke-import-result") {
|
||||
let ok = MainActor.assumeIsolated { () -> Bool in
|
||||
var failures: [String] = []
|
||||
let model = InspectionModel()
|
||||
model.importFinished(.failure(CocoaError(.userCancelled)))
|
||||
if model.selectionError != nil || model.fileName != nil { failures.append("cancel shows a message") }
|
||||
model.importFinished(.failure(CocoaError(.fileReadNoPermission)))
|
||||
if model.selectionError == nil || model.fileName != nil { failures.append("failure is not shown") }
|
||||
model.requestImport()
|
||||
if model.selectionError != nil || !model.importing { failures.append("reopening keeps the old message") }
|
||||
model.importFinished(.failure(CocoaError(.fileReadNoPermission)))
|
||||
model.inspect(URL(fileURLWithPath: "/nonexistent/import-result-check"))
|
||||
if model.selectionError != nil || model.fileName != "import-result-check" {
|
||||
failures.append("a new selection keeps the old message")
|
||||
}
|
||||
for failure in failures { print("smoke-import-result: FAILED \(failure)") }
|
||||
return failures.isEmpty
|
||||
}
|
||||
print("smoke-import-result: \(ok ? "ok" : "failed")")
|
||||
exit(ok ? 0 : 1)
|
||||
}
|
||||
|
||||
// `--smoke` prints the probe and exits without opening a window, for scripts and CI.
|
||||
if CommandLine.arguments.contains("--smoke") {
|
||||
let probe = RuntimeProbe.run()
|
||||
|
||||
@@ -72,4 +72,5 @@ for dependency in $dependencies; do
|
||||
esac
|
||||
done
|
||||
"$binary" --smoke
|
||||
"$binary" --smoke-import-result
|
||||
echo "build-app: built $bundle"
|
||||
Reference in new issue
Block a user