feat: carry selected excerpt through composer integration references - #1024
Draft
adriandemian wants to merge 6 commits into
Draft
feat: carry selected excerpt through composer integration references#1024adriandemian wants to merge 6 commits into
adriandemian wants to merge 6 commits into
Conversation
Resolve conflicts from the selected-excerpt composer work against upstream: - keep both provider_unavailable_skips (main) and the selected-excerpt prompt helpers (workspace) - drop the inline chat_service_queue test module in favour of main's extracted chat_service_queue_tests.rs - update ComposerIntegrationReference literals added upstream for the three new selected_* fields
…rences Escape every interpolated value in format_selected_excerpt_block via the shared chat_service::escape_attr helper so an excerpt containing a literal </selected_context> cannot close the untrusted-context fence and a quote in selected_source_path cannot break out of its attribute. Drop structurally unsafe attribute values (empty/NUL/CR/LF) and clamp the excerpt server-side at 16 KiB on a UTF-8 character boundary. Also pass expandable_references to append_selected_excerpts_for_prompt so references already recorded as BudgetExceeded skips no longer bypass the reference count cap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added support for carrying user-selected excerpt text from artifact surfaces (tickets, PRs, Granola notes) through the chat composer into agent prompt expansion. Three new optional fields on
ComposerIntegrationReference:selectedExcerpt,selectedSourcePath, andselectedRangeLabel.Excerpt text is appended to the expanded prompt even when no full-expansion service is available for that provider (e.g., ClickUp), and is rendered as a clearly labeled
<selected_context>fence with fully escaped content to prevent injection.User Impact
Agents can now see relevant context the user highlights from artifact surfaces without relying on provider expansion services to be wired. The selected text is marked as
untrusted external contextand never treated as instructions.Technical Context
Frontend (
frontend/src/api/chat.ts,frontend/src/components/agents/composer/agentComposerCore.ts):ComposerIntegrationReferenceCOMPOSER_SELECTED_EXCERPT_MAX_LENGTH = 4000) and safety checks innormalizeComposerIntegrationReferencesBackend (
src-tauri/src/domain/services/message_queue.rs):Defaultderive added; all existing literals updatedExpansion (
src-tauri/src/application/integration_reference_expansion.rs):append_selected_excerpts_for_prompt()appends excerpts after standard provider expansions, remaining withinMAX_TOTAL_INTEGRATION_REFERENCE_BYTESbudgetformat_selected_excerpt_block()renders<selected_context provider="..." kind="..." id="..." source="..." range="...">fence with every value escaped viaescape_attr()(body and attributes both escaped)safe_selected_attribute_value()validatesselected_source_pathandselected_range_label, dropping values with null bytes or newlinesclamp_selected_excerpt()truncates on a UTF-8 character boundary (server-side max 16 KiB, matchingMAX_SELECTED_EXCERPT_BYTES)BudgetExceededduring the expansion phaseTests: Comprehensive coverage added to
integration_reference_expansion_tests.rs(body injection, attribute breakout, newline filtering, character-boundary clamping, budget interaction); mechanical struct-literal updates across ~23 test files.Risks / Follow-Ups
untrusted external contextin the prompt; agents should not execute or treat as instructions.Generated by RalphX
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.