Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions cypress/component/features/mobile/MobileContentLayout.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React from 'react'
import '../../../../app/globals.css'
import { NoteList } from '@ui/web/components/features/notes/NoteList'
import { TagsPage } from '@ui/web/components/features/tags/TagsPage'

const notes = Array.from({ length: 6 }, (_, index) => ({
id: `layout-note-${index}`,
user_id: 'layout-user',
title: `Note ${index + 1}: A long title that needs more than two lines on a phone`,
description: '<p>A detailed preview with enough content to fill every available line in a narrow tile. The date and tags must remain readable.</p>',
tags: ['a-long-project-tag', 'another-long-tag', 'ideas', 'mobile'],
created_at: '2026-11-05T10:00:00Z',
updated_at: '2026-11-05T10:00:00Z',
}))

describe('Mobile content layout', { retries: 0 }, () => {
beforeEach(() => {
cy.document().then((doc) => {
doc.documentElement.style.removeProperty('font-size')
doc.documentElement.classList.remove('dark')
})
})

for (const { width, fontSize, selectionMode } of [
{ width: 320, fontSize: 16, selectionMode: false },
{ width: 390, fontSize: 16, selectionMode: false },
{ width: 320, fontSize: 20, selectionMode: false },
{ width: 320, fontSize: 20, selectionMode: true },
]) {
it(`keeps tile rows separate and dates readable at ${width}px with ${fontSize}px text and selection ${selectionMode}`, () => {
cy.viewport(width, 844)
cy.document().then((doc) => { doc.documentElement.style.fontSize = `${fontSize}px` })
cy.mount(
<div style={{ height: 650, width }}>
<NoteList notes={notes} layout="grid" selectionMode={selectionMode} isLoading={false} height={650} width={width}
onSelectNote={cy.stub()} onToggleSelect={cy.stub()} onDeleteNote={cy.stub()}
onTagClick={cy.stub()} onLoadMore={cy.stub()} hasMore={false} isFetchingNextPage={false} />
</div>
)
cy.get('[data-testid="note-card"]').should('have.length', 6).should(($cards) => {
const first = $cards[0].getBoundingClientRect()
const second = $cards[1].getBoundingClientRect()
const nextRow = $cards[2].getBoundingClientRect()
expect(second.left, 'gap between columns').to.be.greaterThan(first.right)
expect(nextRow.top, 'gap between rows').to.be.greaterThan(first.bottom)
})
cy.get('[data-testid="note-card"]').each(($card) => {
cy.wrap($card).contains('p', '05.11.2026').should('be.visible').should(($date) => {
const card = $card[0].getBoundingClientRect()
const date = $date[0].getBoundingClientRect()
const range = $date[0].ownerDocument.createRange()
range.selectNodeContents($date[0])
const text = range.getBoundingClientRect()
const tags = $card.find('[data-cy="interactive-tag"]').last()[0].getBoundingClientRect()
expect(date.top, 'date below tags').to.be.greaterThan(tags.bottom)
expect(text.bottom, 'entire date inside card').to.be.at.most(card.bottom - 8)
expect(text.top, 'date text inside its line box').to.be.at.least(date.top - 1)
expect(text.bottom, 'date text fits its line box').to.be.at.most(date.bottom + 1)
})
})
cy.screenshot(`notes-grid-${width}-${fontSize}-selection-${selectionMode}`)
})
}

it('gives tag coverage actions separate touch targets on a narrow phone', () => {
cy.viewport(320, 844)
cy.mount(
<div style={{ height: 844, width: 320 }}>
<TagsPage notes={notes} onSelectTag={cy.stub()} onRenameTag={cy.stub()} onDeleteTag={cy.stub()}
managementBlockReason="Loaded 6 of 51 notes. Load more notes and check again."
onLoadMoreNotes={cy.stub().as('loadMore')} onCheckNotes={cy.stub().as('checkNotes')} />
</div>
)
cy.get('[data-testid="tag-coverage-status"]').within(() => {
cy.contains('Counts are based on loaded and cached notes and may be incomplete.').should('be.visible')
cy.get('[role="status"]').should('contain.text', 'Loaded 6 of 51 notes')
cy.contains('button', 'Load more notes').should(($button) => {
expect($button[0].getBoundingClientRect().height, 'load touch target').to.be.at.least(44)
}).click()
cy.contains('button', 'Check loaded notes').should(($button) => {
expect($button[0].getBoundingClientRect().height, 'check touch target').to.be.at.least(44)
}).click()
cy.root().should(($panel) => {
expect($panel[0].scrollWidth, 'no horizontal overflow').to.be.at.most($panel[0].clientWidth)
})
})
cy.get('@loadMore').should('have.been.calledOnce')
cy.get('@checkNotes').should('have.been.calledOnce')
cy.get('[data-testid="tags-page"]').scrollTo('top')
cy.screenshot('tags-coverage-320')
})

it('keeps busy tag coverage actions disabled and local-cache notices readable', () => {
cy.viewport(390, 844)
cy.document().then((doc) => { doc.documentElement.classList.add('dark') })
cy.mount(
<div style={{ height: 844, width: 390 }}>
<TagsPage notes={notes} onSelectTag={cy.stub()} onRenameTag={cy.stub()} onDeleteTag={cy.stub()}
managementNotice="Some cached notes have an unknown account and are kept locally."
onLoadMoreNotes={cy.stub()} onCheckNotes={cy.stub()} loadingMoreNotes checkingNotes />
</div>
)
cy.get('[data-testid="tag-coverage-status"]').within(() => {
cy.contains('Some cached notes have an unknown account and are kept locally.').should('be.visible')
cy.contains('button', 'Loading notes…').should('be.disabled').and('have.attr', 'aria-busy', 'true')
cy.contains('button', 'Checking notes…').should('be.disabled').and('have.attr', 'aria-busy', 'true')
})
cy.screenshot('tags-coverage-busy-dark-390')
})
})
4 changes: 3 additions & 1 deletion docs/ai/design/feature-mobile-adaptation.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@ The controller retains the workspace tab while hiding its pane. The mobile tab s

The swipe action is separate from vertical scrolling and long-press selection, and it reuses single-note confirmation and deletion. Find-in-note scans title and text ranges, paints transient highlights without editing the document, and scrolls to the selected match. Browsers without custom highlights use a visual overlay; the editor title uses an outline when it is the selected match.

The notes list stores the chosen layout locally. List view retains the existing dynamic virtual rows; grid view virtualizes pairs of notes with a fixed row height and translates the visible-row index back into a note index for pagination. Both layouts use the same card, selection and swipe actions.
The notes list stores the chosen layout locally. Both layouts measure virtual rows; grid view groups pairs of notes with a minimum row height of 200 px and translates the visible-row index back into a note index for pagination. Taller content expands the row, keeping dates visible and rows separate when text is enlarged. Switching layouts resets the row measurement cache. Both layouts use the same card, selection and swipe actions.

The Tags count explanation, management status and local-cache notice share a bordered panel. Load and check actions stack as full-width, 44 px buttons on phones, with loading labels and indicators; desktop actions sit side by side.
2 changes: 2 additions & 0 deletions docs/ai/implementation/feature-mobile-adaptation.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ description: Technical implementation notes, patterns, and code guidelines for m
- `SwipeableNoteRow` reveals the existing single-note delete confirmation after a left swipe. A list allows one open swipe action; vertical gestures and selection mode do not reveal it.
- `NoteFindBar` searches title and body in reading and editing views, including matches across inline formatting. The expanded editor exposes Find in its toolbar and searches the visible body. It uses browser text highlights with a non-mutating overlay fallback, and refreshes matches when the draft changes.
- The notes sidebar switches between a list and a two-column grid, remembers the choice locally, and shows a count when a tile has additional tags. Grid rows remain virtualized and use the existing note actions.
- Grid rows use the same measured-height mechanism as list rows, with a 200 px minimum. The layout keys the measurement cache so switching views cannot reuse incompatible row sizes.
- Tags count coverage uses a bordered panel with separate explanation and status areas. Shared Button components provide stacked 44 px phone actions and loading states while preserving the existing callbacks and management guards.
8 changes: 8 additions & 0 deletions docs/ai/planning/feature-mobile-adaptation.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ description: Break down work into actionable tasks and estimate timeline for mob
- [x] Add mobile swipe-to-reveal deletion and in-note search for reading and editing.
- [x] Verify local Docker flows and focused regression tests.
- [ ] Validate touch gestures and the on-screen keyboard on physical iOS and Android browsers.

## Mobile tile and Tags layout — 2026-11-05

- [x] Reproduce tile row overlap with enlarged text and add geometry/date regressions, including selection mode.
- [x] Measure tile rows and reset measurements when switching between grid and list.
- [x] Group Tags count coverage and management messages with accessible load/check buttons.
- [x] Validate the focused component scope, web unit suite, type-check, lint and static production build.
- [ ] Confirm the updated build on a physical Android phone.
2 changes: 2 additions & 0 deletions docs/ai/requirements/feature-mobile-adaptation.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ description: Clarify the problem space, gather requirements, and define success
- A left swipe on a note in the mobile list or regular search exposes Delete; deletion uses the existing confirmation. Vertical scrolling and long-press selection must remain usable.
- Reading and editing expose an in-note search across the title and body, with match counts, highlighting and previous/next navigation. Expanded editing searches the visible body. Searching must not change the draft.
- The notes list offers a remembered list or two-column tile view. Tiles retain note opening, selection and swipe-to-delete; hidden tags are counted.
- Tile rows must remain separate and show the complete date at narrow phone widths and enlarged text sizes, including selection mode.
- Tags must group count coverage, loaded-note status and recovery actions in a readable panel with phone-sized buttons.
- Maintain the established desktop layout and functionality. Native apps are outside this change.

## Note editing canvas — 2026-10-28
Expand Down
9 changes: 9 additions & 0 deletions docs/ai/testing/feature-mobile-adaptation.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ description: Define testing approach, test cases, and quality assurance for mobi
- Mobile and desktop component checks cover short and long notes, the editable canvas, save, toolbar position, caret placement, theme and focus. A simulated safe-area inset and resized visual viewport cover the mobile navigation and keyboard layout; an additional scenario checks an image in the canvas.
- The focused mobile layout and rich-text rendering run passed 45 tests. In a broader 142-test editor run, 137 passed and five keyboard undo/redo scenarios failed or broke on macOS; one of those failures was also reproduced using the original editor files from `origin/main`.
- Type-check, ESLint, and a production build in an isolated Docker container passed. Physical iOS and Android keyboard/safe-area behavior remains to be checked on devices.

## Mobile tile and Tags layout — 2026-11-05

- Reproduced overlapping rows on unchanged `main` (`bd30c2716af`) at 320 px with a 20 px root font (125%), both with and without selection. The next row started at 205 px while the preceding card extended to 214.625 px. The same cases pass with measured row heights.
- `MobileContentLayout.cy.tsx` checks 320/390 px grids, complete dates below tags, enlarged text, selection, 44 px Tags buttons, callbacks, loading guards and cache notices. Screenshots capture the layouts.
- Focused Cypress run: 31 passed, 0 failed across the new layout spec, `MobileNotesGrid`, `NoteCard`, `NoteList`, `NoteListVirtualization` and `NoteListPagination`.
- Web unit run: 148 suites / 1,300 tests passed, including `tagsPage.test.tsx`. npm consumed the intended Jest scope flags, so this ran the full web unit suite.
- `npm run type-check`, `npx eslint . --max-warnings=0`, `git diff --check` and `npm run build` passed (exit 0). The static build used placeholder public Supabase configuration and proves compilation/export, not backend connectivity.
- Outstanding: rebuild the Android APK and confirm on the user's physical phone; no installed-app validation is claimed.
8 changes: 4 additions & 4 deletions ui/web/components/features/notes/NoteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type NoteListLayout = "list" | "grid"
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const VirtualList = ReactWindow.List as any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const useDynamicRowHeight = (ReactWindow as any).useDynamicRowHeight as (options: { defaultRowHeight: number }) => unknown
const useDynamicRowHeight = (ReactWindow as any).useDynamicRowHeight as (options: { defaultRowHeight: number; key?: string }) => unknown

// Row component props type for react-window v2
type RowComponentProps<T> = {
Expand Down Expand Up @@ -184,7 +184,7 @@ const NoteRow = memo(({ index, style, ariaAttributes, ...props }: RowComponentPr

if (layout === "grid") {
return (
<div style={style} className="grid grid-cols-2 gap-2 px-2 py-1" role="presentation">
<div style={style} className="grid min-h-[200px] grid-cols-2 gap-2 px-2 py-1" role="presentation">
{items.slice(firstIndex, firstIndex + columns).map((note, offset) => (
<div key={note.id} className="min-w-0" role="listitem" aria-posinset={firstIndex + offset + 1} aria-setsize={items.length}>
{renderNote(note)}
Expand Down Expand Up @@ -342,7 +342,7 @@ export const NoteList = memo(function NoteList({
}, [ftsHasMore, ftsLoadingMore, onLoadMoreFts, searchResultCount])

// Dynamic row height for virtualized lists - measures actual content height
const dynamicRowHeight = useDynamicRowHeight({ defaultRowHeight: 140 })
const dynamicRowHeight = useDynamicRowHeight({ defaultRowHeight: layout === "grid" ? 200 : 140, key: layout })
const dynamicSearchRowHeight = useDynamicRowHeight({ defaultRowHeight: 180 })

// Memoize item data for virtualized list (notes only)
Expand Down Expand Up @@ -507,7 +507,7 @@ export const NoteList = memo(function NoteList({
height={height}
width={width}
rowCount={(layout === "grid" ? Math.ceil(notes.length / 2) : notes.length) + (hasMore ? 1 : 0)}
rowHeight={layout === "grid" ? 200 : dynamicRowHeight}
rowHeight={dynamicRowHeight}
rowProps={itemData}
overscanCount={5}
onRowsRendered={handleNoteRowsRendered}
Expand Down
35 changes: 24 additions & 11 deletions ui/web/components/features/tags/TagsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client"

import * as React from "react"
import { MagnifyingGlass as Search, Tag as TagIcon, X } from "@phosphor-icons/react"
import { ArrowDown, ArrowClockwise, CircleNotch, Info, MagnifyingGlass as Search, Tag as TagIcon, X } from "@phosphor-icons/react"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { ThemeToggle } from "@/components/theme-toggle"
import { getTagsWithCounts, groupTagsAlphabetically } from "@core/services/tags"
type TagWithCount = { name: string; count: number }
Expand Down Expand Up @@ -200,21 +201,33 @@
</div>
</div>

<div className="mb-6 space-y-2 text-sm text-muted-foreground" data-testid="tag-coverage-status">
<p>Counts are based on loaded and cached notes and may be incomplete.</p>
{managementBlockReason && <p role="status">{managementBlockReason}</p>}
{managementNotice && <p>{managementNotice}</p>}
<section className="mb-6 shrink-0 rounded-2xl border border-border/60 bg-muted/20 p-4 sm:p-5" data-testid="tag-coverage-status" aria-labelledby="tag-coverage-heading">
<div className="flex items-start gap-3">
<Info className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" aria-hidden="true" />
<div className="min-w-0 space-y-1">
<h2 id="tag-coverage-heading" className="text-sm font-semibold text-foreground">Tag counts</h2>
<p className="text-xs leading-relaxed text-muted-foreground">Counts are based on loaded and cached notes and may be incomplete.</p>
</div>
</div>
{(managementBlockReason || managementNotice) && (
<div className="mt-3 space-y-2 rounded-xl bg-background/70 px-3 py-2.5 text-xs leading-relaxed text-muted-foreground">
{managementBlockReason && <p role="status" className="font-medium text-foreground/80">{managementBlockReason}</p>}

Check warning on line 214 in ui/web/components/features/tags/TagsPage.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use <output> instead of the "status" role to ensure accessibility across all devices.

See more on https://sonarcloud.io/project/issues?id=koreyba_EverFreeNote&issues=AaGsw16f-J3Gs6Pfymw4&open=AaGsw16f-J3Gs6Pfymw4&pullRequest=212
{managementNotice && <p>{managementNotice}</p>}
</div>
)}
{(onLoadMoreNotes || onCheckNotes) && (
<div className="flex flex-wrap gap-3">
{onLoadMoreNotes && <button type="button" className="underline" onClick={onLoadMoreNotes} disabled={loadingMoreNotes}>
<div className="mt-4 flex flex-col gap-2 sm:flex-row sm:flex-wrap">
{onLoadMoreNotes && <Button type="button" variant="secondary" className="h-11 w-full sm:w-auto md:h-9" onClick={onLoadMoreNotes} disabled={loadingMoreNotes} aria-busy={loadingMoreNotes}>
{loadingMoreNotes ? <CircleNotch className="animate-spin" aria-hidden="true" /> : <ArrowDown aria-hidden="true" />}
{loadingMoreNotes ? 'Loading notes…' : 'Load more notes'}
</button>}
{onCheckNotes && <button type="button" className="underline" onClick={onCheckNotes} disabled={checkingNotes}>
</Button>}
{onCheckNotes && <Button type="button" variant="outline" className="h-11 w-full sm:w-auto md:h-9" onClick={onCheckNotes} disabled={checkingNotes} aria-busy={checkingNotes}>
{checkingNotes ? <CircleNotch className="animate-spin" aria-hidden="true" /> : <ArrowClockwise aria-hidden="true" />}
{checkingNotes ? 'Checking notes…' : 'Check loaded notes'}
</button>}
</Button>}
</div>
)}
</div>
</section>

{/* Alphabetical Grid Navigation Bar */}
{availableLetters.length > 0 && (
Expand Down
Loading