Skip to content

feat: mention database row page#403

Draft
appflowy wants to merge 18 commits into
mainfrom
codex/mention-search
Draft

feat: mention database row page#403
appflowy wants to merge 18 commits into
mainfrom
codex/mention-search

Conversation

@appflowy

@appflowy appflowy commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds server-backed mention search to the editor mention panel, including support for people, pages, databases, database rows, dates, and external links.

Details

  • Wires the workspace mention search API through app, modal, document, database, and editor contexts.
  • Adds mention result mapping/rendering for database and database-row references.
  • Splits scoped database-row searches from broader mention searches and caches mention responses in the panel.
  • Adds API integration coverage, utility unit tests, command text extraction tests, and Playwright BDD coverage for mention search behavior.

Impact

Users can search richer mention targets from the editor, including embedded database rows, while existing page/date/create mention flows remain available.

Validation

  • git diff --check
  • pnpm run type-check
  • pnpm jest src/components/editor/components/panels/mention-panel/__tests__/mentionUtils.test.ts src/application/slate-yjs/__tests__/command.test.ts --no-coverage --runInBand
  • codex review --uncommitted found no actionable correctness issues

Summary by Sourcery

Integrate a server-backed mention search API into the editor mention panel while extending mention types to support databases, database rows, and external links.

New Features:

  • Add server-driven mention search in the editor mention panel with support for people, pages, databases, database rows, dates, and external links.
  • Introduce database and database-row mention rendering and navigation within the editor.
  • Expose workspace-level mention search API wiring through app, modal, document, database, and editor contexts, including mention-specific context data.

Enhancements:

  • Refine mention keyboard navigation and option handling to unify search results, date shortcuts, and page creation actions.
  • Improve editor command text extraction to derive readable content from database and database-row mentions, using denormalized display data when available.
  • Extend mention-related type definitions and context plumbing to handle richer mention payloads and search sections.

Tests:

  • Add HTTP integration tests for the workspace mention search API behavior and filtering.
  • Add Playwright BDD scenarios for end-to-end mention search flows in the web editor, including database row searches.
  • Add unit tests for mention search utilities used by the mention panel.

@sourcery-ai

sourcery-ai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements server-backed mention search throughout the editor by wiring a new WorkspaceService.searchMentions API into editor, document, modal, and database contexts; introduces richer Mention types and search models (including databases and database rows); updates the Mention panel UI/keyboard handling to render server results with caching and fallback to legacy recent-pages behavior; adds database mention rendering, improved mention text extraction, and extensive integration/unit/Playwright coverage.

Sequence diagram for mention panel server search with cache and legacy fallback

sequenceDiagram
  actor User
  participant MentionPanel
  participant EditorContext
  participant WorkspaceService
  participant Cache as MentionSearchCache

  User->>MentionPanel: type "@query"
  MentionPanel->>MentionPanel: buildMentionSearchRequests
  MentionPanel->>Cache: get(cacheKey)
  alt cache hit
    Cache-->>MentionPanel: sections
    MentionPanel->>MentionPanel: flattenMentionSearchSections
    MentionPanel-->>User: render server results
  else cache miss
    alt searchMentions available
      MentionPanel->>EditorContext: searchMentions(requests)
      EditorContext->>WorkspaceService: searchMentions
      WorkspaceService-->>EditorContext: MentionSearchResponse[]
      EditorContext-->>MentionPanel: responses
      MentionPanel->>MentionPanel: mergeMentionSearchResponses
      MentionPanel->>Cache: set(cacheKey, sections)
      MentionPanel-->>User: render server results
    else searchMentions unavailable or failed
      MentionPanel->>MentionPanel: useLegacyMentionSearch = true
      MentionPanel->>EditorContext: loadViews
      EditorContext-->>MentionPanel: recent pages
      MentionPanel-->>User: render legacy recent-pages UI
    end
  end
Loading

File-Level Changes

Change Details Files
Rewrite the mention panel to consume server-backed mention search, support multiple mention target kinds (people/pages/databases/database rows/dates/links), cache results, and gracefully fall back to legacy recent-pages loading when the API is unavailable or fails.
  • Extend MentionPanel to import new mention search utilities and icons, introduce MentionTag.Result, and build a combined options model that includes search results, legacy pages, date actions, and create-page actions.
  • Introduce server search state (sections, loading/failure flags, cache map, request id) and derive mentionSearchRequests/mentionSearchCacheKey using buildMentionSearchRequests and buildMentionSearchRequestsCacheKey.
  • Debounce searchMentions calls, merge multiple responses, cache sections with an LRU-like cap, and reset selection on new queries or panel open/close events.
  • Flatten sections into MentionPanelSearchResult entries, group them back into sections for rendering, and wire keyboard navigation and Enter handling to operate on search results when present.
  • Render a new Results area (with per-kind icons) when server search is enabled, retain the legacy recent-pages block only when search is disabled or has failed, and refactor date/create-page footer actions into reusable FooterActionButton components.
src/components/editor/components/panels/mention-panel/MentionPanel.tsx
src/components/editor/components/panels/mention-panel/mentionUtils.ts
src/components/editor/components/panels/mention-panel/__tests__/mentionUtils.test.ts
Extend core application types and editor inline attributes to model server mention search requests/responses and richer Mention payloads, including database/database-row/date ranges and denormalized display data.
  • Add MentionTargetKind, MentionSearchSectionKind, MentionSearchContext/Filter/Request/Response, MentionSearchPayload variants, and MentionSearchResultItem/Section types to application types.
  • Extend Mention/MentionType to support Database/DatabaseRow mentions, row_id/database_row_id/row_document_id, optional end for dates, and an arbitrary data bag for display metadata.
  • Expose a SearchMentions function type and add searchMentions and mentionContext to ViewComponentProps and EditorContext state.
  • Mirror the new Mention fields in EditorInlineAttributes so inline mention nodes can carry database and row metadata through Slate.
src/application/types.ts
src/slate-editor.d.ts
src/components/editor/EditorContext.tsx
Wire the workspace mention search HTTP API into the app, view modal, document, and database contexts so any editor instance can invoke searchMentions with an appropriate mentionContext.
  • Add WorkspaceService.searchMentions HTTP wrapper and re-export it through http_api and workspace domain services.
  • Implement searchMentions callbacks in AppPage and ViewModal that call WorkspaceService.searchMentions with the current workspaceId, and pass them plus mentionContext into EditorContext via ViewComponent props.
  • Extend Database and DatabaseRowSubDocument to propagate searchMentions and construct a database-aware mentionContext (view_id/database_id/database_view_id/row_id) for embedded editors.
  • Adjust Document to always inject view_id into mentionContext based on viewMeta.viewId.
src/application/services/js-services/http/workspace-api.ts
src/application/services/js-services/http/http_api.ts
src/application/services/domains/workspace.ts
src/pages/AppPage.tsx
src/components/app/ViewModal.tsx
src/components/document/Document.tsx
src/components/database/Database.tsx
src/application/database-yjs/context.ts
src/components/database/components/database-row/DatabaseRowSubDocument.tsx
Add dedicated rendering and text extraction behavior for database and database-row mentions, and generalize mention text computation used in command-based content extraction.
  • Introduce MentionDatabase component that renders database and database-row mentions with appropriate icons, titles (from mention.data.title when present), and navigation to the underlying database or row via navigateToView/getViewIdFromDatabaseId.
  • Update MentionLeaf to render MentionDatabase when encountering Database or DatabaseRow mention types with the necessary identifiers.
  • Refactor CustomEditor.getEditorContent mention handling to use getMentionTextContent, which knows how to render dates and database/database-row mentions (favoring denormalized data.title and falling back to generic labels).
src/components/editor/components/leaf/mention/MentionDatabase.tsx
src/components/editor/components/leaf/mention/MentionLeaf.tsx
src/application/slate-yjs/command/index.ts
Enhance HTTP test setup and add integration/Playwright coverage for the workspace mention search API and editor mention search behavior, including database row search and external link suggestions.
  • Refactor HTTP test setup to introduce TestAuthToken, FeatureFixtureAccount, token helpers, and getFeatureFixtureAccount for reusable, named fixture accounts per feature.
  • Add Node-based integration tests that exercise searchMentions for default empty-query sections, person search using a fixture member, seeded page suggestions, and external link normalization.
  • Add Playwright BDD feature and step definitions that sign in fixture accounts, seed a database row via API, mock database-row mention search when needed, and validate that the editor mention panel surfaces dates, external links, people, and embedded database rows correctly.
  • Add utility logic in mentionUtils for building/splitting/caching mention search requests and mapping MentionSearchResultItem structures into editor Mention models, with accompanying unit tests.
src/application/services/js-services/http/__tests__/setup.ts
src/application/services/js-services/http/__tests__/mention.integration.test.ts
playwright/bdd/features/editor/mention-search.feature
playwright/bdd/steps/mention-search.steps.ts
src/components/editor/components/panels/mention-panel/mentionUtils.ts
src/components/editor/components/panels/mention-panel/__tests__/mentionUtils.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

appflowy and others added 9 commits June 16, 2026 22:29
# Conflicts:
#	src/application/database-yjs/context.ts
#	src/components/database/Database.tsx
- Re-read cache after joining an in-flight mention search refresh so
  reopened panels pick up refreshed sections instead of stale ones
- Enforce mention search cache size limit on all insert paths and make
  eviction LRU instead of FIFO
- Subscribe the mention panel keydown listener once per open via a
  handler ref instead of re-attaching on every keystroke
- Guard MentionPerson user fetch against out-of-order responses
- Derive MentionDatabase resolved view id during render (keyed by
  databaseId) instead of mirroring props into state via an effect
- Pass primitive props to MentionDatabase so MentionLeaf's content memo
  no longer depends on unstable leaf object identity
- Replace arrow-key option array allocation with index arithmetic and
  drop a useMemo over module constants
- Memoize local fallback view tree walk separately from query filtering

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port the desktop row-page features to web, API/collab-driven (no local
store):

- Soft-delete tombstones: RowOrder.is_deleted support with filtering in
  all rendering paths; row-lifecycle dispatches to soft-delete, restore,
  and permanently remove rows across every database view
- Delete row: rows with document content (or a materialized row
  document) are tombstoned and their row-document view moves to trash;
  empty rows hard-delete with no trash entry
- Favorite a row page: header star on ?r= pages targets the row
  document (materializing the orphan view lazily); favorites entries
  navigate back to the row page; dedicated favoriteFailed toast
- Trash page: restore clears the tombstone across views, permanent
  delete removes the row for good; restore-all/delete-all handle
  row-document entries
- Title sync: primary-cell edits propagate to the row-document view
  name (debounced) so favorites/trash labels stay current
- Mention parity: database rows render inline in the Pages section with
  a grid icon (no separate heading); row mentions resolve through the
  row-document view when database_view_id is missing; open failures
  show a toast
- BDD: port cloud_row_page_trash_restore.feature to Playwright
  (row-page-lifecycle), scoped to the visible grid to handle multi-view
  testid duplicates; update mention-search steps to the new section
  contract

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

🥷 Ninja i18n – 🛎️ Translations need to be updated

Project /project.inlang

lint rule new reports level link
Missing translation 28 warning contribute (via Fink 🐦)

@appflowy appflowy changed the title [codex] add server-backed mention search feat: mention database row page Jul 6, 2026
appflowy and others added 7 commits July 7, 2026 10:43
Resolved conflicts in share access files by combining both sides:
- access-api.ts: kept main's getShareDetail (v2 endpoint with legacy
  fallback, retry, and workspace-scoped caching), which subsumes this
  branch's direct v2 rewrite
- useShareAccessDetails.ts / callers: restored the ancestorViewIds
  argument required by the legacy fallback
- PersonItem.tsx: canModifyThisPerson now requires both
  !isInheritedWorkspaceAccess (this branch) and main's full-access /
  not-you / not-owner gating
- PeopleWithAccess.tsx / SharePanel.tsx: pass both sectionType and
  canGrantFullAccess
- tests: kept both sides' new cases; added the required
  isInheritedWorkspaceAccess prop to main's new PersonItem test

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A user whose access was revoked could keep reading a page indefinitely:
local-first rendering serves view metadata from the outline/disk cache and
content from IndexedDB without consulting the server, and the only server
probe (routeViewExists) is skipped while the view is still in the cached
outline and treats only 404 as an error.

- Add AccessService.getObjectPermission wrapping
  GET /api/workspace/{w}/collab/{id}/permission
- AppBusinessLayer: background permission probe on navigation (10s TTL,
  in-flight dedup); on can_read=false or a definitive 403 show the
  no-access page and purge the view's IndexedDB collab + view-meta cache.
  Denied state is keyed by view id and derived during render so
  navigation never flashes the no-access screen on the next page.
- useWorkspaceData: on a SHARE_VIEWS_CHANGED notification naming the
  current user (case-insensitive), probe the server and, when access is
  gone, evict local caches and emit VIEW_ACCESS_REVOKED so an open page
  swaps to the no-access screen immediately.
- MainLayout renders the Forbidden/RequestAccess screen for viewNoAccess.
- access-api: drop the stacked withRetry around the share-details v2 GET;
  the axios interceptor already retries transient GET failures, and the
  double ladder kept the share panel blocked before the legacy fallback.

Known gap: rows of a revoked database page keep their per-row collab
caches; only the database view's own doc is evicted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant