Skip to content

[codex] stabilize Wework Codex runtime guidance - #1748

Merged
qdaxb merged 1 commit into
mainfrom
codex/fix-wework-guidance-order
Jul 6, 2026
Merged

qdaxb merged 1 commit into
mainfrom
codex/fix-wework-guidance-order

Conversation

@qdaxb

@qdaxb qdaxb commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add native runtime guidance forwarding across Backend, executor, and Wework local services
  • render guidance user messages at the active assistant split point so live streaming order matches refreshed transcripts
  • support Cmd/Ctrl+Enter as direct guidance while a runtime turn is busy
  • document runtime guidance and Wework guidance message ordering in zh/en developer guides

Root Cause

Wework inserted successful guidance messages only after the guidance request returned, while Codex could continue emitting assistant text during that request window. That text was already attached to the pre-guidance assistant, so live streaming could show assistant content before the user guidance even though a refresh reconstructed the transcript differently.

Validation

  • pnpm --filter wework exec vitest run src/features/workbench/WorkbenchProvider.test.tsx src/components/chat/ChatInput.test.tsx src/components/layout/BufferedChatInput.test.tsx
  • pnpm --filter wework typecheck
  • pnpm --filter wework lint
  • uv run pytest tests/api/endpoints/test_runtime_work_api.py tests/services/test_runtime_work_service.py
  • cargo test --test app_runtime_work_send_contract
  • pre-push gate: Wework lint/typecheck/unit, Backend black/isort/syntax, settings config, executor cargo fmt/lib tests/clippy, alembic multi-head

Summary by CodeRabbit

  • New Features

    • Added a new “guide while busy” flow so queued messages can be sent into an actively streaming reply instead of waiting.
    • Pressing Cmd/Ctrl+Enter now sends the current message as guidance when a conversation is busy.
    • Improved message ordering during active replies so guided messages appear in the transcript at the correct point.
  • Bug Fixes

    • Reduced duplicate or out-of-order assistant text when guidance is inserted mid-stream.
    • Preserved transcript consistency when continuing a response after guidance.

@coderabbitai

coderabbitai Bot commented Jul 6, 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: 295b6f42-beb0-42ce-af2a-46554910aa0d

📥 Commits

Reviewing files that changed from the base of the PR and between da38662 and f350b2e.

📒 Files selected for processing (31)
  • backend/app/api/endpoints/runtime_work.py
  • backend/app/schemas/runtime_work.py
  • backend/app/services/runtime_work_service.py
  • backend/tests/api/endpoints/test_runtime_work_api.py
  • backend/tests/services/test_runtime_work_service.py
  • docs/en/developer-guide/runtime-local-work.md
  • docs/en/developer-guide/wework-chat-state-sources.md
  • docs/zh/developer-guide/runtime-local-work.md
  • docs/zh/developer-guide/wework-chat-state-sources.md
  • executor/src/agents/codex.rs
  • executor/src/agents/mod.rs
  • executor/src/local/app_ipc.rs
  • executor/src/runtime_work/handler.rs
  • executor/tests/app_runtime_work_send_contract.rs
  • wework/src/api/executorAccess.ts
  • wework/src/api/hybrid/hybridServices.ts
  • wework/src/api/local/localServices.ts
  • wework/src/api/runtimeWork.ts
  • wework/src/components/chat/ChatInput.test.tsx
  • wework/src/components/chat/ChatInput.tsx
  • wework/src/components/chat/composer/CompactChatComposer.tsx
  • wework/src/components/chat/composer/ComposerTextarea.tsx
  • wework/src/components/chat/composer/ProjectChatComposer.tsx
  • wework/src/components/layout/BufferedChatInput.tsx
  • wework/src/components/layout/useWorkbenchPaneSession.ts
  • wework/src/features/workbench/WorkbenchProvider.test.tsx
  • wework/src/features/workbench/WorkbenchProvider.tsx
  • wework/src/features/workbench/useWorkbenchRuntimeMessaging.ts
  • wework/src/features/workbench/useWorkbenchSkills.ts
  • wework/src/features/workbench/workbenchContextTypes.ts
  • wework/src/types/api.ts

📝 Walkthrough

Walkthrough

This PR adds a "runtime guidance" feature allowing a queued user message to steer an active Codex turn without interrupting it. Backend gains a /guidance endpoint and service forwarding runtime.tasks.guidance RPC; the executor tracks active Codex turns and adds a steer_turn client method; wework adds guidance-aware composer submit options, pane session splitting/trimming logic, and API/context wiring. Documentation and tests are updated accordingly.

Changes

Runtime Guidance Feature

Layer / File(s) Summary
Backend guidance schemas and endpoint
backend/app/schemas/runtime_work.py, backend/app/api/endpoints/runtime_work.py, backend/app/services/runtime_work_service.py, backend/tests/api/endpoints/test_runtime_work_api.py, backend/tests/services/test_runtime_work_service.py
New RuntimeGuidanceRequest/RuntimeGuidanceResponse schemas, a POST /guidance endpoint, and send_runtime_guidance service logic forwarding to runtime.tasks.guidance RPC, with API/service tests covering success and failure.
Executor Codex client steer_turn and active-turn callback
executor/src/agents/codex.rs, executor/src/agents/mod.rs
Adds CodexActiveTurnCallback, active_turn_started option, and steer_turn client method invoking turn/steer; wires callback into shared turn notification handling.
Executor active-turn tracking and guidance handler
executor/src/runtime_work/handler.rs, executor/src/local/app_ipc.rs, executor/tests/app_runtime_work_send_contract.rs
Tracks active Codex turns per task, adds send_guidance RPC handler that waits for the active turn then calls steer_turn, removes prior method remapping, adds contract test.
Wework API clients and types
wework/src/types/api.ts, wework/src/api/executorAccess.ts, wework/src/api/hybrid/hybridServices.ts, wework/src/api/local/localServices.ts, wework/src/api/runtimeWork.ts
Adds RuntimeGuidanceRequest/Response types and guideRuntimeTask methods across API clients.
Composer submit contracts and Enter/Cmd+Enter handling
wework/src/components/chat/ChatInput.tsx, .../ComposerTextarea.tsx, .../CompactChatComposer.tsx, .../ProjectChatComposer.tsx, wework/src/components/layout/BufferedChatInput.tsx, related tests
Extends onSubmit signatures with guideWhenBusy/ComposerSubmitOptions, and wires Cmd/Ctrl+Enter to submit as guidance.
Pane session guidance splitting and queued sending
wework/src/components/layout/useWorkbenchPaneSession.ts
Adds guidance split boundary tracking, message splitting/freezing helpers, sendQueuedMessageAsGuidance with no_active_turn fallback, and extends send() with guidance options.
Workbench context wiring and tests
wework/src/features/workbench/workbenchContextTypes.ts, useWorkbenchRuntimeMessaging.ts, WorkbenchProvider.tsx, WorkbenchProvider.test.tsx, useWorkbenchSkills.ts
Adds sendRuntimePaneGuidance context method and implementation, wires it through provider values, and updates tests for native guidance flows.
Guidance flow documentation
docs/en/developer-guide/runtime-local-work.md, docs/en/developer-guide/wework-chat-state-sources.md, docs/zh/developer-guide/runtime-local-work.md, docs/zh/developer-guide/wework-chat-state-sources.md
Documents the guidance endpoint, executor behavior, message ordering rules, and updates benchmark tables.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant PaneSession as useWorkbenchPaneSession
  participant Messaging as useWorkbenchRuntimeMessaging
  participant BackendAPI
  participant Executor

  User->>PaneSession: send(input, {guideWhenBusy:true})
  PaneSession->>PaneSession: split active assistant, insert guidance message
  PaneSession->>Messaging: sendRuntimePaneGuidance(request)
  Messaging->>BackendAPI: POST /guidance
  BackendAPI->>Executor: runtime.tasks.guidance RPC
  Executor->>Executor: wait for active Codex turn, steer_turn
  Executor-->>BackendAPI: guidance/turn result
  BackendAPI-->>Messaging: RuntimeGuidanceResponse
  Messaging-->>PaneSession: {sent, code, error}
  alt no_active_turn
    PaneSession->>Messaging: fallback sendRuntimeMessage
  end
Loading

Possibly related PRs

  • wecode-ai/Wegent#1636: Both PRs modify the executor's Codex turn-spawning flow in executor/src/runtime_work/handler.rs, touching the same spawn_turn/active-turn logic.
  • wecode-ai/Wegent#1666: The guidance steering relies on turn/started callback wiring in executor/src/agents/codex.rs that overlaps with this PR's shared-app-server turn notification refactor.
  • wecode-ai/Wegent#1727: Both PRs modify the same chat composer/chat input Enter-submission handling code paths.
✨ 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 codex/fix-wework-guidance-order

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.

@qdaxb
qdaxb marked this pull request as ready for review July 6, 2026 07:40
@qdaxb
qdaxb merged commit 633c9bd into main Jul 6, 2026
26 of 27 checks passed
@qdaxb
qdaxb deleted the codex/fix-wework-guidance-order branch July 6, 2026 07:40
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