()
| 1570 | ? this.app.escapeHtml(originalText) |
| 1571 | : originalText.replace(/</g, '<').replace(/>/g, '>'); |
| 1572 | |
| 1573 | const tooltip = document.createElement('div'); |
| 1574 | tooltip.id = 'scrubber-original-tooltip'; |
| 1575 | tooltip.className = 'scrubber-original-tooltip'; |
| 1576 | tooltip.innerHTML = ` |
| 1577 | <div class="inline-flex items-center px-1.5 py-0.5 mb-2 rounded bg-muted/50 text-muted-foreground text-[10px] font-medium uppercase tracking-wide"> |
| 1578 | Original prompt |
| 1579 | </div> |
| 1580 | <div class="text-foreground text-xs leading-relaxed" style="white-space: pre-wrap; user-select: text;">${escaped}</div> |
| 1581 | `; |
| 1582 | document.body.appendChild(tooltip); |
| 1583 | |
| 1584 | // Track interaction (e.g., text selection) to keep tooltip visible |
| 1585 | tooltip.addEventListener('mousedown', () => { |
| 1586 | this.enableScrubberPreviewSticky(false); |
| 1587 | }); |
| 1588 | |
| 1589 | this.repositionOriginalTooltip(); |
| 1590 | |
| 1591 | requestAnimationFrame(() => { |
| 1592 | tooltip.classList.add('visible'); |
| 1593 | }); |
| 1594 | |
| 1595 | this.scrubberDiffState.originalTooltipVisible = true; |
| 1596 | } |
| 1597 | |
| 1598 | hideOriginalPromptPreview() { |
| 1599 | const tooltip = document.getElementById('scrubber-original-tooltip'); |
| 1600 | if (!tooltip) return; |
| 1601 | tooltip.classList.remove('visible'); |
| 1602 | setTimeout(() => tooltip.remove(), 180); |
| 1603 | this.scrubberDiffState.originalTooltipVisible = false; |
| 1604 | } |
| 1605 | |
| 1606 | enableScrubberPreviewSticky(shouldMarkEditing = false) { |
| 1607 | this.scrubberDiffState.tooltipInteracted = true; |
| 1608 | if (shouldMarkEditing) { |
| 1609 | this.setScrubberPreviewEditing(true); |
| 1610 | } |
| 1611 | this.updateScrubberPreviewHint(); |
| 1612 | if (!this.scrubberDiffState.tooltipClickOutsideHandler) { |
| 1613 | this.scrubberDiffState.tooltipClickOutsideHandler = (e) => { |
| 1614 | const tooltip = document.getElementById('scrubber-original-tooltip'); |
| 1615 | const preview = this.app.elements.scrubberPreviewDiff; |
| 1616 | const hint = document.getElementById('scrubber-preview-hint'); |
| 1617 | const clickedInsideTooltip = tooltip && tooltip.contains(e.target); |
| 1618 | const clickedInsidePreview = preview && preview.contains(e.target); |
| 1619 | const clickedInsideHint = hint && hint.contains(e.target); |
| 1620 | if (!clickedInsideTooltip && !clickedInsidePreview && !clickedInsideHint) { |
| 1621 | this.forceHideScrubberPreview(); |
no test coverage detected