Skip to content

Navigation Menu

Sign in
Sign up

[Outlook] Use selected email text as input instead of full body #1448

Open
Labels

Description

Summary

When a user highlights text inside an email and starts a chat, they expect the add-in to act on just the selection, not the entire email body. Today the full body is always shoved into the prompt, which is noisy and breaks token budgets on long threads.

Current behavior

client/src/features/office/utilities/outlookMailContext.js:

  • getBodyTextAsync() (lines 16–31) reads the full email via item.body.getAsync(Office.CoercionType.Text, ...).
  • fetchCurrentMailContext() (lines 84–138) returns { bodyText, subject, itemId, attachments }. There is no notion of a selection.

client/src/features/office/utilities/buildChatApiMessages.js:

  • combineUserTextWithEmailBody() (lines 71–77) unconditionally appends the full body under --- Current email ---.

The Office.js API for selection in read mode is Office.context.mailbox.item.getSelectedDataAsync(Office.CoercionType.Text, callback) — currently unused.

Proposed change

  1. In outlookMailContext.js, add getSelectedTextAsync() using item.getSelectedDataAsync(Office.CoercionType.Text, ...). Resolve to null on missing/empty selection (don't reject — selection-not-supported should be a soft fallback).
  2. Extend fetchCurrentMailContext() to return selectedText alongside bodyText.
  3. In buildChatApiMessages.combineUserTextWithEmailBody() (or a new helper), prefer selectedText when non-empty; otherwise fall back to bodyText.
  4. Surface the choice in the UI: if a selection exists, show a chip / banner reading "Using selected text (N chars) — switch to full email" (ties into issue: Review attachments / show like uploaded files).
  5. Persist the user's last choice (use-selection vs use-full-body) per session.

Acceptance criteria

  • Highlighting text in the email and opening the add-in produces a prompt that uses only the selection.
  • With no selection, behaviour is identical to today (full body used).
  • The user can override the default per message (one-click toggle).
  • Selection text is refreshed when the user re-runs (not cached stale).
  • Works in both read mode and compose mode where the API supports it.

Files

  • client/src/features/office/utilities/outlookMailContext.js
  • client/src/features/office/utilities/buildChatApiMessages.js
  • client/src/features/office/hooks/useOfficeChatAdapter.js
  • client/src/features/office/hooks/useOutlookMailContext.js
  • client/src/features/office/components/OfficeChatPanel.jsx

Source

User feedback, 2026年05月13日.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /