Commit Graph
33 Commits
Author SHA1 Message Date
M57andM57 3fd9ac767f feat(ws): adopt event replay via session.events.since on reconnect (#1016) (#1027)
Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-31 19:32:17 +03:00
M57andM57 cfe3e736fd chore: upgrade ktlint to 1.8.0 and format codebase (#1024)
Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-31 12:27:40 +03:00
AlexDev_ 0ae5ed4db2 feat(chat): stabilize multi-image attachment picker (#986) 2026-08-27 10:50:55 +03:00
M57andhy4ri bb400881e6 ws: harden HermesWsClient (stale-socket watchdog, JSON ticket parse, dead-branch removal) (#954)
* ws: watchdog cancels stale sockets to trigger reconnect

* ws: parse ws-ticket response with kotlinx.serialization

* ws: remove unreachable buffer-overflow warning

* style: ktlint format ws client tests

---------

Co-authored-by: hy4ri <hy4ri@users.noreply.github.com>
2026-08-22 18:49:50 +03:00
M57andM57 82e2d787af fix(sessions): show fork icon + order number on nested forked sessions (#934)
* fix(sessions): fork icon + depth number, no indentation

Multiply-nested forked sessions rendered with deep indentation that crushed
the card off-screen and made titles unreadable, and the per-sibling order
number was uninformative (mostly "1").

- SessionTreeItem: replace forkIndex (sibling order) with forkDepth (nesting
  level: 1 = child of a root, 2 = fork of a fork, ...); flattenSessionTree
  populates it.
- SessionCard: render CallSplit fork icon + the depth number (primary tint).
  Removed the depth-based start padding so names stay full-width readable —
  the icon+number now carries the structure instead of indentation.
- strings: sessions_fork_indicator (en/zh/ko).
- SessionTreeTest: assert isFork/forkDepth across nested fixtures.

No backend change — backend already returns parent_session_id per SessionInfo.

* test(ws): make testAutoReconnect tolerate transient RECONNECTING state

The test gated on connectionStatus.first { it == RECONNECTING } with a
15s timeout. With the test backoff forced to 0ms the RECONNECTING state is
emitted + consumed before the collector attaches, so the wait missed it and
timed out (kotlinx.coroutines.TimeoutCancellationException) — the flake CI
saw under parallel load.

- Replace the brittle RECONNECTING .first{} wait with a tolerant check that
  accepts RECONNECTING-or-later (the reconnect clearly fired).
- Keep connect2Latch (second socket opening) as the definitive proof + add a
  final CONNECTED assertion.
- Reset the test backoff in a finally so later tests never inherit 0ms.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-18 17:06:51 +03:00
M57andM57 acd82c0085 feat(#919): adopt session.usage WS push event for real-time context & compression updates (#927)
Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-17 23:31:07 +03:00
M57andM57 90c1e8dc5f fix: tab reloads actually reload — kanban switch spam, plugins/skills refresh, ws mint (#897)
- ws: ticket-mint response body was read on the calling (main) thread —
  the socket read threw NetworkOnMainThreadException, the mint failed,
  and the kanban events stream never connected (board stuck Offline).
  execute() + body read now run entirely on Dispatchers.IO; same fix in
  DashboardSessionTokenRefresher.fetch (loopback mint path).
- kanban: re-selecting the already-active board reloads data and
  reconnects events WITHOUT the redundant POST /boards/{id}/switch that
  refresh fired on every tap.
- plugins: top-bar Refresh + pull-to-refresh wired through HermesScaffold
  (previously no reload control at all).
- skills: Refresh icon now does a plain GET reload; the heavy hub-update
  POST moved to the cloud icon so refresh is no longer disguised as update.
- test: mock the 3-arg Log.w overload (catch now logs the full stack).

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-13 14:27:36 +03:00
AlexDev_ 3b033a025b fix(notification): disconnect idle background socket (#858)
* fix(notification): disconnect idle background socket

* fix(notification): clear rejected prompt state
2026-08-09 12:06:59 +03:00
M57andM57 f34bfa7cf8 feat(ws): consume gateway change events (issue #784) (#837)
* feat(ws): consume gateway change events (cron/sessions/platforms/pairing) for targeted refresh (issue #784)

* test(chat): complete catch-all request stub — kill frozen-collector capture race (slash-focus flake, 4645a2b CI)

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-07 13:48:17 +03:00
M57andM57 d9f437939a test(connect): phase 5 — restart lands on the selected profile, no login (#827)
* test(connect): pin restart-with-scoped-profile token resolution (phase 5)

* fix(profiles): scope switch via un-clamped active-profile state

The switch persisted the server profile through serverStore.selectedProfileId,
whose selfHealed() clamps ids absent from the local connection list — server
profiles like "meow" never exist there, so the scope silently reset to
default and the re-dialed socket created the fresh session in the wrong
profile (live logcat 2026-08-06: session.create carried profile=default
right after switching to meow).

- AuthManager: prefs-backed activeProfileId state, immune to the clamp,
  restored on startup; resetAuthStateForTest clears it
- ProfileScopeInterceptor + WsProfileParams + ChatViewModel fetchContextUsage:
  read the active profile instead of the connection selection
- ProfileSwitchCoordinator: write activeProfileId; dial the socket on
  Dispatchers.IO (the ticket mint did blocking I/O on the main thread —
  NetworkOnMainThreadException — and fell back to a 1s reconnect)
- ProfilesViewModel: inject the IO dispatcher; ProfilesViewModelTest drops
  its static Dispatchers mock (JVM-wide bleed class)
- Tests: WsProfileParams/Interceptor tests use the real prefs-backed state
  instead of mockkObject(AuthManager) (re-mock breaks in suite order after
  real AuthManager init); AuthManagerTest + Issue647ProfileUrlTest cancel
  the init() DataStore scope in tearDown (UncaughtExceptionsBeforeTest
  phantoms); regression test pins the clamp on the old path vs the new state

* fix(profiles): resolve getter/property JVM collision; de-poison slash test

- AuthManager.activeProfileId (StateFlow) and a getActiveProfileId()
  function generated the same JVM getter name — calls silently resolved to
  the property getter at runtime (ReadonlyStateFlow -> String
  ClassCastException, CI unit red 2026-08-06). Function removed; callers
  read activeProfileId.value.
- ChatViewModel: inject ioDispatcher (38 sites) so SlashCommandDispatchRpcTest
  can drop its mockkStatic(Dispatchers) bleed without racing real IO.
- SlashCommandDispatchRpcTest: drop the static Dispatchers mock (JVM-wide
  bleed; CI cross-wired COMMAND_DISPATCH captures in suite order), construct
  the VM with the test dispatcher.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-06 15:07:35 +03:00
M57andM57 5808d57da3 test(ws): lock the profile-scoping invariant with an audit guard (phase 3) (#825)
Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-06 15:07:17 +03:00
M57andM57 531219cdb5 feat(profiles): phase 2 — atomic switch coordinator (#824)
* feat(profiles): ProfileSwitchCoordinator — atomic re-home on profile switch (phase 2)

* fix(ws): deterministic reconnect backoff in tests (testAutoReconnect flake)

* test(ws): harden testAutoReconnect against CI latency (stub token refresh, generous latches)

* test(profiles): remove static Dispatchers mock from coordinator test — it bled into HermesWsClientTest in full-suite runs

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-06 15:07:09 +03:00
M57andM57 75ac0c4790 feat(profiles): first-class profile switching — phase 0 baseline port (#820)
* feat(profiles): make profile switching actually scope the app (issue #781 follow-up)

* fix(profiles): inherit connection token when switching to same-dashboard profile (issue #781 follow-up)

* fix(chat): reset open session on profile switch + prefill login profile (desktop parity)

* fix(ws): inject profile into profile-scoped RPC params so chat follows the selected profile

* test(chat): de-poison SlashCommandDispatchRpcTest (drop static Dispatchers mock)

mockkStatic(Dispatchers::class) + a stubbed Dispatchers.IO bleeds JVM-wide and
breaks later classes in suite order (CI 2026-08-06: COMMAND_DISPATCH captures
cross-wired → ComparisonFailure on lower stack PRs). ChatViewModel gains an
injected ioDispatcher (38 sites); the slash test constructs the VM with the
test dispatcher so the IO stub is unnecessary.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-06 15:06:28 +03:00
AlexDev_ d1dac57ccb fix(ws): reconnect after network handover (#808) 2026-08-04 18:09:22 +03:00
M57andM57 44767fef4a feat(kanban): live board updates over plugin events WebSocket + kanban UI pass (#789)
* feat(kanban): live board updates over plugin events WebSocket (#775)

Tail /api/plugins/kanban/events per board with cursor tracking and
backoff reconnect; debounced REST reload on event batches (desktop's
proven pattern — event payloads are partial updates). Board switch
re-subscribes with a fresh stream. Reuses HermesWsClient's ticket
refresh (now internal). Adds ServerEndpoint.webSocketUrl(path, ...)
overload for non-chat WS endpoints.

Kanban UI pass: add-task FAB (the AddTaskDialog was unreachable),
live/offline status pill, assignee chip on task cards, 2-line
description clamp, empty-column hint.

Tests: KanbanEventsClient frame parsing, KanbanViewModel WS wiring
(connect on load, debounced reload, board-switch reconnect,
no-reconnect guard, onCleared), ServerEndpoint overload.

* fix(kanban): create task response is wrapped {"task": ...} — read it as Unit

Backend POST /api/plugins/kanban/tasks returns {"task": {...}} (wrapped),
but the app declared Response<KanbanTask> — with ignoreUnknownKeys=true
the wrapper key is skipped and the required id/title/status fields are
missing, so deserialization threw and the create showed a failure toast
while the task WAS created server-side (ghost tasks). The body is never
consumed by the ViewModel, so Response<Unit> matches updateKanbanTask.

FAB from the live-events PR (#775) made this latent bug reachable.
Adds an E2e regression assertion for the create path.

* feat(kanban): remove move left/right arrows — backend rejects the transitions

The dashboard PATCH route's status whitelist omits 'review' (a first-class
kanban_db status), so any move touching that column 400s, and reopen
transitions (done->blocked) 409. Every task on the live board sits in
'done', making the arrows 100% failure. Removing them keeps the UI honest;
tasks are managed from the desktop/CLI.

Drops moveTask/revertTaskMove from the VM, the arrows from TaskCard, the
now-dead updateKanbanTask API method and move strings; E2e test keeps
load/create coverage.

* feat(kanban): desktop-style task transitions — gated action sheet

Mirrors the desktop kanban's move model: tap a card to open an action
sheet with only the transitions the backend PATCH route accepts:

- triage / ready from any status (direct write; unblock from blocked)
- block only from running/ready, complete only from running/ready/blocked
- archive from any non-archived status
- never running (dispatcher-only, backend 400s) and never review (not in
  the dashboard whitelist) — the moves that made the old arrows lie

Complete prompts for a mandatory completion summary (stored as result),
matching the desktop; block/complete/archive ask for confirmation.
Optimistic update with revert + toast on failure.

Tests: transition-gating map, move PATCH body, failure revert, completion
summary body; E2e kanban test covers a desktop-style todo->ready move.

* ui(kanban): replace oversized FAB with compact top-bar add button

The 56dp FAB floated over the board's bottom-right corner and covered a
chunk of the last column. The add action now lives in the header row next
to the live pill (input-top style), and the board's bottom contentPadding
drops back to 16dp — no more reserved dead zone.

* fix(kanban): mint an independent WS ticket — don't touch the chat's shared slot

The dashboard WS ticket is single-use and consumed at handshake. Both the
chat client and the kanban events client were refreshing into the SAME
shared AuthManager token slot on their own schedules (the kanban client on
every backoff reconnect, forever). Whichever client built its URL second
grabbed the other's just-consumed ticket, got 1008, reconnected, and stole
the other's next ticket — mutual starvation that left the app stuck at
'Reconnecting...' (repro on main: none, because main has one consumer).

HermesWsClient now exposes mintWsTicket(): a ticket minted WITHOUT touching
the shared slot (cookie-auth'd, same endpoint). The kanban events client
uses its own ticket per connection; the chat WS keeps the shared slot.
Refresh's HTTP-error -> status mapping is preserved via a small result
holder.

* fix(kanban): drop orphaned ko translations for removed move buttons

The move arrows were removed earlier but values-ko still shipped
content_desc_move_left/right — Android lint ExtraTranslation failed CI.

* fix(ws): keep RECONNECTING on transient ticket-mint exceptions

My refactor flattened the ticket-mint failure mapping: a network exception
during POST /api/auth/ws-ticket was reported as a null HTTP code and
mapped to DISCONNECTED, breaking the #740 contract that transient failures
stay in RECONNECTING (and with it testGatedMode_transientTicketFailure-
KeepsReconnectFlow). TicketRequestResult now carries an exception flag and
refreshWsTicketIfNeeded maps it to RECONNECTING.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-08-03 18:19:08 +03:00
AlexDev_ e39544ebd5 fix: keep transient ticket failures reconnecting (#740)
* fix: keep transient ticket failures reconnecting

* fix: recover rejected websocket sends

* fix: serialize websocket reconnect scheduling
2026-07-28 22:33:12 +03:00
M57 5c1492a80e feat(chat): add animated GIF rendering with tap-to-play animation (#721) (#731)
* feat(chat): add animated GIF rendering with tap-to-play animation

Closes #721

* fix(#721): add missing GifImageThumbnail component and format ktlint

* fix(analytics): resolve ktlint indentation error in itemsIndexed

* feat(chat): add interactive play/pause toggle for animated GIFs

* fix(chat): control GIF playback via Animatable start and stop
2026-07-27 18:32:45 +03:00
M57andM57 a62bc7e16c refactor: remove device Pairing feature entirely (issue #645) (#650)
* refactor: remove device Pairing feature entirely (issue #645)

- Delete Pairing.kt model + pairing API endpoints (get/approve/revoke/clear)
- Delete PairingScreen/PairingViewModel + PairingCodeEntryScreen/ViewModel
- Remove NavKeys, ScreenRegistry drawer entry, Navigation.kt entry + Landing pairing button
- Remove pairing string resources (en + ko); keep connect_* config-parse strings
- Keep Telegram onboarding pairing_id flow (separate concept, per issue)
- Fix related doc comments + remaining test reference

* test: fix racy CONNECTED read in gated-mode WS test (issue #635 test)

testGatedMode_attemptsTicketFetchWithoutBareCookie asserted CONNECTED
immediately after the server-side onOpen latch fired, racing the client
handshake (WsListenerImpl sets CONNECTED on receipt of the 101). Await the
real status transition via connectionStatus.first{==CONNECTED} like the
other connect tests do. No product behavior changed.

---------

Co-authored-by: M57 <Hy4ri@users.noreply.github.com>
2026-07-20 23:23:29 +03:00
M57andM57 c8a5055a84 fix(auth): support __Host-/__Secure- prefixed session cookies and proxy-relative paths (issue #635) (#648)
- CookieSerialization: add SESSION_COOKIE_NAMES (__Host-, __Secure-, bare) and
  isSessionCookieName(); isSessionCookie now matches any variant.
- PersistentCookieJar.getSessionCookieValue(): iterate SESSION_COOKIE_NAMES,
  returning the strictest prefixed match when present.
- HermesWsClient.refreshWsTicketIfNeeded(): drop the bare-name session-cookie
  preflight in gated mode — the server may hold a valid refresh cookie under a
  prefixed name; the authenticated ticket endpoint is the authority. Ticket URL
  already derived from endpoint (issue #634).
- HermesWsClient: stop logging WS close/failure reason strings and exception
  messages (class name only) to avoid leaking server context / URLs.
- ProfileScopeInterceptor: match profile-scoped paths via endpoint-relative
  request path so reverse-proxy prefixes (e.g. /hermes/api/...) are honored;
  wrap endpoint read in runCatching.

Verified: ktlintCheck, testDebugUnitTest, lintDebug all green locally.

Co-authored-by: M57 <Hy4ri@users.noreply.github.com>
2026-07-20 20:56:39 +03:00
M57andM57 ee28ee5ce2 feat(#538): wire tool.progress/generating + subagent.* events into chat (#567)
* feat(#538): wire tool.progress/generating + subagent.* events into chat

* fix(#538): remove subagent indicator on subagent.complete so it doesn't linger

* style(#538): drop dead Elvis on non-nullable event.text in onMessageComplete

---------

Co-authored-by: M57 <m57@hermes-control.app>
2026-07-12 22:06:32 +03:00
M57andM57 cf893585b1 feat(#527): surface gateway error + background.complete WebSocket events (#550)
Mobile was silently dropping two event types the gateway emits. This adds
parsing + UI surfacing for both, bringing mobile to parity with desktop
(which shows gateway errors as red toasts).

- `error` (backend crash) -> WsEvent.GatewayError, surfaced in the existing
  error banner (mirrors how RpcError is handled).
- `background.complete` (scheduled job finished) -> WsEvent.BackgroundComplete,
  surfaced as a non-blocking snackbar in ChatScreen.

Changes:
- WsEvent.kt: add GatewayError(message?) + BackgroundComplete(data?) sealed subtypes.
- EventParser.kt: handle "error" + "background.complete"; unknowns still fall
  through to Unknown (no behavior change for existing event types).
- ChatWsEventReducer.kt: onGatewayError (sets errorMessage, clears loading) +
  onBackgroundComplete (sets backgroundCompleteMessage); mirrors onRpcError.
- ChatViewModel.kt: backgroundCompleteMessage state field, clearBackgroundComplete(),
  handleWsEvent branches (ViewModel owns the snackbar trigger).
- ChatScreen.kt: pass backgroundCompleteMessage to ChatLifecycleEffects + a
  LaunchedEffect that shows the snackbar and calls clearBackgroundComplete().
- EventParserTest.kt: cover both new events (incl. missing-message case).

Pure additive; sealed class + exhaustive when() preserved. Verified:
compileDebugKotlin + ktlintCheck green; EventParserTest passes.

Closes #527

Co-authored-by: M57 <m57@hermes-control.app>
2026-07-11 15:18:49 +03:00
M57andM57 53b3966931 feat(#525): render reasoning.delta / reasoning.available stream (#543)
* feat(#525): add ReasoningDelta + ReasoningAvailable WsEvent types

* feat(#525): parse reasoning.delta + reasoning.available; route through reducer + StreamingState

* feat(#525): add reasoning streaming buffer to ChatStreamingController

* feat(#525): dispatch ReasoningDelta/ReasoningAvailable in ChatViewModel

* feat(#525): render collapsible ReasoningIndicator in chat list

* fix(#525): address review — icons+semantics, LocalHermesStatusColors, drop redundant ReasoningAvailable branch

* feat(#525): persist reasoningText on model, entity, mapper + Room migration 3->4

* feat(#525): reducer + streaming carry reasoningText onto message

* feat(#525): render persisted reasoning above each assistant bubble, drop global indicator

* nix: flake

* nix: flake

---------

Co-authored-by: M57 <m57@hermes-control.app>
2026-07-10 23:41:53 +03:00
M57 d178d7f69e refactor: proper OkHttp CookieJar integration (issue #470) (#483)
Replace the manual session-cookie interceptor in ApiClient and the
manual cookie branch in TokenRefreshAuthenticator with a shared
PersistentCookieJar backed by an encrypted, per-server EncryptedCookieStore.

- Add CookieStore iface + EncryptedCookieStore (EncryptedSharedPreferences,
  per-server scope, legacy single-cookie migration)
- Add CookieSerialization (OkHttp Cookie <-> holder) + PersistentCookieJar
  (in-mem cache, async persist, atomic useStore scope switching, prune,
  session-cookie accessor)
- Add CookieManager coordinator (init/useStore/prune/clear) and wire its
  cookieJar into OkHttpProvider base/websocket/probe (lazy)
- AuthManager.get/setSessionCookie now delegate to CookieManager; add
  pruneServerCache(); clear path drops the scope's session cookie
- AuthLoginViewModel + HermesWsClient rely on the jar for Set-Cookie capture
  and session-cookie re-attachment (no manual header injection)
- Add fakes (FakeEncryptedCookieStore/buildFakePersistentCookieJar) + unit
  tests (PersistentCookieJarTest, CookieManagerTest); inject fake jar into
  ApiClientTest/HermesWsClientTest setup

WS token-out-of-URL (step 5) deferred: backend hermes-agent authenticates
WS only via ws.query_params, so moving it requires a coordinated backend
change (noted for follow-up).

Verified: testDebugUnitTest (334 passing) + assembleDebug green via local SDK.
2026-07-07 21:51:04 +03:00
M57 5697405b19 refactor: migrate Gson serialization to kotlinx.serialization (#475)
* refactor: migrate Gson serialization to kotlinx.serialization

* fix(dto): resolve serializing Any? and Map<String, Any?> with JsonElement

* test(refactor): fix unit test issues under kotlinx.serialization and update nullable DTO defaults

* fix(chat): support flexible numeric and string decoding for message timestamps

* fix(chat): sequentialize cache loading to avoid overwriting network state
2026-07-05 21:30:44 +03:00
M57 8f14aca647 perf: optimize startup, database, and ui rendering (#405)
* perf: optimize startup, database, and ui rendering

* fix(#405): address code review feedback

* test: wait for async prefs initialization to prevent coroutine leaks

* test: stub mockViewModel.streamingState in ChatScreenTest to prevent ClassCastException on Android
2026-06-27 01:38:44 +03:00
M57 82bd98dfd8 Fix HermesWsClientTest teardown and OkHttp 5.x deprecation warnings
- Widen catch in tearDown() from Exception to Throwable so
  MockWebServer.shutdown() AssertionError is caught (OkHttp 5.x
  enforces clean connection state on shutdown)
- Increase teardown wait from 100ms to 500ms for WS close handshake
- Replace deprecated RequestBody.create(null, ...) with
  toRequestBody() extension from Kotlin API
2026-06-25 23:40:08 +03:00
M57andM57 1bd56270b3 fix(#206): read clarify.request question/choices from gateway (#355)
* fix(#206): read clarify.request question/choices from gateway

The Hermes TUI gateway sends clarify.request payloads with "question" and "choices" fields, but the Android parser was looking for "text" and "options" — so the text was always null and the dialog showed only the input box.

Fix reads "question"/"choices" first, falls back to "text"/"options" for backward compat.

Test added for the new field names; existing test for legacy names still passes.

* fix(#206): clear default text in clarify input field

The input box was pre-filled with the clarify question text because the initial state was set to clarify.text instead of empty string.

* fix: use JsonRpcResponse instead of undefined WsResponse in EventParserTest

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-06-24 23:54:47 +03:00
M57andM57 2acfaabfcb fix(#284): remove legacy WS callbacks (CODE-04), migrate tests to StateFlow/SharedFlow (#303)
- Remove onMessage/onConnected/onDisconnected/onError callback
  properties from HermesWsClient — redundant with events SharedFlow
  and connectionStatus StateFlow
- Rewrite all 10 tests to use connectionStatus.first{} and
  events.first{} instead of callback + CountDownLatch patterns
- Remove polling loop for RECONNECTING status — flow inherently
  waits for the right value

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-06-22 14:05:01 +03:00
M57andM57 15a4748634 test(#292): coverage gaps TEST-04 through TEST-14 (#302)
* test(#292): coverage gaps TEST-04 through TEST-14

- TEST-04: ApiClient auth interceptor + BuildConfig.DEBUG gate (6 tests)
- TEST-05: SettingsViewModel profile operations (5 tests)
- TEST-06: ConnectViewModel profile switch edge cases (8 tests)
- TEST-07: EventParser untested subtypes (12 tests)
- TEST-08: AuthManager token routing through profiles (5 tests)
- TEST-09: ChatScreen instrumented compose tests (3 tests)
- TEST-10: WS reconnect state recovery (5 tests)
- TEST-11: Multi-profile token scenarios (6 tests)
- TEST-12: Chat DAO Room operations (11 tests)
- TEST-13: ChatViewModel slash command handling (8 tests)
- TEST-14: Predictive back gesture instrumented test (1 test)

Total: 70 tests across 11 files. CI updated with new
instrumented-tests job via android-emulator-runner.

* fix(ci): resolve ktlint, tests, and emulator failures

* fix(ci): resolve test failures on PR #302

* fix(ci): more ChatMessageDaoTest context mocks, re-read state after advanceUntilIdle in connect test

* fix(ci): remove problematic packageManager mock, decouple instrumented tests from CI gate

* fix(ci): switch emulator to default target, add more cores, memory, and timeout

* fix(ci): remove mockkStatic(Log::class) from ChatMessageDaoTest - fails on Android stubs

* fix(ci): use aosp_atd emulator image + KVM + AVD cache for fast instrumented tests

* fix(ci): remove ApplicationInfo mock - Android stub class breaks MockK

* fix(ci): rewrite ChatMessageDaoTest to use HermesDatabase.setForTest() pattern - Room in-memory DB requires Android SDK not available in JVM tests

* fix(ci): use actions/cache@v4 instead of @v7 (doesn't exist)

* fix(ci): add missing performClick import in StateViewsTest

* fix(ci): mock ChatViewModel in instrumented tests, add mockk to androidTestImplementation

* fix(ci): add asStateFlow import in ChatScreenTest

* fix(ci): exclude duplicate META-INF LICENSE/NOTICE files from androidTest build

JUnit Jupiter 5.8.2 JARs each ship META-INF/LICENSE.md,
causing mergeDebugAndroidTestJavaResource to fail with
'duplicate files found'. Add LICENSE.md, LICENSE, NOTICE,
and NOTICE.md to the packaging exclusion list.

* fix(#302): exclude duplicate META-INF/LICENSE-notice.md from instrumented test APK

JUnit Jupiter 5.x JARs all ship META-INF/LICENSE-notice.md,
causing mergeDebugAndroidTestJavaResource to fail.

* fix(#302): add LICENSE-notice.md as separate exclude entry

The Ant-style glob brace expansion in packaging.resources.excludes
doesn't handle LICENCE-notice.md inside the {}-enclosed pattern.
Adding it as a separate entry instead.

* fix(#302): use mockk-android for instrumented tests

io.mockk:mockk uses Java instrumentation agents not available on
Android. Switch to io.mockk:mockk-android for connectedDebugAndroidTest
which uses an Android-compatible mocking strategy.

* fix(#302): use createAndroidComposeRule for test lifecycle isolation

Standard createComposeRule has a gap where consecutive test methods
can lose the compose hierarchy on the emulator. Switching to
createAndroidComposeRule<MainActivity> gives explicit activity
lifecycle management across test methods, fixing the
'No compose hierarchies found' errors.

* fix(#302): use createComposeRule instead of createAndroidComposeRule<MainActivity>

MainActivity.onCreate() already calls setContent, so the test's
setContent { ChatScreen(...) } crashed with 'has already set content'.
Switch to createComposeRule() which launches a bare ComponentActivity
that doesn't call setContent, allowing the test to compose ChatScreen
in isolation with a mock ChatViewModel.

* fix(#302): use createAndroidComposeRule<ComponentActivity> + unmockkAll for instrumented tests

ChatScreenTest was failing with 'No compose hierarchies found' because
mockk mocks in instrumented tests weren't cleaned up between test runs.
Switch from createComposeRule() to explicit createAndroidComposeRule<ComponentActivity>()
and add @After tearDown() with unmockkAll() to ensure mock state doesn't
leak between test methods.

* fix(#302): wrap ChatScreen in HermesControlTheme in instrumented tests

ChatScreen accesses MaterialTheme.colorScheme during composition (background
gradient). Without a Material3 theme wrapper, the composable silently crashes
and no compose hierarchy is registered — causing 'No compose hierarchies found'
on any subsequent onNodeWithTag() call.

Fix: wrap ChatScreen in HermesControlTheme inside setContent {}, matching how
MainActivity renders the app. Also use createAndroidComposeRule<ComponentActivity>
instead of createComposeRule() for explicit lifecycle management, and add
unmockkAll() in @After to clean up mockk state between tests.

* fix(ci): fix packaging resource paths and use pickFirsts for duplicate META-INF files

Remove leading slashes from META-INF paths (AGP paths are
relative, not absolute). Use pickFirsts instead of excludes
to handle duplicate files from JUnit Jupiter JARs.

* fix(#302): use createAndroidComposeRule<ComponentActivity> for test isolation

createComposeRule() has a known race where the compose hierarchy
is lost between sequential test methods on the emulator.
createAndroidComposeRule<ComponentActivity> provides proper
Activity lifecycle management while using the same lightweight
empty activity that doesn't pre-set content (unlike MainActivity).

* fix(#302): consolidate ChatScreenTest into single test method

The Compose test rule's lifecycle gap between test methods on the
emulator causes 'No compose hierarchies found' on consecutive
setContent calls. Consolidating all three test scenarios into one
invocation eliminates the cross-test teardown issue entirely.

* fix(#302): mock ContextCompat to suppress permission dialog in test

The ChatScreen LaunchedEffect requests POST_NOTIFICATIONS via
ActivityResultContracts.RequestPermission(), which pauses the
activity and disposes the compose hierarchy. Mocking
ContextCompat.checkSelfPermission to return PERMISSION_GRANTED
prevents this from happening during the test.

* fix(#302): set connectionStatus=CONNECTED in ChatScreenTest

The default ChatUiState has connectionStatus=DISCONNECTED, which
makes isConnected=false, in turn disabling the chat input field
(enabled = isConnected) and the send button (canSend checks
isConnected). Set it to CONNECTED so both controls are active.

* fix(#302): add ConnectionStatus import and fix ktlint wrapping

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-06-22 13:49:04 +03:00
M57 bfef3613fa fix(#240): parse session_id from params root (#242)
* fix(#240): parse session_id from params root

Allows correct session mapping when opening app via notification.

* fix(#240): set MainActivity launchMode to singleTop

Prevents activity destruction and WebSocket reconnection when tapping notifications.

* fix(#240): save inline notification replies to Room database

* fix(#240): refresh current session when app comes to foreground

* fix(#240): use uppercase role string to match Mapper mapping expectations

* style: format NotificationReplyReceiver.kt to satisfy ktlint
2026-06-21 19:04:54 +03:00
M57 262578528b fix: stabilize flaky testAutoReconnect with polling assertion 2026-06-21 16:26:07 +03:00
M57 4547861c71 test: Add HermesWsClient test (#187) 2026-06-20 23:56:04 +03:00
Hy4ri d6ff3de594 Initial commit of HermesControl Android app 2026-06-16 00:00:36 +03:00