Skip to content

Mobile QoL: remote project add, auto-refresh, and daemon-restart recovery#455

Open
Crabbotix wants to merge 3 commits intoDimillian:mainfrom
artuskg:codex/mobile-qol-ios-refresh
Open

Mobile QoL: remote project add, auto-refresh, and daemon-restart recovery#455
Crabbotix wants to merge 3 commits intoDimillian:mainfrom
artuskg:codex/mobile-qol-ios-refresh

Conversation

@Crabbotix
Copy link

@Crabbotix Crabbotix commented Feb 19, 2026

What

  • Add support for adding Projects from mobile while connected to a remote server (manual path entry fallback in remote+iPhone flow).
  • Improve automatic refresh behavior for remote usage:
    • workspace refresh polling now responds correctly to backend mode/visibility lifecycle.
    • thread live connection recovery is stronger after interruptions.
  • Add reconnect hardening for daemon restarts:
    • stale live stream watchdog with auto-reconnect.
    • reconnect on detached events when visible/focused.
    • improved reconnect sequencing and cleanup handling.
  • Add server-side busy indication in the sidebar for workspaces with active processing/streaming thread activity.
  • Add regression tests for the new remote refresh/reconnect behaviors and mobile add-project flow.

Why

  • iPhone users connected to a remote Codex Monitor server currently hit friction when adding projects and when daemon/live-stream state changes.
  • After daemon restarts, the app could get stuck until manual restart; this patch improves self-healing reconnect behavior.
  • Workspace-level activity visibility helps users quickly see active/streaming work without drilling into each thread.

How

  • Frontend hooks:
    • updated useWorkspaces to support remote mobile manual path entry.
    • updated useWorkspaceRefreshOnFocus to properly rebind polling lifecycle by mode/interval/visibility.
    • updated useRemoteThreadLiveConnection with stale-live detection, focus-aware reconnect triggers, and reconnect sequence hardening.
  • UI:
    • sidebar computes workspace processing activity and renders a colored indicator in workspace rows.
  • Tests:
    • added/expanded tests for reconnect races, stale recovery, focus/visibility polling behavior, and mobile remote add-project flow.

Testing status

  • Untested manually on device right now (I can only run end-to-end/manual verification this evening).

@Dimillian
Copy link
Owner

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd5b109622

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 332 to 333
if (connectionStateRef.current === "live") {
lastThreadEventAtRef.current = Date.now();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Mark stream live on activity events

Gating lastThreadEventAt updates behind connectionStateRef.current === "live" means the hook now relies on thread/live_heartbeat to ever enter/maintain live mode, but the in-repo backends currently emit attach/detach only (see src-tauri/src/codex/mod.rs and src-tauri/src/bin/codex_monitor_daemon.rs thread/live_attached/thread/live_detached paths) and no heartbeat producer. In that environment the state can stay stuck in polling, so the stale watchdog (connectionStateRef.current === "live") never triggers after daemon interruptions and live-recovery logic is effectively bypassed.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 2f35d4b.

What changed:

  • In useRemoteThreadLiveConnection, thread activity events (item/*, turn/*, error, thread/tokenUsage/updated) now update lastThreadEventAtRef and set connection state to "live".
  • Added regression test: promotes polling state to live on thread activity without heartbeat.

Validation run:

  • npm run test -- src/features/app/hooks/useRemoteThreadLiveConnection.test.tsx src/features/app/hooks/useRemoteThreadRefreshOnFocus.test.tsx src/features/workspaces/hooks/useWorkspaceRefreshOnFocus.test.tsx src/features/workspaces/hooks/useWorkspaces.test.tsx src/features/app/components/Sidebar.test.tsx
  • npm run typecheck

@Crabbotix
Copy link
Author

Crabbotix commented Feb 19, 2026

Addressed a follow-up reconnect-churn risk from RepoPrompt review in commit 274d092.

Change summary:

  • useRemoteThreadLiveConnection reconnect trigger now keys off stable workspace primitives (workspace id and connected) instead of full workspace object identity.
  • Added a guard to skip redundant reconnect when already subscribed and not disconnected.
  • Added regression test covering rerender with a new workspace object (same key) to ensure no extra subscribe/unsubscribe.

Validation run:

  • npm run test -- src/features/app/hooks/useRemoteThreadLiveConnection.test.tsx src/features/app/hooks/useRemoteThreadRefreshOnFocus.test.tsx src/features/workspaces/hooks/useWorkspaceRefreshOnFocus.test.tsx src/features/workspaces/hooks/useWorkspaces.test.tsx src/features/app/components/Sidebar.test.tsx
  • npm run typecheck

@Dimillian
Copy link
Owner

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 274d092bc5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +316 to +318
if (isDocumentVisible() && isWindowFocused()) {
void reconnectLive(activeWorkspaceId, selectedThreadId, {
runResume: true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore self-triggered detach events before reconnecting

This unconditional reconnect on thread/live_detached fires even when the detach was initiated locally by reconnectLive itself (the dedupe path now calls threadLiveUnsubscribe before re-subscribing for the same key). In a visible/focused window, that unsubscribe emits thread/live_detached, which re-enters reconnectLive and creates overlapping reconnect sequences for the same thread, causing redundant resume/subscribe calls and racey state transitions instead of a single reconnect attempt.

Useful? React with 👍 / 👎.

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

Comments