Skip to content

Comments

spec(wikibase-schema-editor): add store auto-save functionality#123

Merged
DaxServer merged 1 commit intomainfrom
store-autosave
Aug 9, 2025
Merged

spec(wikibase-schema-editor): add store auto-save functionality#123
DaxServer merged 1 commit intomainfrom
store-autosave

Conversation

@DaxServer
Copy link
Owner

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Aug 9, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Updated design and requirements documents to describe a new autosave system for the schema editor, eliminating manual save/cancel buttons for individual editing actions.
    • Added detailed implementation notes and user stories reflecting immediate local saving of all changes, with a single manual save button for backend synchronization.
    • Expanded task list to cover autosave implementation, UI changes, and updated test cases for the new autosave workflow.

Walkthrough

The changes update the design, requirements, and tasks documentation for the Wikibase Schema Editor to formalize an autosave architecture. All schema-editing actions now immediately update the local Pinia store, eliminating manual save/cancel buttons for individual elements. Only a single manual "Save to Server" button remains for backend persistence.

Changes

Cohort / File(s) Change Summary
Design Document Updates
.kiro/specs/wikibase-schema-editor/design.md
Updates the design to specify autosave replacing manual save/cancel buttons throughout the UI. Details autosave patterns at the component and store level, adds isDirty and lastSyncedAt to the schema model, and provides example Pinia store and handler methods. Manual backend save remains unchanged.
Requirements Document Updates
.kiro/specs/wikibase-schema-editor/requirements.md
Revises requirements to mandate autosave for all schema editing actions, removing individual save/cancel operations. Adds acceptance criteria and a new requirement for immediate local persistence and a single manual backend save control. No code or API changes are specified.
Task List Updates
.kiro/specs/wikibase-schema-editor/tasks.md
Adds tasks for implementing autosave in all editor components and store, removing save/cancel buttons, updating drag-and-drop and schema selection workflows, and updating tests to expect immediate store persistence. Manual backend save remains as is.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI Component
    participant Pinia Store
    participant Backend

    User->>UI Component: Edit schema (e.g., term, statement, qualifier)
    UI Component->>Pinia Store: Immediately update state (autosave)
    Pinia Store-->>UI Component: State updated, mark as dirty

    User->>UI Component: Click "Save to Server"
    UI Component->>Backend: Persist schema changes
    Backend-->>UI Component: Confirm save
    UI Component->>Pinia Store: Update lastSyncedAt, clear dirty flag
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch store-autosave

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.
  • 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.

Support

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

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: 4

🔭 Outside diff range comments (5)
.kiro/specs/wikibase-schema-editor/requirements.md (2)

137-152: Requirement 10.8 is not achievable without persisted store

“Retain all locally saved changes … when the user navigates away” requires persistence beyond in-memory Pinia. Amend requirement to explicitly mandate persisted state (e.g., localStorage/IndexedDB) or scope it to “within session” if persistence is out of scope.

Proposed rewording:

- 8. WHEN the user navigates away from the editor THEN the system SHALL retain all locally saved changes in the Pinia store
+ 8. WHEN the user navigates away or reloads THEN the system SHALL retain all locally saved changes using persisted local storage (e.g., IndexedDB/localStorage via Pinia persistence)

53-65: Clarify atomicity and validation messaging for autosave during statement edits

The current requirements specify immediate autosave (AC 7) and no save/cancel buttons (AC 8), but they don’t explain how partial or invalid edits are handled before a statement is “complete.” We need to define:

• Whether intermediate invalid states (e.g. property selected but value unmapped, or invalid data type) are persisted to the store
• How and when inline validation errors or warnings are displayed during multi‐step edits

Suggested additional acceptance criteria:

  1. WHEN the user begins editing a Statement (selects property or maps values) THEN the system SHALL allow intermediate edits but SHALL NOT persist an incomplete or invalid Statement until all required fields are valid
  2. WHEN the user enters invalid data (e.g. mismatched type or missing property) THEN the system SHALL display inline validation messaging immediately and block autosave until the error is corrected

These criteria ensure clear rules around autosave atomicity and user feedback for partial edits.

.kiro/specs/wikibase-schema-editor/design.md (3)

137-159: Type definitions: include autosave fields or the store sample will not type-check

You set schema.value.isDirty and lastSyncedAt later, but these fields aren’t part of the interface. Add optional fields to avoid TS errors.

Patch:

 interface WikibaseSchemaMapping {
   id: string
   projectId: string
   name: string
   wikibase: string
   item: ItemSchemaMapping
   createdAt: string
   updatedAt: string
-  // Note: isDirty and lastSyncedAt may already exist in current implementation
-  // Only add if not already present in existing schema structure
+  // Autosave metadata
+  isDirty?: boolean
+  lastSyncedAt?: string
 }

623-698: Avoid mixing UseDraggable with native HTML5 drag-and-drop on the same element

UseDraggable manipulates element position for pointer dragging; HTML5 DnD uses ghost images and DataTransfer. Combining them can cause event quirks and UX jitter. Prefer HTML5 DnD without UseDraggable for data transfer here.

Suggested simplification:

-  <UseDraggable v-slot="{ isDragging }" :initial-value="{ x: 0, y: 0 }" :prevent-default="true">
-    <div class="column-chip" draggable="true" @dragstart="handleDragStart" @dragend="handleDragEnd">...</div>
-  </UseDraggable>
+  <div
+    class="column-chip cursor-grab active:cursor-grabbing"
+    draggable="true"
+    @dragstart="handleDragStart"
+    @dragend="handleDragEnd"
+  >...</div>

703-777: TermsEditor example: hard-coded 'en' and direct classList usage

  • Don’t hard-code language ('en'); derive from current language selection in store/props.
  • Avoid classList mutations; rely on reactive class bindings already present.

Patch snippet:

-      handleColumnDrop('label', column, 'en')
+      handleColumnDrop('label', column, activeLanguage.value)

And remove classList adds/removes in handlers; keep the reactive :class bindings only.

🧹 Nitpick comments (17)
.kiro/specs/wikibase-schema-editor/tasks.md (4)

210-216: Instrument TermsEditor autosave with debounce for text inputs

Autosaving every keystroke to the store can thrash validation/reactivity. Add a task to debounce user typing (labels/descriptions/aliases) while still applying immediate updates for non-typing events (drops, selects).

Proposed addition:

+ - [ ] 35a. Debounce autosave for text inputs in TermsEditor
+   - Debounce 150–300ms while typing; immediate on blur/enter
+   - Update tests to assert batched store updates during typing
+   - _Requirements: 10.1, 10.2_

238-244: Verify manual backend sync compatibility via integration tests

Good call-out. Add explicit integration tests covering dirty state clearing, lastSyncedAt updating, and rollback on failure while preserving local changes.

Proposed addition:

+ - [ ] 39a. Integration tests for manual sync + autosave
+   - Assert isDirty resets and lastSyncedAt updates on success
+   - Assert local store remains intact on failure; isDirty stays true
+   - _Requirements: 10.3, 10.4_

252-258: Initialize autosave at schema load/create with feature flag fallback

Document a feature flag or safe rollout plan (env or store flag) to toggle autosave, enabling staged rollout/testing.

Proposed addition:

+ - [ ] 41a. Feature flag for autosave rollout
+   - Gate autosave mutations behind a config flag for staged rollout
+   - E2E tests for both modes (flag on/off)
+   - _Requirements: 9.4, 9.5, 9.8_

259-266: Expand test updates to cover performance and validation impacts

Update tests to assert:

  • Validation isn’t spuriously retriggered in tight loops during typing.
  • Large schemas don’t regress performance with per-change autosave.

Proposed addition:

+ - [ ] 42a. Add performance/validation regressions tests
+   - Typing in terms does not trigger excessive validations
+   - Large schema (100+ statements) remains responsive
+   - _Requirements: 10.1, 8.1, 8.2_
.kiro/specs/wikibase-schema-editor/requirements.md (6)

11-22: Avoid implementation-specific terms in requirements

Referencing “Pinia” in requirements couples UX expectations to a library. Consider phrasing as “local store” while keeping Pinia in design/tasks. This keeps requirements technology-agnostic.


39-50: Define language selection behavior for term mapping autosave

Clarify how the active language is determined on drop, and what happens on multilingual fields (multiple aliases). Acceptance criteria should cover current language context and defaulting rules.


68-79: Rank changes: validation and constraints

Add acceptance criteria for constraints like “at least one normal/preferred rank exists” if relevant, and expected behavior when changing ranks rapidly under autosave.


82-93: Qualifiers autosave: ordering and deduplication

Clarify whether qualifier order matters and how duplicates (same property/value) are handled. Add criteria for these cases.


96-107: References autosave: required fields and validity

Add criteria for minimally valid references (e.g., require P248 or P854?) and behavior when partial/incomplete reference data is autosaved.


124-136: Schema selection: autosave enablement in read-only contexts

Confirm that viewing an existing schema in a read-only context does not autosave. If read-only mode exists, add acceptance criteria.

.kiro/specs/wikibase-schema-editor/design.md (7)

47-55: Root container responsibilities: add unsynced changes indicator

Include an indicator (badge/toast) when isDirty is true to remind users they have changes not yet saved to the server.


430-437: State management: note on debouncing and watchers

Autosaving on every change can over-trigger validations and derived computations. Document debouncing for text fields and microtask batching for store updates where appropriate.


438-456: Two-level autosave: clarify dirty clearing and sync timestamps

Document when isDirty clears (after successful sync) and how lastSyncedAt updates. Include behavior on sync error (keep isDirty true).


472-478: Backend integration unchanged: confirm optimistic updates don’t double-apply

Since autosave is local-only, ensure existing optimistic update logic in sync doesn’t re-run local mutations redundantly. Note this explicitly.


782-833: Validation composable: broaden compatibility map and centralize types

Put the compatibilityMap in a single source (e.g., validation constants) and cover more Wikibase types (external-id, monolingualtext, url, globe-coordinate). Add tests to prevent drift.


838-874: Drag store: compute valid targets reactively rather than storing strings

Keep validDropTargets as a computed derived from draggedColumn + schema shape, not an eagerly stored array, to reduce state divergence.


536-544: Minor copy edit: repeated ‘immediately’

There’s adverb repetition in these bullet points. Tighten wording to improve readability.

Suggested edit:

- - Drop zones immediately apply mappings on drop
- - Property selectors immediately update on selection
- - Rank dropdowns immediately update on change
- - Language selectors immediately update on change
- - Add/remove buttons immediately modify arrays
+ - Drop zones apply mappings on drop
+ - Property selectors update on selection
+ - Rank dropdowns update on change
+ - Language selectors update on change
+ - Add/remove buttons modify arrays
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a7bcfd0 and 6827e4d.

📒 Files selected for processing (3)
  • .kiro/specs/wikibase-schema-editor/design.md (5 hunks)
  • .kiro/specs/wikibase-schema-editor/requirements.md (8 hunks)
  • .kiro/specs/wikibase-schema-editor/tasks.md (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-07-20T14:13:24.706Z
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 Pinia stores for global state

Applied to files:

  • .kiro/specs/wikibase-schema-editor/design.md
📚 Learning: 2025-07-20T14:13:24.706Z
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 Pinia for state management in all Vue components

Applied to files:

  • .kiro/specs/wikibase-schema-editor/design.md
📚 Learning: 2025-07-20T14:13:24.706Z
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:

  • .kiro/specs/wikibase-schema-editor/design.md
📚 Learning: 2025-07-20T14:13:24.706Z
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 useApi composable (Elysia Eden) for all API calls

Applied to files:

  • .kiro/specs/wikibase-schema-editor/design.md
🪛 LanguageTool
.kiro/specs/wikibase-schema-editor/design.md

[style] ~538-~538: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym.
Context: ...y mappings on drop - Property selectors immediately update on selection - Rank dropdowns im...

(ADVERB_REPETITION_PREMIUM)


[style] ~541-~541: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym.
Context: ...y update on change - Add/remove buttons immediately modify arrays - No confirmation dialogs...

(ADVERB_REPETITION_PREMIUM)

🔇 Additional comments (2)
.kiro/specs/wikibase-schema-editor/design.md (2)

76-83: SchemaCanvas: avoid mixed class manipulation and bindings

Examples later use both classList mutations and Vue class bindings for DnD feedback. Prefer reactive class bindings only to avoid divergence and flicker.

⛔ Skipped due to 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 : Prefer reactivity over computed unless necessary
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
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
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 reactive objects for form state and errors
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
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 : No inline style attributes in templates
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 : Do NOT use custom CSS in <style> blocks except with explicit approval
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 Tailwind CSS utility classes for all styling; Tailwind is mandatory for all styling
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
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 Pinia stores for global state

171-188: No duplicate StatementSchemaMapping in design.md
The design spec only references the backend’s StatementSchemaMapping type—it does not declare its own. There is no conflicting interface in .kiro/specs/wikibase-schema-editor/design.md, so no renaming or consolidation is needed.

Likely an incorrect or invalid review comment.

Comment on lines +481 to +500
#### Component-Level Autosave
```typescript
// Example: TermsEditor autosave pattern
const handleTermMapping = (termType: string, language: string, columnMapping: ColumnMapping) => {
// Immediately update Pinia store - no save button needed
schemaStore.updateTermMapping(termType, language, columnMapping)

// Mark schema as dirty for backend sync
schemaStore.markDirty()
}

// Example: StatementEditor autosave pattern
const handlePropertySelection = (statementId: string, property: PropertyReference) => {
// Immediately update Pinia store - no save button needed
schemaStore.updateStatementProperty(statementId, property)

// Mark schema as dirty for backend sync
schemaStore.markDirty()
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Store sample: missing comma and defensive guards

There’s a missing comma after markDirty in return. Also, ensure nested paths exist before assignment to terms[termType][language].

Patch:

 export const useSchemaStore = defineStore('schema', () => {
   const schema = ref<WikibaseSchemaMapping | null>(null)
 
   const updateTermMapping = (termType: string, language: string, mapping: ColumnMapping) => {
     if (!schema.value) return
-    // Immediate store update
-    schema.value.item.terms[termType][language] = mapping
+    // Ensure term bucket exists
+    const terms: any = schema.value.item.terms as any
+    terms[termType] ||= {}
+    // Immediate store update
+    terms[termType][language] = mapping
     schema.value.isDirty = true
     schema.value.updatedAt = new Date().toISOString()
   }
 
   const markDirty = () => {
     if (schema.value) {
       schema.value.isDirty = true
     }
   }
 
   return {
     schema: readonly(schema),
     updateTermMapping,
-    markDirty
+    markDirty,
     // Note: syncToBackend already exists in current implementation
   }
 })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#### Component-Level Autosave
```typescript
// Example: TermsEditor autosave pattern
const handleTermMapping = (termType: string, language: string, columnMapping: ColumnMapping) => {
// Immediately update Pinia store - no save button needed
schemaStore.updateTermMapping(termType, language, columnMapping)
// Mark schema as dirty for backend sync
schemaStore.markDirty()
}
// Example: StatementEditor autosave pattern
const handlePropertySelection = (statementId: string, property: PropertyReference) => {
// Immediately update Pinia store - no save button needed
schemaStore.updateStatementProperty(statementId, property)
// Mark schema as dirty for backend sync
schemaStore.markDirty()
}
```
export const useSchemaStore = defineStore('schema', () => {
const schema = ref<WikibaseSchemaMapping | null>(null)
const updateTermMapping = (termType: string, language: string, mapping: ColumnMapping) => {
if (!schema.value) return
// Ensure term bucket exists
const terms: any = schema.value.item.terms as any
terms[termType] ||= {}
// Immediate store update
terms[termType][language] = mapping
schema.value.isDirty = true
schema.value.updatedAt = new Date().toISOString()
}
const markDirty = () => {
if (schema.value) {
schema.value.isDirty = true
}
}
return {
schema: readonly(schema),
updateTermMapping,
markDirty,
// Note: syncToBackend already exists in current implementation
}
})
🤖 Prompt for AI Agents
In .kiro/specs/wikibase-schema-editor/design.md around lines 481 to 500, the
sample code for the store's autosave pattern is missing a comma after the
markDirty method in the return statement, and it lacks defensive checks before
assigning to nested paths like terms[termType][language]. Fix this by adding the
missing comma after markDirty and adding checks to ensure that terms[termType]
and terms[termType][language] exist before assignment, initializing them if
necessary to avoid runtime errors.

Comment on lines +203 to +209
- [ ] 34. Implement autosave functionality in schema store
- Write tests for immediate Pinia store updates on all schema changes
- Write tests for isDirty flag management and lastSyncedAt tracking
- Write tests for automatic store persistence without manual save operations
- Implement autosave mutations in schema store for all schema operations
- _Requirements: 10.1, 10.2, 10.8_

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add explicit persistence strategy for "retain on navigation" requirement

Tasks omit implementing persisted local storage, yet Requirement 10.8 expects local changes to survive navigation. Add a task to enable persisted Pinia state (e.g., pinia-plugin-persistedstate or IndexedDB/localStorage) and tests for reload/navigation scenarios.

Proposed addition:

+ - [ ] 34a. Implement persisted local store for autosave
+   - Use pinia-plugin-persistedstate (or IndexedDB) to persist schema state
+   - Write tests verifying state survives route changes and page reloads
+   - Ensure security: avoid persisting sensitive tokens
+   - _Requirements: 10.8_
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [ ] 34. Implement autosave functionality in schema store
- Write tests for immediate Pinia store updates on all schema changes
- Write tests for isDirty flag management and lastSyncedAt tracking
- Write tests for automatic store persistence without manual save operations
- Implement autosave mutations in schema store for all schema operations
- _Requirements: 10.1, 10.2, 10.8_
- [ ] 34. Implement autosave functionality in schema store
- Write tests for immediate Pinia store updates on all schema changes
- Write tests for isDirty flag management and lastSyncedAt tracking
- Write tests for automatic store persistence without manual save operations
- Implement autosave mutations in schema store for all schema operations
- _Requirements: 10.1, 10.2, 10.8_
- [ ] 34a. Implement persisted local store for autosave
- Use pinia-plugin-persistedstate (or IndexedDB) to persist schema state
- Write tests verifying state survives route changes and page reloads
- Ensure security: avoid persisting sensitive tokens
- _Requirements: 10.8_
🤖 Prompt for AI Agents
In .kiro/specs/wikibase-schema-editor/tasks.md around lines 203 to 209, the
autosave functionality tasks lack implementation of persisted local storage
required by Requirement 10.8 to retain state across navigation. Add a task to
enable persisted Pinia state using a persistence plugin or
localStorage/IndexedDB, and include tests verifying state retention after page
reloads or navigation events.

Comment on lines +217 to +223
- [ ] 36. Remove save/cancel buttons from StatementEditor component
- Write tests for immediate statement configuration updates without save buttons
- Write tests for automatic property selection and rank changes persistence
- Remove save/cancel buttons from StatementEditor interface
- Update StatementEditor to use autosave store mutations
- _Requirements: 4.7, 4.8, 5.6, 5.7, 10.5_

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Cover undo/redo or revert workflows after removing save/cancel

With save/cancel removed, users need a way to revert unintended edits. Add a small history/undo task (store-level snapshot stack) and tests.

Proposed addition:

+ - [ ] 36a. Provide undo/redo for autosaved edits
+   - Implement lightweight history (bounded stack) in store
+   - Keyboard shortcuts and UI affordance
+   - Tests for reverting terms/statements/qualifiers/references
+   - _Requirements: 10.1, 10.2_
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [ ] 36. Remove save/cancel buttons from StatementEditor component
- Write tests for immediate statement configuration updates without save buttons
- Write tests for automatic property selection and rank changes persistence
- Remove save/cancel buttons from StatementEditor interface
- Update StatementEditor to use autosave store mutations
- _Requirements: 4.7, 4.8, 5.6, 5.7, 10.5_
- [ ] 36. Remove save/cancel buttons from StatementEditor component
- Write tests for immediate statement configuration updates without save buttons
- Write tests for automatic property selection and rank changes persistence
- Remove save/cancel buttons from StatementEditor interface
- Update StatementEditor to use autosave store mutations
- _Requirements: 4.7, 4.8, 5.6, 5.7, 10.5_
- [ ] 36a. Provide undo/redo for autosaved edits
- Implement lightweight history (bounded stack) in store
- Keyboard shortcuts and UI affordance
- Tests for reverting terms/statements/qualifiers/references
- _Requirements: 10.1, 10.2_
🤖 Prompt for AI Agents
In .kiro/specs/wikibase-schema-editor/tasks.md around lines 217 to 223, after
removing the save/cancel buttons from the StatementEditor component, add a new
task to implement undo/redo or revert functionality to allow users to revert
unintended edits. Specifically, introduce a store-level snapshot stack to manage
history and write corresponding tests to cover these undo/redo workflows.

Comment on lines +245 to +251
- [ ] 40. Update drag-and-drop operations to use autosave
- Write tests for immediate store updates on column drop operations
- Write tests for automatic mapping persistence without confirmation dialogs
- Update all drop zone handlers to use autosave store mutations
- Remove any remaining save/cancel patterns from drag-and-drop workflows
- _Requirements: 10.1, 10.2, 10.5_

Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Automate removal of legacy save/cancel UI

Add a task (with a script) to detect any lingering “Save”/“Cancel” buttons and confirmation dialogs in target editors and DnD flows.

Script to run:


🏁 Script executed:

#!/bin/bash
# Find lingering save/cancel patterns in components
rg -n -S --glob "src/**/*.vue" --glob "src/**/*.ts" \
  -e '\bSave\b' -e '\bCancel\b' -e 'confirm\(' -e 'confirmDialog' \
  -e 'onConfirm' -e 'saveToServer' -e 'save/cancel' -A2 -B2

Length of output: 316


🏁 Script executed:

#!/bin/bash
# Retry searching for lingering save/cancel patterns across the entire repo
rg -n --no-ignore \
  -e '\bSave\b' -e '\bCancel\b' \
  -e 'confirm\(' -e 'confirmDialog' \
  -e 'onConfirm' -e 'saveToServer' -e 'save/cancel' \
  -A2 -B2

Length of output: 5827


Remove all legacy Save/Cancel UI elements
We ran the detection script and confirmed multiple “Save”/“Cancel” buttons and confirmation dialogs remain. Please remove or replace them with the new autosave-driven patterns in the following locations:

• frontend/src/features/wikibase-schema/components/StatementEditor.vue (labels “Cancel” at line 297, “Save” at line 303)
• frontend/src/features/wikibase-schema/components/SchemaSelector.vue (label “Cancel” at line 79)
• frontend/src/features/wikibase-schema/components/ReferencesEditor.vue (label “Cancel” at line 500)
• frontend/src/features/wikibase-schema/components/QualifiersEditor.vue (label “Cancel” at line 417)
• frontend/src/features/project-management/composables/useProjectListComposable.ts (rejectProps label “Cancel” at line 13)
• frontend/src/features/wikibase-schema/components/WikibaseSchemaEditor.vue (save-button helpers at lines 178–183)
• backend/src/api/project/index.ts (legacy “Save file to temporary location” logic at lines 94–96)
• API.md (endpoints under /command/core/cancel-*)

Update each component to use the autosave store mutations and remove any manual save/cancel or confirm dialogs.

🤖 Prompt for AI Agents
In .kiro/specs/wikibase-schema-editor/tasks.md around lines 245 to 251, the
legacy Save/Cancel UI elements and confirmation dialogs remain in multiple
frontend components and backend logic. Remove or replace all "Save" and "Cancel"
buttons and dialogs in the specified files and lines with autosave-driven
patterns by updating the components to use autosave store mutations. Also,
eliminate manual save/cancel logic in backend/src/api/project/index.ts lines
94-96 and remove related endpoints in API.md under /command/core/cancel-*.
Ensure all drag-and-drop and editing workflows rely solely on autosave without
manual confirmation.

@DaxServer DaxServer merged commit a6c7d39 into main Aug 9, 2025
6 checks passed
@DaxServer DaxServer deleted the store-autosave branch August 9, 2025 12:55
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