Skip to content

[00548] DiffViewerMobileInlineMode#4621

Merged
dcrjodle merged 5 commits into
developmentfrom
tendril/00548-DiffViewerMobileInlineMode
Jun 22, 2026
Merged

[00548] DiffViewerMobileInlineMode#4621
dcrjodle merged 5 commits into
developmentfrom
tendril/00548-DiffViewerMobileInlineMode

Conversation

@dcrjodle

Copy link
Copy Markdown
Collaborator

Fixes #4583

Summary

Changes

Implemented mobile-responsive behavior for the DiffView widget that automatically switches to unified (inline) mode on narrow viewports (< 768px) to improve code readability on mobile devices. Added comprehensive test coverage for the new mobile detection logic.

API Changes

  • useIsMobile hook (exported) — New React hook that detects mobile viewports using window.matchMedia("(max-width: 767px)") with SSR-safe initialization and efficient event-based updates

Files Modified

Implementation:

  • src/widgets/Ivy.Widgets.DiffView/frontend/src/DiffView.tsx — Added useIsMobile hook, overrides viewType to "unified" on mobile, auto-enables word wrap on mobile

Tests:

  • src/widgets/Ivy.Widgets.DiffView/frontend/src/useIsMobile.test.ts — Unit tests for mobile detection logic and media query behavior
  • src/widgets/Ivy.Widgets.DiffView/frontend/src/DiffView.test.tsx — Component-level tests for mobile viewport overrides

Configuration:

  • src/widgets/Ivy.Widgets.DiffView/frontend/package.json — Added vitest dependency and test script

Commits

  • d51a0fd Add mobile-friendly inline diff mode for DiffView widget
  • e293df1 Update pnpm lockfile after adding vitest dependency
  • 3b97f49 Fix TypeScript errors in test files
  • 69ee79f Add test environment configuration for DiffView widget

dcrjodle and others added 5 commits June 22, 2026 08:55
Implement automatic viewport detection that forces unified (inline)
view mode on mobile devices (< 768px) to prevent compressed split-view
on narrow screens. Also enable word wrap automatically on mobile.

Changes:
- Add useIsMobile hook using window.matchMedia for efficient breakpoint detection
- Override viewType to "unified" on mobile regardless of prop value
- Auto-enable word wrap on mobile viewports
- Add unit tests for hook logic and component behavior
- Update package.json with vitest dependency for testing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove unused imports and add missing afterEach import to make tests
compile cleanly with tsc strict mode.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add happy-dom test environment and vitest config to enable tests to
run with DOM APIs (window.matchMedia) available.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…pdown

The previous mobile detection used a window-level media query, so a DiffView
embedded in a panel narrower than the viewport never switched to inline mode
(it saw a "wide" window and tried to render a split that had no room). Replace
useIsMobile with useIsNarrow, which measures the widget's own container via a
ResizeObserver and falls back to unified (inline) view + word wrap only when the
container itself is below 768px.

On a narrow container with multiple files, collapse the stacked file headers
into a sticky "Jump to file" dropdown that scrolls to the chosen file (all diffs
still render — navigation only). Per-file metadata is derived once and shared by
the dropdown and the file list.

Tests now render the real component/hook (via react-dom createRoot, mocked
ResizeObserver) instead of asserting on mock shadows, covering container-width
detection, split/unified switching, and dropdown visibility.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dcrjodle dcrjodle merged commit 2fc64f4 into development Jun 22, 2026
9 checks passed
@artem-ivy-ai

Copy link
Copy Markdown
Collaborator

Staging removed

Staging environment has been deleted for this PR.

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.

Code changes viewer widget needs mobile responsive design (DiffViewer)

2 participants