Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: distinguish text edits without relying on color

Adam Eivy2369005729c0
diff --git a/client/src/components/ui/InlineDiff.jsx b/client/src/components/ui/InlineDiff.jsx
index 2795c923f3..03f636911f 100644
--- a/client/src/components/ui/InlineDiff.jsx
+++ b/client/src/components/ui/InlineDiff.jsx
@@ -26,22 +26,21 @@ const InlineDiff = memo(function InlineDiff({ oldText, newText, emptyLabel = 'No
const { tooLarge, oldRuns, newRuns } = diffWords(oldStr, newStr);
- if (tooLarge) {
- return (
- <div className="font-mono text-xs p-4 space-y-2 bg-port-bg">
+ return (
+ <div className="font-mono text-xs p-4 space-y-2 bg-port-bg">
+ {tooLarge && (
<div className="text-gray-500 text-[11px] uppercase tracking-wider">
Diff too large for inline highlighting — both versions shown in full
</div>
- <div className="text-port-error leading-relaxed whitespace-pre-wrap">{oldStr}</div>
- <div className="text-port-success leading-relaxed whitespace-pre-wrap">{newStr}</div>
+ )}
+ <div>
+ <div className="text-[10px] uppercase tracking-wider text-gray-500 mb-1">Before</div>
+ <div className="text-port-error leading-relaxed whitespace-pre-wrap">{tooLarge ? oldStr : renderRuns(oldRuns, false)}</div>
+ </div>
+ <div>
+ <div className="text-[10px] uppercase tracking-wider text-gray-500 mb-1">After</div>
+ <div className="text-port-success leading-relaxed whitespace-pre-wrap">{tooLarge ? newStr : renderRuns(newRuns, true)}</div>
</div>
- );
- }
-
- return (
- <div className="font-mono text-xs p-4 space-y-2 bg-port-bg">
- <div className="text-port-error leading-relaxed whitespace-pre-wrap">{renderRuns(oldRuns, false)}</div>
- <div className="text-port-success leading-relaxed whitespace-pre-wrap">{renderRuns(newRuns, true)}</div>
</div>
);
});
diff --git a/client/src/components/ui/InlineDiff.test.jsx b/client/src/components/ui/InlineDiff.test.jsx
index 48df358dc1..e0dfb926fc 100644
--- a/client/src/components/ui/InlineDiff.test.jsx
+++ b/client/src/components/ui/InlineDiff.test.jsx
@@ -17,6 +17,8 @@ describe('InlineDiff', () => {
it('renders both stacked rows when the texts differ', () => {
const { container } = render(<InlineDiff oldText="The cat sat" newText="The dog sat" />);
expect(screen.queryByText('No changes.')).not.toBeInTheDocument();
+ expect(screen.getByText('Before')).toBeInTheDocument();
+ expect(screen.getByText('After')).toBeInTheDocument();
// Two stacked diff rows — the red (removed) and green (added) divs.
expect(container.querySelectorAll('.text-port-error.leading-relaxed')).toHaveLength(1);
expect(container.querySelectorAll('.text-port-success.leading-relaxed')).toHaveLength(1);
@@ -24,9 +26,9 @@ describe('InlineDiff', () => {
it('highlights only the changed words inside each row, not the unchanged ones', () => {
const { container } = render(<InlineDiff oldText="The cat sat" newText="The dog sat" />);
- // Removed-word span lives inside the red row.
- const removedSpans = container.querySelectorAll('.text-port-error .bg-port-error\\/20');
- const addedSpans = container.querySelectorAll('.text-port-success .bg-port-success\\/20');
+ // Native edit semantics distinguish changes without relying on color.
+ const removedSpans = container.querySelectorAll('del');
+ const addedSpans = container.querySelectorAll('ins');
expect(removedSpans).toHaveLength(1);
expect(addedSpans).toHaveLength(1);
expect(removedSpans[0].textContent).toBe('cat');
@@ -44,6 +46,8 @@ describe('InlineDiff', () => {
const buildHuge = (prefix) => Array.from({ length: 2500 }, (_, i) => `${prefix}${i}`).join(' ');
const { container } = render(<InlineDiff oldText={buildHuge('a')} newText={buildHuge('b')} />);
expect(screen.getByText(/Diff too large/i)).toBeInTheDocument();
+ expect(screen.getByText('Before')).toBeInTheDocument();
+ expect(screen.getByText('After')).toBeInTheDocument();
// No per-word highlight spans — just the two flat color blocks.
expect(container.querySelectorAll('.bg-port-error\\/20, .bg-port-success\\/20')).toHaveLength(0);
});
diff --git a/client/src/components/ui/SideBySideDiff.test.jsx b/client/src/components/ui/SideBySideDiff.test.jsx
index 29354652f9..368f5cdfaa 100644
--- a/client/src/components/ui/SideBySideDiff.test.jsx
+++ b/client/src/components/ui/SideBySideDiff.test.jsx
@@ -18,8 +18,8 @@ describe('SideBySideDiff', () => {
it('highlights removed words on the left and added words on the right', () => {
const { container } = render(<SideBySideDiff oldText="The cat sat" newText="The dog sat" />);
- const removed = container.querySelectorAll('.bg-port-error\\/20');
- const added = container.querySelectorAll('.bg-port-success\\/20');
+ const removed = container.querySelectorAll('del');
+ const added = container.querySelectorAll('ins');
expect(removed).toHaveLength(1);
expect(added).toHaveLength(1);
expect(removed[0].textContent).toBe('cat');
diff --git a/client/src/components/ui/diffRuns.jsx b/client/src/components/ui/diffRuns.jsx
index 31476a3c08..4db436f10f 100644
--- a/client/src/components/ui/diffRuns.jsx
+++ b/client/src/components/ui/diffRuns.jsx
@@ -1,15 +1,16 @@
/**
* Render the `{ text, changed }` runs from `diffWords` into React nodes —
- * changed runs get a red (removed) or green (added) highlight span, unchanged
+ * changed runs get native deletion/insertion marks and colored highlights, unchanged
* runs render as bare text. Shared by `InlineDiff` (stacked) and
* `SideBySideDiff` (columnar) so the highlight markup stays in one place.
*/
-export const renderRuns = (runs, added) =>
- runs.map((run, i) => (run.changed ? (
- <span key={i} className={added ? 'bg-port-success/20 text-port-success' : 'bg-port-error/20 text-port-error'}>
+export const renderRuns = (runs, added) => runs.map((run, i) => {
+ if (!run.changed) return run.text;
+ const Mark = added ? 'ins' : 'del';
+ return (
+ <Mark key={i} className={added ? 'bg-port-success/20 text-port-success underline' : 'bg-port-error/20 text-port-error line-through'}>
{run.text}
- </span>
- ) : (
- run.text
- )));
+ </Mark>
+ );
+});