Skip to content

Feature/enhance note view - #798

Merged
pikann merged 5 commits into
masterfrom
feature/enhance-note-view
Nov 20, 2026
Merged

pikann merged 5 commits into
masterfrom
feature/enhance-note-view

Conversation

@pikann

@pikann pikann commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Simplifies the Note view from #796: a note view is now one editable document, not a list of notes. It opens straight into the docs editor with its comments and activity pane, with no notes sidebar and no title.

Web

  • NoteView shows the view's one document. The first time someone with docs:write opens an empty view, the document is created. With only docs:read, an empty view says it has no document yet. A failed creation can be retried.
  • Removed: the notes list, New note, rename, move up/down, delete and the remembered active note.
  • DocumentPane takes an optional headerSlot. With it, the pane draws no header bar of its own, and its save status and comments/activity toggle render into that element. The interaction layout provides the slot in the view header, where other view types keep their settings button. The docs route passes no slot and keeps its breadcrumb header.
  • If creation loses a race (DOC_NOTE_VIEW_TAKEN), the view refetches and shows the other client's document instead of an error.
  • noteView strings are trimmed to what is still used, with translations in all 9 locales.

API (migration 000095)

  • A view holds exactly one live document: partial unique index uq_documents_note_view on documents (view_id) where view_id IS NOT NULL AND deleted_at IS NULL. This also settles two clients creating it at once.
  • A second POST /docs with the same view_id returns 409 DOC_NOTE_VIEW_TAKEN. Deleting the document frees the view for a new one.
  • For a view that already has several notes, the migration keeps the first (by position, then creation, then id) and soft-deletes the rest, so their snapshots and activity stay for the audit log. It takes the doc change counter of every project with a note view, then locks documents in SHARE mode before deduping and building the index, so instances still running the old code during a rolling deploy cannot insert a duplicate in between (counter first, as 000088 requires). It can be run again.

MCP

  • write_doc with viewId updates the view's one document whatever title is given (the title only names it on creation), or creates it when the view has none. README, ALL_TOOLS.md and the changelog are updated.

Docs: interaction-views.md, http-design.md (error table) and database-schema.md.

Things a reviewer may want to know:

  • The API still lists notes with GET /docs?view_id=, so a view that had several before the migration shows the first in manual order (the migration soft-deletes the rest).
  • Orphaned extra documents from before the migration are soft-deleted, not hard-deleted.

Type of Change

  • Other (enhancement: Note view holds a single document)

Checklist

  • The change is focused and scoped.
  • Related documentation is updated.
  • New structure or direction is explained clearly.
  • I avoided unnecessary detail or premature abstraction.

Testing

  • Go: Postgres repository tests (run against a throwaway Postgres) cover the one-document rule, freeing the view by deleting its document, and the 000095 dedupe and re-run, alongside the existing note tests. Service, handler and presenter tests pass. The Go e2e suite (doc_note_view_test.go, now with a 409 DOC_NOTE_VIEW_TAKEN case and a re-run of both migrations) was not run.
    • TestWriteDocumentAtPath_DocDeletedBeforeRowLockIsPathChanged fails on my machine with and without this change.
  • Web: tsc -b passes. note-view.test.tsx is rewritten (opens the one document, shows only the first of several, creates once when empty, retries a failed creation, shows a document created by someone else, read-only and no-access states).
  • MCP: filesystem-doc-tools-notes.test.ts passes, with a new case for writing the view's document under a different title.
  • Playwright: note-views.spec.ts (rewritten for the single document) passes on chromium and mobile-chrome against the e2e docker stack rebuilt from this branch.

- Refactor note view translations across multiple languages to reflect the change from "notes" to "document".
- Introduce new error handling for cases where a note view already has an associated document (DOC_NOTE_VIEW_TAKEN).
- Update database schema and migration scripts to enforce the constraint that a note view can only hold one document.
- Modify API responses and documentation to clarify the behavior of note views and their associated documents.
- Enhance tests to cover scenarios related to the new document handling in note views.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Migration 000095 dedupes and then builds its unique index without excluding concurrent writers, so an instance still running the pre-000095 code can commit a second note in the gap and abort CREATE UNIQUE INDEX. The counter-first guarantee the file documents also only covers projects that already had duplicates when the counter statement ran.

Approach: sound — "one live document per note view" is enforced in the database rather than in the clients, so the web auto-create and the MCP write_doc both converge on the same 409 and every existing read/write path for documents keeps working unchanged.

Reviewed changes — full diff (32 files), against 1d9d7b5.

  • Single-document note view — NoteView renders documents[0] in DocumentPane, auto-creates the document once for a docs:write caller on an empty view, treats DOC_NOTE_VIEW_TAKEN as success, and shows an inline retry for other create failures; the notes list, New note, rename, reorder, delete and remembered active note are gone.
  • headerSlot — DocumentPane draws no header bar when a slot is given and portals its save status and comments/activity toggle into the view header element that InteractionLayout owns; the docs route still passes nothing and keeps its breadcrumb header.
  • API invariant — partial unique index uq_documents_note_view, ErrNoteViewTaken from the 23505 on that index, 409 DOC_NOTE_VIEW_TAKEN in the presenter; migration 000095 keeps the first note of a multi-note view by (position, created_at, id) and soft-deletes the rest.
  • MCP — write_doc with viewId patches the view's one document whatever title is passed and only uses the title on creation.
  • i18n, docs, tests — locales trimmed to the keys still used in all 9 languages; interaction-views.md, database-schema.md, http-design.md, MCP README/ALL_TOOLS/CHANGELOG updated; web, MCP, Postgres and Playwright coverage rewritten for the single-document behavior.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the incremental delta 1d9d7b5..0461ce4 (3 files), covering the migration hardening and the two stale-comment corrections.

  • Migration 000095 closes the rolling-deploy window — it takes the doc_sync_state counter for every project with a note view, then locks documents in SHARE mode before deduping and building the unique index, so a pre-000095 writer can neither slip a duplicate between dedupe and index build nor invert 000088's counter-before-rows order.
  • Stale "through the API or MCP" wording removed — note-view.tsx now describes extras as leftovers from before 000095, and interaction-views.md scopes the multi-note case to pre-migration data.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor coverage suggestion inline.

Approach: sound — the new commits keep the database as the authority for "one document per note view" and make the MCP writer converge on 409 DOC_NOTE_VIEW_TAKEN instead of surfacing it.

Reviewed changes — the incremental delta 0461ce4..528a2b3 (4 files), on top of the previously reviewed single-document note view.

  • MCP write_doc converges on a racing writer — writeViewNote re-reads the view after a failed create and patches the document another writer created, rethrowing the original error when none appears.
  • Activity toggle accessible name — the icon-only comments/activity button in DocumentPane now carries an aria-label alongside its tooltip title.
  • note-view.tsx naming — the local notesKey/notesQuery are renamed to docKey/docQuery to match the single-document model, and a long doc comment was rewrapped.
  • 000095 comments — documents why the keeper choice and the API's list ordering cannot diverge, and warns that the table lock blocks document writers for the migration's duration.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the incremental delta 528a2b3..4e72866 (1 file), adding the unit coverage the prior review asked for.

  • 409 convergence covered — a test makes createDocument reject with DOC_NOTE_VIEW_TAKEN while the post-failure listDocuments returns the winner, asserting patchDocument is called on that document and the tool reports an update.
  • Rethrow path covered — a second test rejects with a generic error while the view stays empty, asserting the original error propagates and nothing is patched.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit 0e9a4a7 into master Nov 20, 2026
9 checks passed
@pikann
pikann deleted the feature/enhance-note-view branch November 20, 2026 05:12
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