Skip to content

Fix char-boundary panic in WorkflowDataSource preview truncation (APP-5287) - #14933

Merged
vorporeal merged 3 commits into
masterfrom
factory/fix-workflow-preview-char-boundary-panic
Aug 12, 2026
Merged

Fix char-boundary panic in WorkflowDataSource preview truncation (APP-5287)#14933
vorporeal merged 3 commits into
masterfrom
factory/fix-workflow-preview-char-boundary-panic

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a panic in the AI @ context-menu Workflow data source: WorkflowDataSource::run_query built a hover-preview description for each workflow by slicing its content at a hard-coded byte offset (&content_preview[..197]) whenever the preview exceeded 200 bytes. If a multi-byte UTF-8 character (emoji, CJK, accented Latin, etc.) straddled byte 197, this slice panicked with byte index 197 is not a char boundary.

run_query reads workflows from CloudModel (Warp Drive), not from local workflow YAML, so the panic is triggered by workflow content synced from Warp Drive, not by the user's typed query. It fires when the Workflows category is opened in the @ context menu (i.e. AIContextMenuAction::CategorySelected { category: Workflows }) or when a query runs against it — not on the bare @ zero state before a category is selected.

Note: the initial report speculated this was a ByteOffset/CharOffset (crates/string-offset) misuse, but that crate is not on this code path — the actual bug is the raw byte slice shown above.

Linked Issue

Fixes APP-5287

Changes

  • app/src/search/ai_context_menu/workflows/data_source.rs: replace the raw &content_preview[..197] slice with the existing safe_truncate helper (app/src/search/ai_context_menu/mod.rs), which floors to the nearest valid UTF-8 char boundary. This is the same helper already used by the sibling code/notebooks/rules/workflows search_item.rs renderers, so all ai_context_menu truncation now goes through one path.

I audited the other ai_context_menu data sources (blocks, rules, skills, conversations, notebooks) for the same raw-byte-slice pattern; none of them have it — notebooks/data_source.rs already used a char_indices-based safe truncation, and the search_item.rs renderers already used safe_truncate. Only workflows/data_source.rs had the bug, so the fix is scoped to that one line.

Testing

This is a one-line logic fix with no unit test attached; coverage instead comes from the GUI verification below, run on an equivalent fix branch:

  • cargo nextest run -p warp -E 'test(search::ai_context_menu)' — passing, no regressions.
  • cargo clippy -p warp --all-targets --tests -- -D warnings — clean.
  • ./script/format — clean (no changes needed beyond the edit).

Screenshots / Videos

Captured on an equivalent fix branch (same repro workflow, same machine):

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: Fixed a crash in the AI @ context menu when a workflow's content included multi-byte characters (emoji, CJK, accented Latin) near the preview truncation boundary.

Conversation: https://staging.warp.dev/conversation/b38216ff-032f-47cf-96bf-c7b058b89806
Run: https://oz.staging.warp.dev/runs/019ff0fd-e7e7-73c8-a339-b9ef2471b442

This PR was generated with Oz.

WorkflowDataSource::run_query truncated the workflow description
preview with a hard-coded byte slice (&content_preview[..197]),
which panics when a multi-byte UTF-8 character straddles byte 197
(e.g. workflow content containing emoji, CJK, or accented Latin
text over 200 bytes).

Replace the raw slice with the existing safe_truncate helper (also
used by the sibling code/notebooks/rules/workflows search_item.rs
renderers), and add a regression test with content matching the
Sentry-reported failure mode.

Fixes APP-5287.

Co-Authored-By: Warp Agent <agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Aug 11, 2026
@warp-agent-staging
warp-agent-staging Bot requested a review from vorporeal August 11, 2026 13:42
Assert accessibility_label() text to confirm the truncation floors to
the char boundary and appends exactly one ellipsis, rather than only
checking that a result was returned.

Co-Authored-By: Warp Agent <agent@warp.dev>
@vorporeal
vorporeal marked this pull request as ready for review August 11, 2026 13:55
Comment thread app/src/search/ai_context_menu/workflows/data_source_tests.rs Outdated
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

Heads up: this PR and #14935 are two independent fixes for the same panic (APP-5287), produced by two parallel agent runs. Both replace the raw &content_preview[..197] slice with safe_truncate and add a multibyte regression test. Only one should be merged.

Differences worth weighing:

  • This PR is out of draft and adds a second short_content_is_not_truncated test plus a wider audit of the other ai_context_menu data sources.
  • [APP-5287] Fix char-boundary panic in workflow AI context menu preview #14935 is still draft but carries visual proof from a real GUI run: a recording of the @ menu working on the fixed branch, a contrast recording of master crashing on the same click, and the client log with the verbatim panic at data_source.rs:69.
  • One factual correction that applies to this PR's description: the panic does not fire on the bare @ zero state. Verification on a real build showed the crash fires when the Workflows category is opened, or when a query runs against WorkflowDataSource. Also note run_query reads workflows from CloudModel/Warp Drive, not from local workflow YAML, which matters for anyone reproducing this by hand.

@vorporeal

Copy link
Copy Markdown
Contributor

hey @warp-agent can you address my comment, and close the other PR?

@warp-local-for-testing-only

Copy link
Copy Markdown

Your GitHub account is not connected to Warp. Connect it here.

@warp-local-for-testing-only

Copy link
Copy Markdown

Oz couldn't complete this task because required inputs, permissions, or resources were invalid or unavailable.

Error Details:
Failed to execute task: container exited with non-zero status: 1

@vorporeal

Copy link
Copy Markdown
Contributor

hey @warp-agent can you address my review comment, and close the other PR?

@warp-local-for-testing-only

Copy link
Copy Markdown

Your GitHub account is not connected to Warp. Connect it here.

David is confident this fixes the issue and doesn't expect a future
regression, so drop the unit test and keep the PR to the one-line
safe_truncate swap.

Co-Authored-By: Warp Agent <agent@warp.dev>
@vorporeal
vorporeal enabled auto-merge (squash) August 12, 2026 00:18
@vorporeal
vorporeal merged commit 87a4e4b into master Aug 12, 2026
33 checks passed
@vorporeal
vorporeal deleted the factory/fix-workflow-preview-char-boundary-panic branch August 12, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants