-
Notifications
You must be signed in to change notification settings - Fork 5
[Outlook] Use selected email text as input instead of full body - #2039
Draft
manzke wants to merge 1 commit into
Draft
[Outlook] Use selected email text as input instead of full body #2039manzke wants to merge 1 commit into
manzke wants to merge 1 commit into
Conversation
Adds a getSelectedDataAsync reader to outlookMailContext.js, threads selectedText through the mail-context snapshot and combineUserTextWithEmailContext (selection takes precedence over the full body when non-empty), and refreshes the selection right before send since Office.js has no selection-changed event. The context banner shows a one-click "Use full email instead" / "Use selection" toggle. Closes #1448. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TTJ57JJa6dWa8HTZrhV5kS
@github-actions
github-actions
Bot
added
documentation
Improvements or additions to documentation
frontend
labels
Jul 14, 2026
5 tasks
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
Closes #1448.
When a user highlights text inside an email, the Outlook add-in now uses just the selection as the message context instead of always injecting the full email body.
outlookMailContext.js: addsgetSelectedDataAsync(item)(soft-fails tonull, never rejects) and includesselectedTextin the mail-context snapshot. AddsfetchCurrentSelectedText()for a fresh, pre-send re-read — Office.js has no "selection changed" event, so a snapshot taken on mount can go stale the moment the user changes their highlight.buildChatApiMessages.js:combineUserTextWithEmailContextnow acceptscurrentSelectedTextand prefers it overcurrentBodyTextwhen non-empty; falls back to the body otherwise (unchanged behavior when there's no selection).useOutlookMailContextSnapshot.js: adds auseSelectiontoggle (defaults totrue, resets on email change likeincludeBody).buildSnapshotOverride()is now async and re-reads the live selection right before send.useOfficeChatAdapter.js: threadsctx.selectedTextthrough tocombineUserTextWithEmailContext.OfficeMailContextBanner.jsx/OfficeContextStrip.jsx: shows "Using selected text (N chars)" with a one-click "Use full email instead" toggle (and the reverse), and updates the collapsed summary line.OfficeChatPanel.jsx: forwards the new toggle and includes selection text in the live token-count estimate.Scope: mail-only (matches the issue's acceptance criteria) — pinned/multi-selected emails and appointment (calendar) items are unaffected and always use their full body.
Acceptance criteria
getSelectedDataAsyncnot present →null).Test plan
npx jest --config tests/config/jest.config.js tests/unit/client— 153/153 passing, including new/updated coverage inoutlook-mail-context.test.jsx,office-build-chat-api-messages.test.jsx, anduse-outlook-mail-context-snapshot.test.jsx.npx eslinton all changed files — no errors (pre-existing unrelated warnings only).npx prettier --writeon all changed files — no changes needed.🤖 Generated with Claude Code
https://claude.ai/code/session_01TTJ57JJa6dWa8HTZrhV5kS
Generated by Claude Code