Skip to content

Proofreading: add text copying and automatic fix application #20

@michaelbeijer

Description

@michaelbeijer

Summary

Two enhancements to the batch proofreading feature in the Reports tab:

  1. Allow selecting and copying text from proofreading issue cards
  2. Add an "Auto-fix" mode that applies suggested corrections directly to target segments

1. Enable text selection and copying in issue cards

Current behaviour

  • Issue cards in the Reports tab display segment number, issue description, and suggestion text
  • Text cannot be selected, right-clicked, or copied — the entire card is a click target for navigation
  • This makes it impossible to copy a suggestion and manually paste it into the target

Desired behaviour

  • The issue description and suggestion text should be selectable and copyable
  • Right-click should show a context menu with at least "Copy" (or the standard Windows text selection context menu)
  • Clicking the segment number / header area should still navigate to the segment
  • Alternatively, add a small copy button (📋) next to the suggestion text

Implementation notes

The issue cards are built with Label controls in ReportsControl.cs (lines 257–377). Labels don't support text selection. Options:

  • Replace Label with RichTextBox set to ReadOnly = true, BorderStyle = None, matching background colour
  • Or add a "Copy suggestion" link/button that copies issue.Suggestion to the clipboard
  • Keep the card-level click handler for navigation, but don't let it swallow clicks on the text area

2. Automatic proofreading (auto-fix mode)

Current behaviour

  • Proofreading results are advisory only — the user must manually navigate to each segment and apply fixes
  • Suggestions often contain the corrected text, e.g.:
    • "Suggestion: Rewrite as follows: De kat zat op de mat."
    • "Suggestion: Reposition to keep the sentence intact: Het was een mooie dag."
    • "Suggestion: Change 'word' to 'correct word'"

Desired behaviour

Add a second proofreading mode (or a post-proofreading action) that automatically applies suggested corrections to the target segments. The flow would be:

  1. User runs proofreading as normal (or selects "Proofread & Auto-fix")
  2. The same numbered issue cards appear in the Reports tab
  3. For segments with issues, the system extracts the corrected text from the suggestion and writes it into the target segment
  4. The segment status changes to "Draft" (not "Confirmed") so the user can review
  5. Issue cards could show a before/after diff or indicate "Auto-fixed ✓"

Extracting corrected text from suggestions

The LLM response format (parsed in ProofreadingPrompt.cs ParseBatchResponse()) currently captures a free-text Suggestion: field. To make auto-fix reliable, we need the LLM to return the complete corrected target text separately from the explanation.

Proposed approach — extend the LLM output format:

Change the required response format from:

[SEGMENT 0001] ISSUE
Issue: Missing article before "huis"
Suggestion: Rewrite as follows: Het huis is groot.

To:

[SEGMENT 0001] ISSUE
Issue: Missing article before "huis"
Suggestion: Add the definite article "het" before "huis"
Corrected: Het huis is groot.

This adds a Corrected: line that contains the full replacement target text, making extraction unambiguous. The parser in ProofreadingPrompt.cs would need a new regex:

var correctedPattern = new Regex(@"^\s*Corrected\s*:\s*(.+)", RegexOptions.IgnoreCase);

And ProofreadingIssue would get a new field:

public string CorrectedText { get; set; }

Applying the fix

In AiAssistantViewPart.cs, after receiving a SegmentProofread event with a non-empty CorrectedText:

if (autoFix && !string.IsNullOrEmpty(issue.CorrectedText))
{
    // Navigate to the segment
    _activeDocument.SetActiveSegmentPair(issue.ParagraphUnitId, issue.SegmentId, true);
    // Get the active segment pair
    var segPair = _activeDocument.ActiveSegmentPair;
    // Replace target text
    segPair.Target.Clear();
    segPair.Target.Add(issue.CorrectedText);
    // Set to draft so user can review
    segPair.Properties.ConfirmationLevel = ConfirmationLevel.Draft;
}

(The exact Trados SDK API for modifying segment text will need verification — it may require using ISegment methods or the document's ISegmentPair API.)

UI for auto-fix mode

Options:

  • A toggle checkbox in the batch proofreading controls: ☐ Auto-fix segments
  • Or a separate button: [Proofread] vs [Proofread & Fix]
  • Or a post-run button in the Reports tab: [Apply All Fixes] that processes all issues with a CorrectedText

Safety considerations

  • Only apply fixes where CorrectedText is non-empty and different from the current target
  • Set confirmation level to Draft, never Confirmed — the user must review
  • Show a summary: "Applied X fixes to Y segments"
  • The existing "check off" mechanism (checkboxes on cards) could be used to selectively apply fixes

Priority

  1. Text copying — quick win, improves usability immediately
  2. Auto-fix — larger feature, needs prompt format extension + SDK integration

Labels

Enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions