Skip to content

feat(settings): add in-process settings panel and CSA fixes - #5

Merged
tkgstrator merged 13 commits into
developfrom
feat/settings-ui-and-csa-fixes
Jun 18, 2026
Merged

feat(settings): add in-process settings panel and CSA fixes#5
tkgstrator merged 13 commits into
developfrom
feat/settings-ui-and-csa-fixes

Conversation

@tkgstrator

Copy link
Copy Markdown
Contributor

What

  • Add in-process settings panel (right-edge swipe) mirroring KiouForge's architecture
  • Settings_Persistence: NSUserDefaults-backed accessors for auto-rematch, auto-start kind, CSA port, eval overlay
  • Settings_UI: UITableViewController with Done button, UITableViewCellStyleValue1 stepper rows, drill-down auto-start picker, About section with GitHub/Author links
  • Makefile: add UIKit to FRAMEWORKS (was crashing at runtime); adopt FINALPACKAGE-based -dbg version suffix
  • Hook_MatchModeObserve: read rematch toggle and step delays from Settings_Persistence
  • Tweak.m: read CSA port from settings; wire KEBSettingsInstall
  • Csa_Engine/Csa_GameInfo: expose and emit Remaining_Time+/- on reconnect
  • Meta_Emitter: stop pushing meta lines onto the CSA socket — they caused the engine to disconnect on every observed move

Why

The UIKit crash (missing FRAMEWORKS entry) caused random crashes on launch. The meta-over-CSA bug caused engine disconnects after every injected move.

Test plan

  • App launches without crash (UIKit linked)
  • Right-edge swipe opens settings panel
  • Auto-rematch toggle / step delays / CSA port / eval overlay persist across restarts
  • Auto-start drill-down works
  • Engine stays connected across multiple moves (no meta disconnect)
  • Reconnect Game_Summary includes Remaining_Time+/- when clocks are available
  • Debug build shows version as 0.1.1-dbg; FINALPACKAGE build shows 0.1.1

🤖 Generated with Claude Code

- add Settings_Persistence.m/.h: NSUserDefaults-backed accessors for
  auto-rematch, auto-start kind, CSA port, and eval overlay
- add Settings_UI.m: right-edge swipe settings panel mirroring
  KiouForge's architecture (UITableViewController + KEBPresentSettings)
- Makefile: add UIKit to FRAMEWORKS; adopt FINALPACKAGE-based -dbg
  version suffix matching KiouForge
- Hook_MatchModeObserve: read auto-rematch toggle and step delays from
  Settings_Persistence instead of hard-coded values
- Tweak.m: read CSA port from Settings_Persistence; wire KEBSettingsInstall
- Csa_Engine.h/.m: expose g_csaLastBlack/WhiteRemainSec for reconnect
- Csa_GameInfo.m: emit Remaining_Time+/- in reconnect Game_Summary
- Meta_Emitter.m: stop pushing meta lines onto the CSA socket — they
  caused the engine to disconnect on every observed move
- bump version to 0.1.1

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 18, 2026 11:02

Copilot AI 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.

Pull request overview

This PR adds an in-process (in-app) settings panel with NSUserDefaults persistence and integrates those settings into CSA/auto-rematch behavior, alongside CSA protocol robustness fixes and build/versioning tweaks to prevent runtime crashes and improve traceability.

Changes:

  • Added Settings UI (right-edge swipe) + NSUserDefaults-backed persistence for rematch timing, CSA port, auto-start kind, and eval overlay toggle.
  • Updated runtime behavior to respect persisted settings (CSA server port, auto-rematch enable + step delays) and removed meta lines from being pushed over CSA to prevent engine disconnects.
  • Enhanced CSA reconnect Game_Summary to include Remaining_Time+/- when available; updated Makefile/framework linkage and version suffixing.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Sources/KiouEngineBridge/Tweak.m Reads CSA port from settings, delays CSA server start, installs settings gesture entry point.
Sources/KiouEngineBridge/Settings_UI.m Implements the in-process settings panel (table UI + right-edge gesture).
Sources/KiouEngineBridge/Settings_Persistence.m Adds NSUserDefaults getters/setters for all user-facing settings.
Sources/KiouEngineBridge/Settings_Persistence.h Declares the settings persistence API and KEBAutoStartKind model.
Sources/KiouEngineBridge/Meta_Emitter.m Stops pushing meta frames onto the CSA socket (log-only).
Sources/KiouEngineBridge/Internal.h Adds version macro default and declares KEBSettingsInstall().
Sources/KiouEngineBridge/Hook_MatchModeObserve.m Reads auto-rematch toggle and step delays from settings.
Sources/KiouEngineBridge/Csa_GameInfo.m Emits Remaining_Time+/- on reconnect when cached values exist.
Sources/KiouEngineBridge/Csa_Engine.m Exposes remaining-time cache globals for reconnect summary emission.
Sources/KiouEngineBridge/Csa_Engine.h Declares extern remaining-time cache globals for other modules.
Makefile Links UIKit and sets KIOU_ENGINE_BRIDGE_VERSION with -dbg suffix logic.
control Bumps package version to 0.1.1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/KiouEngineBridge/Internal.h Outdated
Comment thread Sources/KiouEngineBridge/Settings_UI.m Outdated
Comment thread Sources/KiouEngineBridge/Settings_Persistence.m Outdated
Comment thread Sources/KiouEngineBridge/Settings_Persistence.m
Comment thread Sources/KiouEngineBridge/Csa_Engine.m Outdated
Comment thread Sources/KiouEngineBridge/Csa_Engine.h Outdated
tkgstrator and others added 12 commits June 18, 2026 11:09
…op unimplemented eval overlay

Fires `StartCpuFreeMatchAsync` or `StartRankMatchingAsync` once on the first
`GameOrchestrator.ActivateAsync` (= launch reaching the match scene), using the
`KEBAutoStartKind` preference. Subsequent activations are rematch cycles that
manage their own restart path.

Removes the placeholder eval-overlay setting (header, persistence, and UI section)
that had no effect; avoids shipping a dead toggle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…s own section

Drop KEBAutoStartKind enum, persistence helpers, and the drill-down
KEBAutoStartKindViewController. Move rematch delay rows out of the Match
section into a dedicated Delay section, and shorten cell titles.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `KEBResignSkipDialog` setting (default true) that controls whether
`%TORYO` bypasses the "投了しますか?" dialog via `SurrenderAsync`, or
shows it via `GameOrchestrator.RequestSurrender`. Resolves both function
pointers at once and dispatches based on the toggle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… unblock MoveCountPresenter

In the CPUStream path NotifyPieceMoved fires but NotifyStateSynced is never
called, leaving MoveCountPresenter stale. Resolve the GameStateStore method by
RVA, cache the last store instance from SetBlackPlayerInfo / SetWhitePlayerInfo
/ NotifyPieceMoved, and call NotifyStateSynced with the latest Position whenever
TryMakeMoveOut succeeds on the opponent side.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mechanical find-and-replace of every `BINPATCH`/`binpatch`/`BinpatchDispatcher` symbol
to `CHINLAN`/`chinlan`/`ChinlanDispatcher`. Covers the Makefile target and output path,
the preprocessor guard `KIOU_CHINLAN`, all `KIOU_BR_CHINLAN_*` helper macros, the
dispatcher source file, and every comment and log string that referenced the old name.
No logic change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…alMove

Add `KIOU_ROUTE_MATCH_CTRL` that calls `MatchController.TryMakeLocalMove` —
the same entry point a real on-screen tap drives. This runs the full commit
pipeline (SetCurrentPosition, NotifyPieceMoved, NotifyStateSynced, timer flip)
from inside a single call, replacing the half-reproduction of calling OPM
directly then poking GameStateStore by hand.

Also call `SetCurrentPosition` before `NotifyStateSynced` in the existing
state-sync hook so `MoveCountPresenter` (which subscribes to the
`CurrentPosition` ReactiveProperty, not the `_onStateSynced` Subject) updates
correctly on the fallback OPM routes. Remove the now-redundant manual
`HookGStateNotifyStateSyncedForCurrentPosition` call from the CPU-stream path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Move

UniTask<bool> is a struct larger than 16 bytes, so AAPCS64 lowers its
return via a hidden sret pointer in x0. The previous typedef treated the
return as a two-register UniTaskRet, shifting every argument by one
register: `self` landed in x1, `move` in x2, causing the move bits to
be misread (promotion dropped, moving side flipped).

Fix by changing the typedef to `void` return with an explicit `void *sret`
first parameter, and passing a 64-byte aligned stack buffer as the sret
destination.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…p double animation

UniTask<bool> fits in two registers on this build, so the sret path was
wrong; revert to the standard UniTaskRet trampoline signature.

Skip the external PlayMoveAnimation trigger when routing through
match_ctrl — TryMakeLocalMove drives the animation internally, and
firing it again caused the move to render in the opponent's colour with
the promotion bit dropped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bundles the CSA UI / TryMakeLocalMove route / chinlan rename work
on this branch into a single release. Pre-1.0 so feature work bumps the
patch field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirrors the source-side rename in c45020e: `make binpatch` no longer
exists, so CI fails with 'No rule to make target binpatch'. Update both
the integration matrix (build job + sanity check) and the deployment
workflow (build step + artefact path + staged dylib name) to invoke
`make chinlan` and to publish dylibs out of packages/chinlan/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Internal.h: KEBSettingsInstall comment said left-edge but Settings_UI installs
  a right-edge gesture. Correct the doc.
- Settings_UI.m: iterate connectedScenes as UIScene * and cast to UIWindowScene *
  after the kind-of-class check to avoid the incompatible-pointer warning.
- Settings_Persistence.m: drop the per-write -synchronize calls (deprecated, not
  guaranteed to flush, adds main-thread I/O) and fix the header comment to
  match the actual flat `kiou_bridge.<name>` key namespace.
- Csa_Engine.h/m: switch g_csaLastBlackRemainSec / g_csaLastWhiteRemainSec from
  `float volatile` to `_Atomic float` so the cross-thread (Unity main thread
  writer, CSA accept-queue reader) access has a defined memory model. Update
  the local cacheSlot pointer accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tkgstrator
tkgstrator merged commit acedbcb into develop Jun 18, 2026
4 checks passed
@tkgstrator
tkgstrator deleted the feat/settings-ui-and-csa-fixes branch June 18, 2026 23:27
tkgstrator added a commit that referenced this pull request Jun 22, 2026
Three commits land in Bridge through this bump:
  9dde9ea feat(logging): rotate the sandbox file log into a Logs/ subdirectory (#5)
  e3695dc docs(CAVES): address Copilot review nits from #3 (#6)
  plus PR #2 / #1 / #3 ancestry already on Chinlan develop.

The behavior change Bridge actually inherits is the log rotation:
sandbox log moves from <base>/<tag>.log to <base>/Logs/<tag>.log
(PascalCase to match Documents/ / Library/) and rotates at 4 MiB across
3 generations. The remaining commits are docs only.

No Bridge-side code change is needed — Chinlan's public API
(IPALog / IPALoggingInit / IPALogServerStart) is unchanged.

Builds: JB + chinlan both clean against the bumped submodule.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
tkgstrator added a commit that referenced this pull request Jun 23, 2026
Three commits land in Bridge through this bump:
  9dde9ea feat(logging): rotate the sandbox file log into a Logs/ subdirectory (#5)
  e3695dc docs(CAVES): address Copilot review nits from #3 (#6)
  plus PR #2 / #1 / #3 ancestry already on Chinlan develop.

The behavior change Bridge actually inherits is the log rotation:
sandbox log moves from <base>/<tag>.log to <base>/Logs/<tag>.log
(PascalCase to match Documents/ / Library/) and rotates at 4 MiB across
3 generations. The remaining commits are docs only.

No Bridge-side code change is needed — Chinlan's public API
(IPALog / IPALoggingInit / IPALogServerStart) is unchanged.

Builds: JB + chinlan both clean against the bumped submodule.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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