Skip to content

fix(wework): restore running tasks after window reopen - #1963

Merged
qdaxb merged 1 commit into
mainfrom
fix/wework-runtime-reopen-status
Jul 15, 2026
Merged

qdaxb merged 1 commit into
mainfrom
fix/wework-runtime-reopen-status

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • expose an authoritative running flag from runtime transcript responses
  • restore running state when a Wework window is recreated while the executor and Codex app-server remain alive
  • prevent stale streaming transcript messages from reviving tasks after a normal or abnormal full app exit
  • preserve an executor-confirmed running state across stale non-terminal work-list refreshes
  • document the window and executor lifecycle contract in Chinese and English

Root cause

The workbench previously had to combine task-list state with streaming transcript messages after a WebView was recreated. A stale task-list response could overwrite a live transcript state, while treating transcript history as authoritative would incorrectly revive interrupted tasks after the application and executor restarted.

The executor now derives transcript execution state from its in-memory active task set or the Codex app-server's live thread status. Historical streaming messages are display history only and no longer establish execution liveness.

Validation

  • pnpm --filter wework test (157 test files, 1572 tests)
  • focused Wework runtime tests (97 tests)
  • executor runtime transcript contract tests (7 tests)
  • executor unit test for active, idle, and not-loaded Codex thread states
  • ESLint, TypeScript, Prettier, cargo fmt, cargo test --all-features --lib, and cargo clippy through pre-push checks
  • isolated real Tauri session: created a real Codex task, observed the running marker, and successfully closed the WebView to tray while execution was active

Notes

The isolated verifier currently has no reopen command after close-to-tray destroys its controlled WebView. Reopen state restoration is covered by the executor contract and workbench integration tests, including the negative stale-streaming case after executor restart.

Summary by CodeRabbit

  • Bug Fixes

    • Improved runtime task status restoration when reopening or refreshing workspaces.
    • Prevented stale streaming messages from incorrectly showing idle or interrupted tasks as running.
    • Preserved active task indicators during transcript refreshes while excluding completed or failed tasks.
  • Documentation

    • Clarified task lifecycle behavior when closing the app to the tray, fully exiting, or restarting.
    • Documented how live runtime status is determined and why historical transcript messages are not authoritative.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d725078e-6f24-4ea5-92be-72192d66ca02

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8b5da and 27f4b2c.

📒 Files selected for processing (13)
  • docs/en/developer-guide/wework-cloud-connection.md
  • docs/zh/developer-guide/wework-cloud-connection.md
  • executor/src/runtime_work/handler.rs
  • wework/src/App.plugins.test.tsx
  • wework/src/components/layout/useWorkbenchPaneSession.ts
  • wework/src/features/workbench/WorkbenchProvider.test.tsx
  • wework/src/features/workbench/WorkbenchProvider.tsx
  • wework/src/features/workbench/runtimePaneStatus.test.ts
  • wework/src/features/workbench/useWorkbenchRuntimeTasks.ts
  • wework/src/features/workbench/workbenchContextTypes.ts
  • wework/src/features/workbench/workbenchReducer.ts
  • wework/src/types/api.ts
  • wework/src/types/workbench.ts

📝 Walkthrough

Walkthrough

The executor now returns a live running transcript flag based on active local tasks or Codex threads. Wework propagates this flag when reopening panes, preserves active state during refreshes, and ignores stale streaming messages for idle tasks.

Changes

Runtime running-state propagation

Layer / File(s) Summary
Executor running-state contract
executor/src/runtime_work/handler.rs, docs/en/..., docs/zh/...
Transcript responses now report running state from live executor or Codex activity, with lifecycle behavior documented in English and Chinese.
Workbench transcript restoration
wework/src/types/*, wework/src/features/workbench/useWorkbenchRuntimeTasks.ts, wework/src/components/layout/useWorkbenchPaneSession.ts
The running flag flows through transcript types and loading logic, marking reopened runtime tasks as started when appropriate.
Workbench state preservation
wework/src/features/workbench/WorkbenchProvider.tsx, wework/src/features/workbench/workbenchReducer.ts
A runtime-task start action is exposed through context, and refreshes preserve running state until a terminal status arrives.
Running-state validation
wework/src/features/workbench/*.test.*, wework/src/App.plugins.test.tsx
Tests cover reopened streaming tasks, stale streaming messages, Codex status detection, and updated context mocks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ExecutorTranscript
  participant useWorkbenchRuntimeTasks
  participant useWorkbenchPaneSession
  participant WorkbenchProvider
  participant workbenchReducer
  Client->>ExecutorTranscript: request runtime transcript
  ExecutorTranscript-->>Client: return messages and running
  Client->>useWorkbenchRuntimeTasks: load transcript
  useWorkbenchRuntimeTasks->>useWorkbenchPaneSession: pass running state
  useWorkbenchPaneSession->>WorkbenchProvider: markRuntimeTaskStarted(address)
  WorkbenchProvider->>workbenchReducer: dispatch runtime_task_started
Loading

Possibly related PRs

Suggested reviewers: micro66, icycrystal4

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wework-runtime-reopen-status

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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