Skip to content

App state and save over the protocol (version 6) - #58

Open
vadi2 wants to merge 3 commits into
ccr-14671218-tf96z6-p4-links-protocolfrom
ccr-14671218-tf96z6-p5-app-state
Open

vadi2 wants to merge 3 commits into
ccr-14671218-tf96z6-p4-links-protocolfrom
ccr-14671218-tf96z6-p5-app-state

Conversation

@vadi2

@vadi2 vadi2 commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Brief overview of PR changes/additions

  • New request setAppState (active, minimized). libmudlet passes them to setApplicationActive(), which raises sysApplicationFocusChangeEvent, and to setWindowMinimized(). When active turns false, it saves the profile with saveAsync() and reports status save.
  • EngineService.onTrimMemory() saves too, through the new JNI call EngineNative.nativeSave(), which is covered by the existing R8 rule.
  • A switch or quit asked during a save now waits for the save to finish, because Mudlet refuses to close a profile while it saves.
  • New message attention (ms), from attentionRequested: alert(), the bell, and game text that arrives while the app is minimized.
  • New message moveTypedLine, from typedLineMoveRequested. EngineClient holds it as moveTypedLine, which typedLineMoved() clears. It is not wired into InputLine.kt.
  • The stand-in accepts setAppState and does nothing with it. The protocol is now version 6.

Motivation for adding to Mudlet

Android kills background processes without warning. Saving when the app leaves the front, or when memory is short, keeps the player's changes. U8 sends setAppState and acts on attention.

Other info (issues closed, discussion etc)

Part of Mudlet/Mudlet#9011
Stacked on #50 (on #43); merge order #43, #50, this. The brief expected "new data while minimized" to send notify. Upstream sends attentionRequested(0) for it, so the test checks attention 0. Roadmap rows will be added after the rebase onto main.
Checked: stand-in test_engine.py, Kotlin protocol tests, ktlint, clang-format, ShellCheck; CI: https://github.com/Mudlet/android/actions/runs/43662532818; bite: https://github.com/Mudlet/android/actions/runs/43662592279; device-only: the onTrimMemory save on a real phone (the emulator smoke test sends am send-trim-memory).

🤖 Generated with Claude Code

https://claude.ai/code/session_016ujaeFyaqXXDx8xjoThE6J

The UI tells the engine whether the app is in front with setAppState
(active, minimized). Leaving the front raises Mudlet's
sysApplicationFocusChangeEvent and saves the profile, as the system may
kill a background process without warning; onTrimMemory saves it too,
through EngineNative.nativeSave(). A switch or quit asked during a save
waits for it, as Mudlet refuses to close then.

The engine sends attention (ms) for alert(), the bell and new text while
minimized, and moveTypedLine ahead of hiddenInput when the typed line is
to move into the masked one. EngineClient keeps that as state for the
input line to act on. The stand-in accepts setAppState and ignores it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ujaeFyaqXXDx8xjoThE6J
…anch

A switch asked while the app-state save runs is now checked in the host
test: Mudlet refuses to close during a save, so the switch has to wait
for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ujaeFyaqXXDx8xjoThE6J
Notify on new data while minimized is on by default (Host::mAlertOnNewData),
so the save holds mAlertOnNewData="yes" and the rewrite to turn it on did
nothing. The typed-line order also caught the hiddenInput (wanted false)
every client is sent on attaching; only the one asking for hidden input
follows moveTypedLine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ujaeFyaqXXDx8xjoThE6J
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