Skip to content

FEAT: Block GUI sends when target doesn't support the modality#4

Closed
romanlutz wants to merge 587 commits into
mainfrom
gui-modality-check
Closed

FEAT: Block GUI sends when target doesn't support the modality#4
romanlutz wants to merge 587 commits into
mainfrom
gui-modality-check

Conversation

@romanlutz
Copy link
Copy Markdown
Owner

Summary

The GUI previously didn't tell users when a target doesn't support a modality they're sending (e.g., attaching an image to a text-only target, or applying a text-to-image converter against a text-only target). This resulted in cryptic backend errors.

This PR exposes target input modality capabilities to the frontend and blocks sends with a clear warning when there's a mismatch.

Changes

Backend

  • pyrit/backend/models/targets.py — Added supported_input_data_types: list[str] to TargetInstance DTO
  • pyrit/backend/mappers/target_mappers.py — Flatten input_modalities from TargetCapabilities into the new field

Frontend — Modality validation

  • frontend/src/types/index.ts — Added supported_input_data_types to TargetInstance type
  • frontend/src/components/Chat/converterTypes.ts — Added file → binary_path mapping; added outputDataType to PieceConversion
  • frontend/src/components/Chat/ChatInputArea.tsx — Validates attachment types AND converter output types against target capabilities; disables send button with warning when mismatched
  • frontend/src/components/Chat/ChatWindow.tsx — Passes converterOutputDataTypes to ChatInputArea
  • frontend/src/components/Chat/ConverterPanel/ConverterPanel.tsx — Passes selected converter's output type to ConverterPreview
  • frontend/src/components/Chat/ConverterPanel/ConverterPreview.tsx — Includes outputDataType in PieceConversion

Frontend — Input area styling

  • Textarea auto-grows with content, capped at 60vh (solo) or 30vh each (when conversion active)
  • Both textareas scroll with matching custom scrollbar styling
  • Clear conversion button moved below send button with tooltip
  • Attach/converter buttons have round borders for consistency
  • Consistent badge indentation between Original and Converted

Tests

  • 3 new backend mapper tests for supported_input_data_types
  • 9 new frontend tests covering: text-only target + image, image-capable target, no target, audio on text+image, multiple unsupported types, send blocked, file/binary_path, converter output blocking, converter output supported

romanlutz and others added 30 commits February 25, 2026 05:49
…oft#1389)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…icrosoft#1397)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…crosoft#1402)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Anandan Sundar <205880232+anasundar_microsoft@users.noreply.github.com>
…osoft#1394)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t#1408)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…crosoft#1390)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ions (microsoft#1395)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dule init (microsoft#1428)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: romanlutz <10245648+romanlutz@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ntication (microsoft#1404)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…#1420)

Co-authored-by: Roman Lutz <romanlutz@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Victor Valbuena <50061128+ValbuenaVC@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…icrosoft#1429)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…LOG, PLE, Q, RSE, SLOT (microsoft#1412)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Roman Lutz <romanlutz@users.noreply.github.com>
behnam-o and others added 29 commits April 30, 2026 02:09
…h labels (microsoft#1670)

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Tejas Saubhage <tsaubhage0007@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rosoft#1653)

Co-authored-by: thirteeneight <purple.format.2o@icloud.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
…crosoft#1665)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…soft#1676)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ry lecture, journalist interview) (microsoft#1677)

Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: hannahwestra25 <hannahwestra@microsoft.com>
Co-authored-by: Behnam <60201681+behnam-o@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: varunj-msft <vjoginpalli@microsoft.com>
Co-authored-by: Maifee Ul Asad <29339330+maifeeulasad@users.noreply.github.com>
Co-authored-by: tejas_0007 <102517877+tejas0077@users.noreply.github.com>
Co-authored-by: Tejas Saubhage <tsaubhage0007@gmail.com>
Co-authored-by: Miroslav Horacek <115625094+thirteeneight@users.noreply.github.com>
Co-authored-by: thirteeneight <purple.format.2o@icloud.com>
Co-authored-by: Richard Lundeen <137218279+rlundeen2@users.noreply.github.com>
Co-authored-by: jsong468 <songjustin@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Behnam Ousat <behnamousat@microsoft.com>
Co-authored-by: hannahwestra25 <hannahwestra@microsoft.com>
…on tests, and endpoint target deprecation (microsoft#1672)

Co-authored-by: Roman Lutz <romanlutz@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
)

Co-authored-by: Behnam Ousat <behnamousat@microsoft.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Expose supported_input_data_types from TargetCapabilities through the
backend DTO and mapper so the frontend knows which input modalities a
target accepts. ChatInputArea now shows a non-blocking warning when
the user attaches a file whose type (image, audio, video, file) is
not in the target's supported input data types.

Changes:
- Add supported_input_data_types field to TargetInstance backend model
- Flatten input_modalities in target_object_to_instance mapper
- Add supported_input_data_types to frontend TargetInstance type
- Add file->binary_path mapping in converterTypes
- Derive unsupported attachment types in ChatInputArea and show warning
- Add backend mapper tests and frontend component tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change the unsupported modality warning from non-blocking to blocking:
- Disable the send button when unsupported attachment types are present
- Guard handleSend against unsupported types
- Update warning text to instruct user to remove the attachment
- Update tests to verify send is disabled

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extend modality validation to also check converter output data types,
not just raw attachment types. When a converter transforms text into
an unsupported type (e.g., text-to-image on a text-only target), the
send button is now disabled with a warning.

Changes:
- Add outputDataType to PieceConversion interface
- Pass output type from ConverterPanel through ConverterPreview
- Pass converterOutputDataTypes from ChatWindow to ChatInputArea
- Validate converter outputs against target supported_input_data_types
- Update all affected tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Increase textInput and convertedTextarea maxHeight from 96px/80px
  to 30vh each, allowing each to use up to ~30% of viewport height
- Remove JS-side 96px cap on auto-resize so CSS maxHeight controls it
- Add matching webkit scrollbar styling to convertedTextarea
- Use alignItems flex-start on both rows so they grow naturally

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a conversion is active, both textareas now cap at 15vh each
(half of the 30vh total) via inline style overrides. Without a
conversion, the original textarea gets the full 30vh.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Wrap both original and converted textareas in a single scrollable
  container (textScrollArea) with max-height 60vh and resize: vertical
- Textareas grow naturally inside it with overflow hidden (no per-textarea
  scrollbars), the outer container handles scrolling
- Move clear-conversion button to columnRight below send with tooltip
- Both textareas share space equally within the scrollable area

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove overflow:hidden from inputWrapper that was blocking scroll
- Add clearConversionButton style with circular border (matches send
  button shape but uses subtle neutral colors for discoverability)
- Increase columnRight gap to spacingVerticalS for more breathing room
  between info icon and send button
- Add marginRight to convertedBadge matching originalBadge for
  consistent indentation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Textarea sizing:
- Each textarea auto-resizes via JS (height = scrollHeight) and is
  capped by CSS max-height with overflowY: auto for scrolling
- Original textarea: 60vh when solo, 30vh when conversion active
  (via textInputShared class toggled with mergeClasses)
- Converted textarea: 30vh with matching scrollbar styling
- Both use identical webkit scrollbar styles
- Converted textarea also auto-resizes via its own ref + useLayoutEffect

Button styling:
- Attach and converter buttons get round border (iconButton)
- Clear conversion button has distinct circular style with subtle border
- More gap between attach/converter buttons (spacingVerticalS)
- More gap in columnRight between info/send/clear (spacingVerticalS)

Badge alignment:
- convertedBadge now has marginRight matching originalBadge

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz closed this May 6, 2026
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.