Skip to content

Move document title ownership from document to version#1001

Merged
SachaProbo merged 3 commits intomainfrom
SachaProbo/doc-title-to-version
Apr 9, 2026
Merged

Move document title ownership from document to version#1001
SachaProbo merged 3 commits intomainfrom
SachaProbo/doc-title-to-version

Conversation

@SachaProbo
Copy link
Copy Markdown
Contributor

@SachaProbo SachaProbo commented Apr 7, 2026

Summary by cubic

Move document titles from Document to DocumentVersion. The UI and APIs now read/write titles on versions and show/order by the latest (or published) version.

  • Refactors

    • Frontend reads titles from the latest DocumentVersion; lists/dialogs/breadcrumbs/actions use versions.edges[0].node.title. DocumentTitleForm now edits version titles via updateDocumentVersion, checks core:document-version:update, and only allows edits on draft versions.
    • GraphQL/MCP: removed Document.title and description (also removed EmployeeDocument.description); UpdateDocumentInput drops title and content; UpdateDocumentVersionInput adds title.
    • Services: Document no longer persists title; backend resolves title from the latest/published version for display/ordering; UpdateDocumentVersion validates/saves title; draft creation copies the latest version’s title.
    • Search: moved search_vector to document_versions; filter queries the latest version’s search_vector.
    • E2E: factories expose the created version ID; tests update and validate titles via updateDocumentVersion and stop querying Document.title.
  • Migration

    • DB: make documents.title nullable; drop documents.description; move search_vector and its GIN index from documents to document_versions with a generated column.
    • Client: stop querying Document.title/description; read DocumentVersion.title (latest or published); use updateDocumentVersion to change titles.

Written for commit eb6c06e. Summary will update on new commits.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 19 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/console/src/pages/organizations/documents/_components/DocumentActionsDropdown.tsx">

<violation number="1" location="apps/console/src/pages/organizations/documents/_components/DocumentActionsDropdown.tsx:346">
P2: The PDF filename uses the latest version title, not the title of the version being exported, so exports of older versions can be mislabeled.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@SachaProbo SachaProbo force-pushed the SachaProbo/doc-title-to-version branch 5 times, most recently from 377da69 to 50624e8 Compare April 7, 2026 19:12
@SachaProbo SachaProbo requested a review from a team April 8, 2026 06:55
Copy link
Copy Markdown
Contributor

@gearnode gearnode left a comment

Choose a reason for hiding this comment

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

LGTM, please check it does not break the CLI before merging.

@SachaProbo SachaProbo force-pushed the SachaProbo/doc-title-to-version branch 3 times, most recently from cd8221c to ef236f4 Compare April 9, 2026 17:49
Title is now owned by document_versions, following the same pattern as
classification and document_type. The documents.title column is made
nullable with a TODO to drop it. Backend loads title from a
latest_versions CTE for ordering purposes only. The frontend resolves
title from the latest version, and DocumentTitleForm now operates on
DocumentVersion using UpdateDocumentVersion mutation.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
The description field on Document and EmployeeDocument was never
populated. Remove it from the database, GraphQL schema, and Go types.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
Now that title lives on document_versions, the full-text search vector
belongs there too. Drop the generated column and GIN index from
documents, recreate them on document_versions, and update the document
filter to query the latest version's search_vector.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
@SachaProbo SachaProbo force-pushed the SachaProbo/doc-title-to-version branch from ef236f4 to eb6c06e Compare April 9, 2026 18:02
@SachaProbo SachaProbo merged commit eb6c06e into main Apr 9, 2026
17 checks passed
@SachaProbo SachaProbo deleted the SachaProbo/doc-title-to-version branch April 9, 2026 18: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.

2 participants