Skip to content

fix: stabilize daemon service lifecycle and align Agent Status UI#6

Merged
senamakel merged 9 commits intodevelopfrom
fix/monday-patches
Mar 25, 2026
Merged

fix: stabilize daemon service lifecycle and align Agent Status UI#6
senamakel merged 9 commits intodevelopfrom
fix/monday-patches

Conversation

@senamakel
Copy link
Copy Markdown
Member

Summary

  • split core runtime flow so service/CLI paths target the core server process model
  • improve macOS LaunchAgent lifecycle handling using modern launchctl behavior with safer stop semantics
  • add/adjust service commands including reinstall flow and status-driven control behavior
  • update UI wording from Daemon Status to Agent Status and wire status checks to server reachability on port 7788
  • fix Home CTA so Message AlphaHuman opens in-app Conversations instead of Telegram

Validation

  • cargo check --bin alphahuman-cli
  • cargo check --bin AlphaHuman

- Added OAuthProviderButton to the Welcome component for Google authentication.
- Updated the branding from AlphaHuman to OpenHuman in the FeaturesStep component.
- Removed unnecessary Lottie animation from the Onboarding page for a cleaner layout.
- Changed the backend URL to point to the new API endpoint for TinyHumans.
- Commented out the Mnemonic route and related logic in AppRoutes for future consideration.
- Updated MiniSidebar to comment out the Invite Friends section.
- Removed unused navigation logic and upgrade call-to-action from the Home page.
- Adjusted Onboarding navigation to redirect to Home instead of Mnemonic.
- Introduced new binaries: `alphahuman-core` and `alphahuman-cli` for core process management and command-line interaction.
- Implemented `CoreProcessHandle` for managing the lifecycle of the core process.
- Added `core_rpc` module for handling RPC requests and responses.
- Created `core_server` module to manage core server logic and routing.
- Updated `alphahuman` commands to utilize the new RPC structure for health checks, security policies, and configuration management.
- Refactored existing code to streamline interactions with the core process and improve overall architecture.
- Added `clap` for command-line argument parsing in the `alphahuman-cli`.
- Updated `Cargo.lock` and `Cargo.toml` to include `clap` and its features.
- Refactored `alphahuman-cli` to utilize structured command handling with subcommands.
- Improved core process management and logging in `core_process.rs`.
- Enhanced routing and error handling in `core_server.rs` with new root and not found handlers.
- Updated various commands in `alphahuman.rs` to ensure core process is running before executing RPC calls.
- Added new functions for daemon program arguments and command line construction in the service module.
- Updated macOS and Linux installation functions to dynamically generate program arguments and command lines.
- Introduced a new `Reinstall` command in the CLI for easier service management.
- Refactored service command handling to utilize local service functions for improved clarity and maintainability.
- Updated terminology from "Daemon" to "Agent" in MiniSidebar, DaemonHealthPanel, and TauriCommandsPanel for consistency.
- Modified useDaemonHealth hook to probe agent status and handle agent lifecycle management.
- Introduced new agent server status interface and function in Tauri commands for improved status checking.
- Adjusted related comments and error handling to reflect the changes in terminology.
- Updated Home component to navigate to in-app conversations instead of opening a Telegram bot link.
- Improved macOS service management by implementing modern lifecycle commands and adding compatibility fallbacks for service control.
- Introduced new utility functions for handling macOS GUI domain and service targets.
- Removed SkillsGrid component and replaced it with a button that navigates to the Skills page.
- Improved layout with additional margin for better spacing in the Home component.
@senamakel senamakel merged commit 37318bc into develop Mar 25, 2026
1 of 5 checks passed
senamakel added a commit to senamakel/openhuman that referenced this pull request Apr 14, 2026
… logs

Findings tinyhumansai#3, tinyhumansai#5, tinyhumansai#6 from the follow-up review:

channels/bus.rs
- chat_done handler no longer returns early on empty reply — it now
  finalizes with a "(No response from agent.)" fallback so any draft
  we posted during streaming gets closed off instead of being left
  showing "_working…_" forever.
- StreamingState gained `draft_sent: bool`, set whenever the initial
  send_channel_message succeeds (even when the backend's response
  didn't include an id). finalize_channel_reply now checks this flag
  and silently skips the "no draft → send atomic" fallback when a
  draft was posted but id was lost — fixes a duplicate-bubble bug
  where an id-less draft plus a chat_done finalize produced two
  messages in the user's channel.

channels/providers/web.rs
- spawn_progress_bridge now logs a scoped entry message on startup
  (client_id/thread_id/request_id), a per-variant trace/debug line on
  each AgentProgress event (with call_id/iteration correlation), and
  an exit message with final round + events_seen count. SubagentFailed
  is logged at warn level for visibility.
senamakel added a commit that referenced this pull request Apr 14, 2026
…hannel edits (#549)

* feat(conversations): implement live streaming for assistant responses

- Added support for live streaming of assistant responses in the Conversations component, enhancing user experience during interactions.
- Introduced new interfaces for handling streaming state, including `StreamingAssistantState` and related event handlers for text, thinking, and tool argument deltas.
- Updated the state management to accommodate streaming data, ensuring smooth updates to the UI as new content arrives.
- Enhanced the rendering logic to display provisional assistant bubbles and thinking indicators while responses are being composed.
- Refactored existing event handling to integrate with the new streaming functionality, improving overall responsiveness and interactivity.

This commit significantly improves the real-time interaction capabilities of the assistant, providing users with immediate feedback during conversations.

* feat(channels): progressive-edit streaming for inbound channels

ChannelInboundSubscriber now buffers text/tool delta events on a 1s
timer and edits the outbound channel message in place, so Telegram/
Slack-style conduits can show a single evolving reply instead of a
single atomic bubble at the end. Renders a "🔧 tool …" status line
above the partial text and rewrites with the final canonical reply
on chat_done.

Falls back to atomic-final delivery if the backend's PATCH
/channels/:channel/messages/:id endpoint is unavailable or repeatedly
fails, so existing channels keep working while the edit endpoint is
rolled out.

New rest.rs helper: BackendOAuthClient::send_channel_edit.

* style: cargo fmt on streaming-related files

Auto-applied by cargo fmt after the streaming plumbing changes touched
provider traits, the session turn loop, the channel inbound subscriber,
and the compatible-provider SSE path.

* feat(streaming): compact live preview + Telegram typing indicator

UI: while streaming, show only the trailing ~120 chars of assistant
text in a monospace ticker-tape bubble (cursor + ellipsis prefix) so
the scroll position doesn't jump as tokens arrive. The full response
still replaces the preview via addInferenceResponse on chat_done.

Backend bridge: ChannelInboundSubscriber now fires Telegram's typing
indicator as soon as an inbound message is received and refreshes it
every 4 s while the turn is in flight (Telegram's sendChatAction lasts
~5 s). New BackendOAuthClient::send_channel_typing hits
POST /channels/:channel/typing; the subscriber latches
typing_disabled after two failures so channels without the endpoint
stop getting hit.

* fix(providers): fall back to JSON parse when upstream ignores stream=true

Some OpenAI-compatible backends (including our e2e mock) accept
`stream: true` in the request but reply with a regular
`application/json` body rather than an SSE stream. The previous
implementation blindly pushed the body through the SSE line parser,
which produced an empty aggregated response because the body never
contained `\n\n` event separators.

Detect the non-SSE content-type and fall through to the existing
`parse_native_response` path so the caller still gets the aggregated
response. No deltas are emitted in this case — there's nothing to
stream — but correctness is preserved.

Unblocks the json_rpc_protocol_auth_and_agent_hello E2E test.

* Enhance event handling for progressive-edit streaming in ChannelInboundSubscriber

- Introduced a new `StreamingState` struct to manage the state of progressive-edit streaming, allowing for buffered text and tool deltas.
- Implemented a timer-based flushing mechanism for edits, ensuring timely updates to the channel.
- Refactored event handling logic to accommodate new event types (`text_delta`, `tool_call`, `tool_result`) and improved error handling for chat events.
- Updated the logic for finalizing channel replies to handle both streaming and atomic delivery scenarios, enhancing overall responsiveness and user experience.

This commit significantly improves the handling of real-time updates during user interactions, providing a smoother and more interactive experience.

* Enhance tool call tracking in AgentProgress and parsing logic

- Added a `call_id` field to `ToolCallStarted` and `ToolCallCompleted` variants in the `AgentProgress` enum to uniquely identify tool calls and link them to their respective events.
- Updated the `ParsedToolCall` struct to include an optional `id` field for tool calls originating from native responses, ensuring consistent tracking across different call types.
- Modified the `parse_tool_call_value` function to initialize the `id` field appropriately, enhancing the parsing logic for tool calls.
- Adjusted the `run_tool_call_loop` function to utilize the new `call_id` for progress events, ensuring accurate tracking of tool execution across iterations.
- Enhanced the `spawn_progress_bridge` function to handle the new `call_id` field in progress events, improving the overall event handling mechanism.

These changes improve the robustness of tool call tracking and enhance the clarity of event relationships within the agent's progress reporting.

* Enhance tool call tracking and event handling in Conversations component

- Added a `tool_call_id` field to `ChatToolCallEvent` and `ChatToolResultEvent` interfaces for improved tracking of tool calls across events.
- Updated event key generation in the Conversations component to include `tool_call_id`, ensuring unique identification of tool events.
- Enhanced the logic for managing tool timelines to prevent duplication of entries by reconciling existing tool calls based on `tool_call_id`.
- Improved handling of tool argument deltas and results, allowing for more accurate updates to the UI during tool execution.

These changes significantly improve the robustness of tool call tracking and enhance the clarity of event relationships within the Conversations component.

* Enhance tool call event handling and progress reporting in Agent

- Updated the `run_tool_call_loop` function to include stable IDs for tool calls, ensuring unique identification across iterations.
- Introduced early completion events for failed tool calls, improving client-side error handling and user experience.
- Refactored the `emit_progress` function to use asynchronous sending, ensuring lifecycle events are not dropped due to backpressure.
- Enhanced the `turn` method to await progress emissions, improving synchronization during user message processing.

These changes significantly improve the robustness of tool call tracking and enhance the clarity of event relationships within the agent's progress reporting.

* fix(channels): close stuck drafts, prevent duplicate post, add bridge logs

Findings #3, #5, #6 from the follow-up review:

channels/bus.rs
- chat_done handler no longer returns early on empty reply — it now
  finalizes with a "(No response from agent.)" fallback so any draft
  we posted during streaming gets closed off instead of being left
  showing "_working…_" forever.
- StreamingState gained `draft_sent: bool`, set whenever the initial
  send_channel_message succeeds (even when the backend's response
  didn't include an id). finalize_channel_reply now checks this flag
  and silently skips the "no draft → send atomic" fallback when a
  draft was posted but id was lost — fixes a duplicate-bubble bug
  where an id-less draft plus a chat_done finalize produced two
  messages in the user's channel.

channels/providers/web.rs
- spawn_progress_bridge now logs a scoped entry message on startup
  (client_id/thread_id/request_id), a per-variant trace/debug line on
  each AgentProgress event (with call_id/iteration correlation), and
  an exit message with final round + events_seen count. SubagentFailed
  is logged at warn level for visibility.
oxoxDev added a commit to oxoxDev/openhuman that referenced this pull request Apr 23, 2026
…umansai#812)

Replaces the flat `screen_share_list_sources` + `screen_share_thumbnail`
command pair with a short-lived session token flow, closing the
privacy surface graycyrus and CodeRabbit flagged as a blocker on tinyhumansai#809:
page JS (including third-party scripts loaded by the embedded site)
could previously call either command directly and exfiltrate open
window titles + live thumbnails with no picker interaction and no user
gesture.

Session gating (tinyhumansai#812 Stage A):

- `screen_share_begin_session` — opens a 30s session. Requires (1) the
  caller's webview label to start with `acct_` (rejects main/overlay
  windows), (2) a live `navigator.userActivation.isActive` (frontend
  check; rejects timers and async continuations), and (3) ≤10 begin
  attempts per account in any 60s window. Returns `{ token, sources }`
  in one round-trip so the picker opens with zero extra latency.
- `screen_share_thumbnail` — now requires the token from a live session
  AND an `id` that was in that session's enumerated source list. A
  leaked token can only replay thumbnails for the IDs the shim already
  showed the user.
- `screen_share_finalize_session` — explicit cleanup from the shim on
  Share or Cancel. No-op on unknown tokens. Not label-gated because the
  only effect is dropping a token the caller already possesses.

A new begin_session for an account replaces any in-flight session for
the same account, which also fixes graycyrus' refactor note tinyhumansai#6
(concurrent getDisplayMedia calls producing stacked overlays) at the
host-state level.

Review blockers / majors (graycyrus, tinyhumansai#809):

- `CGWindowID` was flowing through `cfnumber_to_u64` (u64) and being
  formatted straight into the DesktopMediaID. `parse_source_id` accepts
  `u32` only, so a window with an ID above u32::MAX would have been
  silently dropped with a grey placeholder. Enumerator now does a
  checked `u32::try_from` and logs + skips on overflow.
- `cfstr` was calling `CString::new().expect()`; panicking through the
  Apple FFI frames is UB. Returns `Option<*const c_void>` now, callers
  bail cleanly.
- `screen_thumbnail_b64` / `window_thumbnail_b64` now guard against
  images smaller than 4×4 pixels. macOS 15 Sequoia returns a valid
  1×1 transparent CGImage when Screen Recording TCC is not granted
  (instead of the pre-Sequoia null); the old zero-dimension check
  wasn't catching that.
- All three commands emit entry/exit `[screen-share]` debug logs with
  grep-friendly token prefixes so the flow is traceable in dev builds.
- Dropped the no-op `bounds_dict` block from window enumeration; it was
  a TODO placeholder that never gained a filter.
- Added `= 8` / `= 16` inline hex comments to the CG window-list
  bitmask constants.

Unit tests cover: parse_source_id (existing), token generation /
URL-safe shape / uniqueness, session expiry purge, rate-limit window
(11th call blocked, scoped per account). Command-level tests would
need a `tauri::Webview` mock the stable API doesn't expose; the live
run will exercise the gate wiring.

Permission allowlists switch from listing `screen_share_list_sources`
to the three session commands on both `allow-webview-recipe` and
`allow-core-process`. `docs/src-tauri/02-commands.md` gains a
Screen-share section describing each command.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
oxoxDev added a commit to oxoxDev/openhuman that referenced this pull request Apr 23, 2026
…mansai#713)

Addresses the shim-side half of graycyrus refactor note tinyhumansai#6 on tinyhumansai#809.

The host session state already evicts a stale session when
`begin_session` is called a second time for the same account, but
without a shim-side guard a concurrent `getDisplayMedia` would still
append a second picker DOM while the first overlay was live — the user
would see two stacked cards and no clean way out of either.

Tracks an `pickerInFlight` module-scoped boolean around the shim body
(now factored into `runShim`) and rejects concurrent calls with
`InvalidStateError`, which matches the MediaStreams spec's error shape
for already-in-progress capture requests. The flag is reset in a
`finally` block so exceptions from `runShim` don't leave it stuck.

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.

1 participant