Skip to content

feat(wikibase-schema-editor): create references editor component#98

Merged
DaxServer merged 3 commits intomainfrom
wikibase-editor-task23
Aug 1, 2025
Merged

feat(wikibase-schema-editor): create references editor component#98
DaxServer merged 3 commits intomainfrom
wikibase-editor-task23

Conversation

@DaxServer
Copy link
Owner

Addresses Task 23 of #66

@coderabbitai
Copy link

coderabbitai bot commented Aug 1, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Introduced a References Editor component for managing statement references, including adding, removing, and updating references with support for column mapping and value types.
  • Bug Fixes
    • None.
  • Tests
    • Added comprehensive test suites to ensure correct logic and compilation of the References Editor component.
  • Chores
    • Updated documentation and project structure files, including marking the References Editor task as complete and adding new convention and rule files.

Walkthrough

A new ReferencesEditor Vue component has been introduced for managing references in the Wikibase schema editor, along with its TypeScript declarations and comprehensive logic/unit tests. The component is registered globally, and a related task in the project checklist was marked as completed. Several new markdown files referencing code conventions and structure were also added.

Changes

Cohort / File(s) Change Summary
ReferencesEditor Component Implementation
frontend/src/components/ReferencesEditor.vue
Added a new Vue 3 component for editing, adding, and removing references in a statement. Handles property selection, value mapping (column, constant, expression), drag-and-drop, and emits events for parent integration.
ReferencesEditor Component Tests
frontend/src/components/__tests__/ReferencesEditor.compile.test.ts, frontend/src/components/__tests__/ReferencesEditor.test.ts
Added a compile-time test to verify component import/compilation and a logic/unit test suite for reference management, property selection, value mapping, and state transitions.
Global Component Declaration
frontend/components.d.ts
Registered ReferencesEditor as a global Vue component with appropriate TypeScript typings.
Task Completion
.kiro/specs/wikibase-schema-editor/tasks.md
Marked the "Create ReferencesEditor component" task as completed in the project checklist.
Project Rule/Structure References
.trae/rules/code-conventions.md, .trae/rules/product.md, .trae/rules/structure.md, .trae/rules/tech.md
Added new markdown files referencing code conventions, product, structure, and tech documents, each containing only a path reference or filename, without substantive content.

Sequence Diagram(s)

sequenceDiagram
    participant ParentComponent
    participant ReferencesEditor

    ParentComponent->>ReferencesEditor: Provide statementId, references, availableColumns, disabled
    ReferencesEditor->>ParentComponent: emit add-reference (statementId, reference)
    ReferencesEditor->>ParentComponent: emit remove-reference (statementId, referenceIndex)
    ReferencesEditor->>ParentComponent: emit update-reference (statementId, referenceIndex, reference)
    ParentComponent-->>ReferencesEditor: Update props as needed (references, columns, etc.)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • DaxServer/dataforge#64: Implements a design spec for the Wikibase Schema Editor, including the ReferencesEditor component described and now implemented in this PR.
  • DaxServer/dataforge#70: Adds the drag-and-drop context composable and utilities used by the new ReferencesEditor component for column mapping.
  • DaxServer/dataforge#90: Introduces the PropertySelector component and selection composable, which are integrated into the new ReferencesEditor component for property selection.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 268e3c2 and 642a556.

📒 Files selected for processing (5)
  • .trae/rules/code-conventions.md (1 hunks)
  • .trae/rules/product.md (1 hunks)
  • .trae/rules/structure.md (1 hunks)
  • .trae/rules/tech.md (1 hunks)
  • frontend/src/components/ReferencesEditor.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • .trae/rules/tech.md
  • .trae/rules/structure.md
  • .trae/rules/product.md
  • .trae/rules/code-conventions.md
  • frontend/src/components/ReferencesEditor.vue
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wikibase-editor-task23

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (2)
.trae/rules/code-conventions.md (1)

1-1: Add trailing newline
POSIX text files should end with a newline to avoid diff noise in future edits.

frontend/src/components/__tests__/ReferencesEditor.test.ts (1)

361-372: Consider using type assertions instead of @ts-ignore.

While @ts-ignore works for testing null assignments, consider using type assertions for better type safety:

-    // @ts-ignore - Test needs to set null values
-    selectedProperty.value = null
+    selectedProperty.value = null as PropertyReference | null

This maintains type checking while allowing the test scenario.

Also applies to: 401-404

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 525ee40 and 268e3c2.

📒 Files selected for processing (9)
  • .kiro/specs/wikibase-schema-editor/tasks.md (1 hunks)
  • .trae/rules/code-conventions.md (1 hunks)
  • .trae/rules/product.md (1 hunks)
  • .trae/rules/structure.md (1 hunks)
  • .trae/rules/tech.md (1 hunks)
  • frontend/components.d.ts (1 hunks)
  • frontend/src/components/ReferencesEditor.vue (1 hunks)
  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts (1 hunks)
  • frontend/src/components/__tests__/ReferencesEditor.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file> for running TypeScript or JavaScript files
Do not use dotenv; Bun automatically loads .env files
Use Bun.serve() for HTTP servers and WebSockets instead of express
Use bun:sqlite for SQLite instead of better-sqlite3
Use Bun.redis for Redis instead of ioredis
Use Bun.sql for Postgres instead of pg or postgres.js
Use built-in WebSocket instead of ws
Prefer Bun.file over node:fs's readFile/writeFile
Use Bun.$ (e.g., Bun.$ls``) instead of execa for running shell commands

Files:

  • frontend/components.d.ts
  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
  • frontend/src/components/__tests__/ReferencesEditor.test.ts
**/*.{html,ts,tsx,css}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild for building HTML, TypeScript, or CSS files

Files:

  • frontend/components.d.ts
  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
  • frontend/src/components/__tests__/ReferencesEditor.test.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun test instead of jest for running tests

Files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
  • frontend/src/components/__tests__/ReferencesEditor.test.ts
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use storeToRefs for state in components
📚 Learning: applies to src/**/*.vue : use storetorefs for state in components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use storeToRefs for state in components

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/ReferencesEditor.vue
📚 Learning: applies to src/**/*.vue : use vue 3 with composition api and <script setup lang="ts"> in all vue com...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use Vue 3 with Composition API and <script setup lang="ts"> in all Vue components

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
  • frontend/src/components/ReferencesEditor.vue
📚 Learning: applies to src/**/*.vue : props and emits must use explicit typescript interfaces...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Props and emits must use explicit TypeScript interfaces

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/ReferencesEditor.vue
📚 Learning: applies to src/**/*.{ts,vue} : type safety everywhere...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{ts,vue} : Type safety everywhere

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
  • frontend/src/components/ReferencesEditor.vue
📚 Learning: applies to src/**/*.vue : build reusable, well-structured components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Build reusable, well-structured components

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to src/**/*.vue : use v-memo, shallowref, markraw, and suspense for performance optimization...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use v-memo, shallowRef, markRaw, and Suspense for performance optimization

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/ReferencesEditor.vue
📚 Learning: applies to src/**/*.vue : use auto-imports for vue, pinia, composables, and utilities...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use auto-imports for Vue, Pinia, composables, and utilities

Applied to files:

  • frontend/components.d.ts
📚 Learning: applies to src/**/*.{vue,ts} : use readonly and shallowreactive for large or expensive data...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{vue,ts} : Use readonly and shallowReactive for large or expensive data

Applied to files:

  • frontend/components.d.ts
  • frontend/src/components/ReferencesEditor.vue
📚 Learning: applies to src/**/*.{vue,ts} : always use backend-inferred types for api data...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{vue,ts} : Always use backend-inferred types for API data

Applied to files:

  • frontend/components.d.ts
📚 Learning: applies to src/**/*.vue : prefer composables over methods in vue components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Prefer composables over methods in Vue components

Applied to files:

  • frontend/components.d.ts
📚 Learning: applies to src/**/*.vue : use primevue as the ui library in all vue components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use PrimeVue as the UI library in all Vue components

Applied to files:

  • frontend/components.d.ts
📚 Learning: applies to **/*.test.{ts,tsx,js,jsx} : use `bun test` instead of `jest` for running tests...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Use `bun test` instead of `jest` for running tests

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to src/composables/**/*.ts : place composables in the composables/ directory...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Place composables in the composables/ directory

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to **/*.{tsx,jsx,js} : import .css files directly in .tsx, .jsx, or .js files and bun will h...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{tsx,jsx,js} : Import .css files directly in .tsx, .jsx, or .js files and Bun will handle them

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to **/*.{ts,tsx,js,jsx} : use `bun ` instead of `node ` or `ts-node ` for ...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `bun <file>` instead of `node <file>` or `ts-node <file>` for running TypeScript or JavaScript files

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to **/*.html : html files can import .tsx, .jsx, or .js files directly and bun's bundler wil...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.html : HTML files can import .tsx, .jsx, or .js files directly and Bun's bundler will transpile & bundle automatically

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to **/*.{html,tsx,jsx,js,css} : use html imports with `bun.serve()` instead of `vite` for fr...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{html,tsx,jsx,js,css} : Use HTML imports with `Bun.serve()` instead of `vite` for frontend development

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: for more information, read the official bun documentation at https://bun.sh/docs or check `node_modu...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: For more information, read the official Bun documentation at https://bun.sh/docs or check `node_modules/bun-types/docs/**.md` if available locally

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to **/*.{html,ts,tsx,css} : use `bun build ` instead of `webpack...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{html,ts,tsx,css} : Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild` for building HTML, TypeScript, or CSS files

Applied to files:

  • frontend/src/components/__tests__/ReferencesEditor.compile.test.ts
📚 Learning: applies to src/**/*.vue : use <script setup lang="ts"> at the top, template second, style last (rare...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use <script setup lang="ts"> at the top, template second, style last (rarely used) in Vue components

Applied to files:

  • frontend/src/components/ReferencesEditor.vue
🪛 GitHub Actions: Typecheck code
frontend/src/components/ReferencesEditor.vue

[error] 352-352: TypeScript error TS2345: Argument of type '{ id: string; label: string; dataType: string; }' is not assignable to parameter of type 'PropertyReference'. Types of property 'id' are incompatible: Type 'string' is not assignable to type 'P${number}'.

🔇 Additional comments (3)
frontend/components.d.ts (1)

35-35: LGTM!

The component declaration follows the established pattern and correctly references the new ReferencesEditor component.

.kiro/specs/wikibase-schema-editor/tasks.md (1)

138-138: Task completion confirmed.

The marking of task 23 as complete is appropriate - the ReferencesEditor component has been implemented with comprehensive test coverage.

frontend/src/components/__tests__/ReferencesEditor.compile.test.ts (1)

1-18: Well-structured compilation test.

The test correctly verifies TypeScript compilation and follows the project's testing conventions using bun:test.

Comment on lines +47 to +53
const commonReferenceProperties = [
{ id: 'P248', label: 'stated in', dataType: 'wikibase-item' },
{ id: 'P854', label: 'reference URL', dataType: 'url' },
{ id: 'P813', label: 'retrieved', dataType: 'time' },
{ id: 'P577', label: 'publication date', dataType: 'time' },
{ id: 'P50', label: 'author', dataType: 'wikibase-item' },
]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix TypeScript error with property ID type.

The id field must match the P${number} type expected by PropertyReference.

 const commonReferenceProperties = [
-  { id: 'P248', label: 'stated in', dataType: 'wikibase-item' },
-  { id: 'P854', label: 'reference URL', dataType: 'url' },
-  { id: 'P813', label: 'retrieved', dataType: 'time' },
-  { id: 'P577', label: 'publication date', dataType: 'time' },
-  { id: 'P50', label: 'author', dataType: 'wikibase-item' },
+  { id: 'P248' as const, label: 'stated in', dataType: 'wikibase-item' },
+  { id: 'P854' as const, label: 'reference URL', dataType: 'url' },
+  { id: 'P813' as const, label: 'retrieved', dataType: 'time' },
+  { id: 'P577' as const, label: 'publication date', dataType: 'time' },
+  { id: 'P50' as const, label: 'author', dataType: 'wikibase-item' },
 ]

Alternatively, properly type the array:

const commonReferenceProperties: PropertyReference[] = [
  { id: 'P248' as `P${number}`, label: 'stated in', dataType: 'wikibase-item' },
  // ... rest of the properties
]
🤖 Prompt for AI Agents
In frontend/src/components/ReferencesEditor.vue around lines 47 to 53, the id
field in commonReferenceProperties is causing a TypeScript error because it does
not match the expected template literal type `P${number}` from
PropertyReference. To fix this, explicitly type the array as PropertyReference[]
and cast each id value to the template literal type using 'as `P${number}`'.
This ensures the id fields conform to the expected type and resolves the
TypeScript error.

@DaxServer DaxServer merged commit 07d2990 into main Aug 1, 2025
6 checks passed
@DaxServer DaxServer deleted the wikibase-editor-task23 branch August 1, 2025 09:16
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