Skip to content

Codex/optimize wework search - #1763

Merged
qdaxb merged 5 commits into
wecode-ai:mainfrom
FicoHu:codex/optimize-wework-search
Jul 7, 2026
Merged

qdaxb merged 5 commits into
wecode-ai:mainfrom
FicoHu:codex/optimize-wework-search

Conversation

@FicoHu

@FicoHu FicoHu commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Search results now open with the full runtime context, making it easier to jump back into the original conversation.
    • Recent search results are reused while the dialog stays open, improving repeat searches.
  • Bug Fixes

    • Search snippets are now shorter and easier to read while still highlighting the matching text.
    • The loading state and “no results” message now appear more consistently during typing.
  • Documentation

    • Updated local executor timeout guidance to reflect a longer default wait time.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds runtimeHandle.threadId to runtime task search-result addresses, introduces bounded snippet generation for search results, adds client-side result caching to the workbench search dialog, and increases the default Claude Code process timeout from 1 hour to 24 hours across code and documentation.

Changes

Runtime Search Enhancements

Layer / File(s) Summary
Runtime address includes runtimeHandle.threadId
executor/src/runtime_work/response.rs, executor/tests/app_runtime_work_contract.rs
Adds a runtime_handle_with_thread_id helper used by local_task_json and runtime_task_address to embed runtimeHandle.threadId in returned addresses; a contract test verifies the value and reads a transcript via the returned address.
Bounded search snippet generation
executor/src/runtime_work/handler.rs
Adds snippet size constants and bounded_search_snippet/byte_index_for_char helpers to trim matched message text into a size-bounded SearchSnippet with remapped match offsets, used in first_message_search_result and covered by a new unit test.
WorkbenchSearchDialog result caching and UI updates
wework/src/components/layout/WorkbenchSearchDialog.tsx, wework/src/components/layout/WorkbenchSearchDialog.test.tsx
Adds an in-memory search cache (searchCacheRef, SEARCH_CACHE_LIMIT, rememberSearchResults) and searchedQuery tracking, refines no-results status logic and input handling, removes the per-result shortcut badge, and adds tests for loading timing and cache reuse.
Search flow documentation
docs/en/developer-guide/runtime-local-work.md, docs/zh/developer-guide/runtime-local-work.md
Updates docs to describe executor-only search fan-out, the Codex runtimeHandle.threadId requirement, and frontend address-opening/caching behavior.

Claude Code Timeout Increase

Layer / File(s) Summary
Default timeout constant and test update
executor/src/agents/mod.rs
Changes DEFAULT_CLAUDE_CODE_PROCESS_TIMEOUT_SECONDS from 3600 to 24 * 60 * 60 and updates the unit test expecting the new default.
Timeout documentation updates
docs/en/user-guide/ai-devices/local-device-support.md, docs/zh/user-guide/ai-devices/local-device-support.md
Updates default timeout description to 24 hours and the example WEGENT_CLAUDE_CODE_PROCESS_TIMEOUT_SECONDS value to 172800.

Also included: an unrelated test timeout adjustment in wework/src/components/layout/DesktopWorkbenchLayout.test.tsx explicitly setting a 10000ms waitFor timeout.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant WorkbenchSearchDialog
  participant SearchCache
  participant RuntimeWorkHandler
  User->>WorkbenchSearchDialog: types query
  WorkbenchSearchDialog->>SearchCache: check cache for query
  alt cache hit
    SearchCache-->>WorkbenchSearchDialog: cached items
  else cache miss
    WorkbenchSearchDialog->>RuntimeWorkHandler: onSearchRuntimeWork(query)
    RuntimeWorkHandler-->>WorkbenchSearchDialog: results with address + runtimeHandle.threadId
    WorkbenchSearchDialog->>SearchCache: rememberSearchResults(query, items)
  end
  WorkbenchSearchDialog-->>User: render results
  User->>WorkbenchSearchDialog: select result
  WorkbenchSearchDialog->>RuntimeWorkHandler: open full runtime address
  RuntimeWorkHandler-->>WorkbenchSearchDialog: transcript / workspace context
Loading

Possibly related PRs

  • wecode-ai/Wegent#1601: Prior work adding runtimeHandle.threadId to search/open runtime task addresses used by runtime.tasks.transcript, directly related to this PR's address changes.
  • wecode-ai/Wegent#1614: Related changes to Codex/runtime task addressing preserving and using runtimeHandle.threadId instead of falling back to localTaskId.
  • wecode-ai/Wegent#1632: Introduced the Claude-specific process timeout handling in executor/src/agents/mod.rs that this PR modifies by raising the default value.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main theme of the changes: Codex-related wework search improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
executor/src/runtime_work/response.rs (1)

469-482: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate handle-building logic already exists in handler.rs.

runtime_handle_with_thread_id reimplements the same extract-object-then-insert-threadId logic as runtime_handle_json in executor/src/runtime_work/handler.rs (see context snippet: fn runtime_handle_json(link: &RuntimeTaskLink) -> Value). Both build the runtimeHandle contract that runtime_session_id_from_handle consumes downstream. Having two independent implementations risks them silently diverging (e.g., one gets updated to fall back to another handle key and the other doesn't).

Consider consolidating into a single shared helper (e.g., exposed from one module and reused by both call sites).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@executor/src/runtime_work/response.rs` around lines 469 - 482, The runtime
handle construction logic is duplicated between runtime_handle_with_thread_id
and runtime_handle_json, which risks the two versions diverging over time.
Consolidate the object-extraction-and-threadId-insertion behavior into a single
shared helper and have both response.rs and handler.rs reuse it so the
runtimeHandle contract stays consistent for runtime_session_id_from_handle and
related callers.
executor/src/runtime_work/handler.rs (1)

4024-4053: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a multi-byte/unicode test case.

The new test only uses ASCII content, where byte index and char index coincide, so it doesn't exercise the char↔byte conversion (byte_index_for_char, chars().count()) that this code was specifically written to handle safely. A test with multi-byte characters (e.g. CJK or emoji) surrounding the match would give real coverage of the boundary-safety logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@executor/src/runtime_work/handler.rs` around lines 4024 - 4053, The new test
in first_message_search_result_returns_bounded_snippet only covers ASCII, so it
does not validate the char-to-byte boundary handling in
first_message_search_result. Update this test to use multi-byte Unicode content
around the matched text (for example, emoji or CJK characters) and keep the same
assertions on snippet bounds and matchStart/matchEnd. Make sure the test still
exercises the bounded snippet path and verifies the match indices against the
returned snippet.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@executor/src/runtime_work/handler.rs`:
- Around line 4024-4053: The new test in
first_message_search_result_returns_bounded_snippet only covers ASCII, so it
does not validate the char-to-byte boundary handling in
first_message_search_result. Update this test to use multi-byte Unicode content
around the matched text (for example, emoji or CJK characters) and keep the same
assertions on snippet bounds and matchStart/matchEnd. Make sure the test still
exercises the bounded snippet path and verifies the match indices against the
returned snippet.

In `@executor/src/runtime_work/response.rs`:
- Around line 469-482: The runtime handle construction logic is duplicated
between runtime_handle_with_thread_id and runtime_handle_json, which risks the
two versions diverging over time. Consolidate the
object-extraction-and-threadId-insertion behavior into a single shared helper
and have both response.rs and handler.rs reuse it so the runtimeHandle contract
stays consistent for runtime_session_id_from_handle and related callers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4028e8e2-90c3-49f1-85c7-bea355b15e40

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc1685 and dad2c79.

📒 Files selected for processing (11)
  • docs/en/developer-guide/runtime-local-work.md
  • docs/en/user-guide/ai-devices/local-device-support.md
  • docs/zh/developer-guide/runtime-local-work.md
  • docs/zh/user-guide/ai-devices/local-device-support.md
  • executor/src/agents/mod.rs
  • executor/src/runtime_work/handler.rs
  • executor/src/runtime_work/response.rs
  • executor/tests/app_runtime_work_contract.rs
  • wework/src/components/layout/DesktopWorkbenchLayout.test.tsx
  • wework/src/components/layout/WorkbenchSearchDialog.test.tsx
  • wework/src/components/layout/WorkbenchSearchDialog.tsx

@qdaxb
qdaxb merged commit 423082c into wecode-ai:main Jul 7, 2026
28 checks passed
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