* 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>
- 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>
* 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>
* 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>
* 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>
- 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>
* 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>
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>
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.
* 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
- 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
* 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>
- 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>
* 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>
* 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