Repository navigation
hle, app, docs: implement XGameUi message and error dialogs - #26
Conversation
simnJS
left a comment
There was a problem hiding this comment.
Thanks for picking up #8. The ABI matches the public XGameUI.h docs and the slot table, the in-memory template is correctly aligned, and keeping the real dialogs out of test builds is the right approach. A few things need to change before this can land:
-
cancelButton(blocking). The docs definecancelButtonas "the button that represents the cancel action", andresultButtonas the button the user selected. Esc and the close box should complete withS_OKand reportcancel_button. KeepE_ABORTfor "could not show the dialog" (and forXAsyncCancel). Right nowcancel_buttonis only logged (L63/L81) and is missing fromMessageDialogRequest, and Esc/close giveE_ABORT(L406–410, L418–421). -
Button indices (blocking). Dropping null or empty labels (L68–72) changes the index you report: with
first = null, second = "OK", clicking OK returnsFirst. Please keep each visible button's enum value with its label, useBTN_BASE + valueas the control id, and comparedefault_buttonandcancel_buttonagainst those values. -
Default button. Returning 1 from
WM_INITDIALOG(L398–401) puts the focus on the first tab stop, so button 0 becomes the effective default and Enter picks it. PleaseSetFocusthe default button and return 0, asdialog::askdoes. -
Unattended runs (blocking for us). XTP runs unattended sessions (
--autopilot, cloud runs), and nothing there can answer a Win32 modal dialog, so a title that waits on the error dialog would stall. Until now these slots returnedE_NOTIMPLat once. Please add a switch that answers without opening a window and logs a warning:- the message dialog completes with
cancel_button(S_OK); - the error dialog completes with
S_OKat once.
For example, an
XTP_DIALOGS=autovariable (the name is open to discussion), documented in the README. Please also turn it on in autopilot runs; if you prefer, we can file the autopilot wiring and text entry as a follow-up, but the switch should exist when these dialogs land. - the message dialog completes with
-
Tests. The
assert_eq!calls inside the hooks (L680–681, L735–736) run on the xasync worker thread. If one fails, that thread panics, the call never completes, andXAsyncGetStatus(.., true)hangs the CI job instead of failing it. Have the hook only record the request and return the answer, then assert on the test thread after completion. Please also cover:- the third button;
- Esc mapping to
cancel_button; - labels with a gap (a null second button);
- the default button.
Smaller points:
- add
SS_NOPREFIXto the content label, and consider&in button captions; - the 40-unit content label clips long text;
return E_INVALIDARGreads better thanput(null, 0)at L112;- please mark R5 in
docs/analysis/hle.md:176.
Thanks for disclosing the AI help, and for the honest "untested live" in the README. We found a separate cancel issue in xasync::pending_with on main while reviewing this; we'll fix that on our side, so you don't need to.
|
Addressed all review items:
|
d744941 to
c309096
Compare
simnJS
left a comment
There was a problem hiding this comment.
Thanks, this addresses all the blocking points:
cancel_buttonwithS_OKon Esc and the close box;- button values kept across gaps;
- focus on the default button;
XTP_DIALOGS=auto, wired into--autopilot.
The tests now assert only on the test thread.
Before merge:
- Please update the branch onto current main. CI ran against c38f95c, which predates the xasync cancel fix (4100a24) and #23/#25, so we need a green run on main.
- Please refresh the PR description. It still says dismissing gives
E_ABORTand quotes 451 lines (it is now +635/−23, about 211 of them tests), and the Area list is missingapps/xtp/src/run.rsanddocs/analysis/hle.md.
Small things, here or as a follow-up:
- The module doc (L2-5) now implies that text entry only aborts when it can't open, but Cancel/Esc still returns
E_ABORT. - Long content is still clipped at 66 DLU; a read-only multiline edit with a scroll bar would do.
- Mark R5 "(done)" in its section heading and in the order table too, as was done for R7.
- The Esc and default-button tests go through the fake, so
message_proc's mapping is untested; small pure helpers would make it testable.
As a follow-up: text entry still opens a window under XTP_DIALOGS=auto and --autopilot, so either cover it or reword the doc at L37.
fogydes
left a comment
There was a problem hiding this comment.
Independent maintainer review of head c309096f (base c38f95ca0), full diff read, CI state checked, xasync API compared against current main (df510eee4). This PR is the only eligible open PR right now; #28 is owned by a separate reviewer.
What I verified as correct (static, from the diff)
- Slots and ABI. 0x18/0x20 = message dialog async/result, 0x70/0x78 = error dialog async/result, matching the existing vtable comments.
XGameUiShowMessageDialogAsynctakes the three button labels plusdefault_button/cancel_buttonasu32(the GDK enum is 4 bytes); the result is written as a 4-byteXGameUiMessageDialogButton.message_dialog_resultrejects a null out-pointer withE_INVALIDARGand otherwise follows the exactXAsyncGetResultpattern of the existingtext_entry_result;error_dialog_resultmirrorsprofile_card_result(0/null/null). No ABI issues found. - Cancel semantics. Esc (
IDCANCEL) and the close box (WM_CLOSE) now complete withS_OKand reportcancel_button;E_ABORTis reserved for "could not open a window" — matches the publicXGameUI.hdocs. The unit test pins Esc →cancel_button. - Button indices.
MessageDialogRequest::buttonskeeps each visible button's original enum value next to its label and usesBTN_BASE + valueas the control id, so a null/empty label never shifts the reported index;message_procmaps the control id back and only accepts ids inbutton_ids. The gap case (null second button → third still reportsBUTTON_THIRD) is tested. - Default focus.
WM_INITDIALOGcallsSetFocuson the default button (falling back to the first visible) and returns 0, same as the existingdialog::ask. - Unattended runs.
XTP_DIALOGS=auto(documented in the README variable table) plusxgameui::set_auto_dismiss(true)wired into--autopilotinapps/xtp/src/run.rs: message dialogs complete immediately withS_OK+cancel_button, error dialogs withS_OK, both with awarn!log and no window. This closes the stall risk for autopilot/cloud runs. - Template construction. The in-memory
DLGTEMPLATE/DLGITEMTEMPLATElayout (DWORD alignment before each item,0xFFFFclass atoms, creation-count 0,SS_NOPREFIXon the content label,&&escaping in button captions) follows the existingdialog::askpattern and is consistent. - Tests. Hooks are
#[cfg(test)]-only, the real dialogs#[cfg(not(test))]; tests serialize onTEST_LOCKand only record (not assert) on the worker thread. Coverage includes button gaps, default/cancel, auto-dismiss, and the no-windowE_ABORTpath. No game files needed; synthetic only. - Policy/provenance. Win32 host APIs only, no game data, no console SDK material, no xcl/AnyPS5 code; AI assistance disclosed. New
windows-sysusage is inside existing features already enabled for the crate.
Still blocking at this head (concurs with the code owner's CHANGES_REQUESTED)
- Rebase onto current main. Base
c38f95ca0predates the xasync cancel fix (4100a24: a cancelledpending_withworker no longer touches a reused block) and the #23/#25 merges. I comparedxasync.rsatc38f95ca0vsmain: the public API this PR uses (pending_with,finished,XAsyncGetResult,XAsyncGetStatus,AsyncBlock) is signature-identical, so I expect no code change — but the green run 45472476499 testedc309096fagainst the then-main, not today'sdf510eee4. The cancel fix is directly relevant to this PR's dialog workers, so a green CI run on the rebased merge is required evidence, not a formality. (mergeableis currentlytrue.) - PR description is stale at
c309096f. It still says dismissing a message dialog completes withE_ABORT(nowS_OK+cancel_button), still quotes "451 changed lines" (actual: +635/−23), and the Area list is missingapps/xtp/src/run.rsanddocs/analysis/hle.md.
Minor, non-blocking
docs/analysis/hle.md: only the comparison-table row is marked "Done (R5)"; the### R5.section heading and the order-table row still read as open — please mark those too, as was done for R7 in #23.- The module doc still implies text entry only aborts when it cannot open; Esc/Cancel on text entry still returns
E_ABORT(or reword). message_proc's id→button mapping is only exercised through the fake; small pure helpers would make it directly testable. Long content is still clipped at 66 DLU.
CI state
All required checks pass on head c309096f (run 45472476499: fmt, clippy, clippy-diagnostics, test, policy, conventions, actionlint, conflicts, labels, overlap; welcome skipped as a returning contributor). Note this run predates main moving to df510eee4 — see blocker 1. Green CI here is static/build evidence only; it says nothing about runtime dialog behavior.
Remaining runtime verification
The description says "Ran on the title: no". Still to verify on a real host: an actual message dialog render/click-through, Esc and close-box paths in the real message_proc, and XTP_DIALOGS=auto under --autopilot in a real unattended session. None of this is covered by the unit tests, which use hooks.
|
This pull request now conflicts with its base branch. Please rebase it on |
fogydes
left a comment
There was a problem hiding this comment.
Independent review follow-up (head unchanged at c309096f4; my full review of this head is #pullrequestreview-6047220994). Since then main moved to 8d503f912 and this PR now reports CONFLICTING/DIRTY, so the rebase blocker from that review is now concrete: please rebase onto current main (which includes the 4100a24 xasync cancel fix your dialog workers rely on) and get a fresh green CI run on the rebased head before this can merge. The stale-description point also still stands (dismiss is now S_OK + cancel_button, not E_ABORT; area list is missing apps/xtp/src/run.rs and docs/analysis/hle.md). No new code findings at this head.
c309096 to
95f0f65
Compare
|
Rebased cleanly onto current Also addressed the minor follow-ups:
|
|
Thanks, this addresses everything from both rounds: Esc and the close box report We'll approve once Follow-ups, not blocking:
|
simnJS
left a comment
There was a problem hiding this comment.
Thanks for the rebase and the follow-ups. Everything from the last round is addressed: the branch is now on a main that includes the xasync cancel fix, the description matches the code, the module doc and README say text entry is not auto-dismissed, R5 is marked done in its heading and in the order table, and focus_button_id/command_to_button let the tests cover message_proc's mapping directly.
I compared the new head with c309096: apart from the rebase, the only changes are the extracted helpers, their test and the doc fixes, so the earlier checks still hold.
CI: the required checks pass. gpu-debug-layer was cancelled at its 60-minute limit while stuck in an xtp-gpu test (descriptor::host::tests::a_translated_program_reads_and_writes_through_the_heaps_table). That job only runs the xtp-gpu tests, which don't depend on xtp-hle, so this PR didn't cause it. I'm updating the branch from main for a clean run and will merge once it is green.
A follow-up, not blocking: long content is still clipped at 66 DLU (xgameui.rs ~L436). A read-only multiline edit with a vertical scroll bar would show all of it.
Approving. Thanks for the careful iterations.
|
Other open pull requests change the same files. Check that they do not do the same work, and agree with their authors on which lands first: the other one will then need a rebase.
This comment is kept up to date automatically and removed when the overlap ends. |
What and why
Implement
XGameUiShowMessageDialogAsync/Result(slots0x18/0x20) andXGameUiShowErrorDialogAsync/Result(slots0x70/0x78) incrates/xtp-hle/src/modules/xgameui.rs:xasync::pending_with, show an in-memory Win32 modal dialog (DialogBoxIndirectParamW) with up to three buttons, preserve each visible button's originalXGameUiMessageDialogButtonenum value (0,1,2) across null/empty label gaps, focusdefault_buttoninWM_INITDIALOG, escape&mnemonics, and return the chosen button (S_OK). Pressing Esc or closing the window completes withS_OKandcancel_button;E_ABORTis returned only when no window can be opened (or onXAsyncCancel).xasync::pending_with, log theHRESULTand context, show a modalMessageBoxWerror dialog, and complete withS_OKwhen dismissed orE_ABORTwhen no window can be opened.XTP_DIALOGS=auto(orxgameui::set_auto_dismiss(true), enabled automatically under--autopilotinapps/xtp/src/run.rs) logs a warning and completes message dialogs immediately withS_OK+cancel_buttonand error dialogs withS_OK, without opening a window (text entry is unaffected).Size note: +699/−25 changed lines across 4 files (including ~250 lines of unit tests, the in-memory Win32 dialog template/procedure,
XTP_DIALOGS=auto+--autopilotwiring, and docs).Fixes: #8
Depends on: none
Area
crates/xtp-hle/src/modules/xgameui.rsapps/xtp/src/run.rs(enablexgameui::set_auto_dismiss(true)under--autopilot)README.md(update "Runtime services" row and documentXTP_DIALOGS=auto)docs/analysis/hle.md(mark R5 done)Tests
cargo xtask pr-checkpasses on my machineUnit tests in
crates/xtp-hle/src/modules/xgameui.rs(asserting only on the test thread, with worker hooks recording requests into aMutex):message_dialog_buttons_gaps_default_cancel_and_auto_dismiss: verifies button 2 (BUTTON_SECOND), button 3 (BUTTON_THIRD) across a null-second-button gap,default_buttonandcancel_buttonpropagation, Esc ->cancel_button(S_OK), nullresult_buttonreturningE_INVALIDARG, unattended auto-dismiss returningcancel_button(S_OK), headless/no-window returningE_ABORT, and&mnemonic escaping.error_dialog_completes_auto_dismisses_or_cancels_without_window: verifies normal dismissal (S_OK), auto-dismiss (S_OK), and no-window (E_ABORT).message_proc_helpers_map_focus_esc_and_gapped_buttons: directly testsfocus_button_id(default button and fallback) andcommand_to_button(Esc ->cancel_button, visible gapped button, absent button ignored).Provenance
Written from scratch for XTP following the existing
dialog::askin-memory Win32 dialog pattern inxgameui.rsand public Microsoft Learn documentation forXGameUI.h. Neither I nor the AI assistant read xcl'sapi.rs.AI assistance: Antigravity assisted with implementation, review fixes, and unit tests; all changes were reviewed and verified locally.
Checklist
<area>: <summary>; one topic; under 400 changed lines, or the reason is above