<!-- TableSuggestionReview.vue -->
<template>
<div class="table-suggestion-review">
<div class="suggestion-header">
<h3>Table Suggestion Review</h3>
<div class="suggestion-meta">
<span>Agent: {{ suggestion.agent }}</span>
<span>Score: {{ suggestion.score.fixed }}</span>
<span>Updated: {{ suggestion.updatedAt | formatDate }}</span>
</div>
</div>
<div v-if="conflicts.length > 0" class="conflicts-section">
<h4>Conflicts Detected</h4>
<div v-for="conflict in conflicts" :key="conflict.id" class="conflict-item">
<ConflictResolver :conflict="conflict" @resolve="handleConflictResolve" />
</div>
</div>
<div class="data-comparison">
<div class="current-data">
<h4>Current Data</h4>
<TableRenderer :table-data="currentData" :readonly="true" />
</div>
<div class="suggested-data">
<h4>Suggested Data</h4>
<TableRenderer :table-data="suggestedData" :readonly="true" />
</div>
<div class="merged-preview" v-if="mergedData">
<h4>Merged Preview</h4>
<TableRenderer :table-data="mergedData" :readonly="true" />
</div>
</div>
<div class="merge-options">
<div class="merge-strategy">
<label>Merge Strategy:</label>
<select v-model="selectedStrategy" @change="updateMergePreview">
<option value="append">Append new rows</option>
<option value="replace">Replace all data</option>
<option value="merge">Smart merge</option>
</select>
</div>
<div class="partial-selection" v-if="selectedStrategy === 'append'">
<h5>Select rows to accept:</h5>
<div v-for="(row, index) in suggestedData.data" :key="index" class="row-selector">
<input
type="checkbox"
:id="`row-${index}`"
v-model="selectedRows[index]"
@change="updateMergePreview"
/>
<label :for="`row-${index}`">Row {{ index + 1 }}</label>
<TableRowPreview :row="row" :schema="suggestedData.schema" />
</div>
</div>
</div>
<div class="action-buttons">
<button @click="acceptSuggestion" :disabled="!canAccept" class="btn-accept">
Accept Suggestion
</button>
<button @click="rejectSuggestion" class="btn-reject">
Reject Suggestion
</button>
<button @click="requestModification" class="btn-modify">
Request Modification
</button>
</div>
</div>
</template>
<script>
export default {
props: {
suggestion: Object,
currentData: Object,
workspaceId: String,
},
data() {
return {
suggestedData: null,
mergedData: null,
conflicts: [],
selectedStrategy: 'append',
selectedRows: {},
loading: false,
};
},
async mounted() {
await this.loadSuggestionData();
},
computed: {
canAccept() {
return this.conflicts.length === 0 && this.mergedData !== null;
},
},
methods: {
async loadSuggestionData() {
this.loading = true;
try {
// Load resolved suggestion data
this.suggestedData = await this.suggestion.getResolvedTableValue(this.workspaceId);
// Load conflicts
this.conflicts = await this.suggestion.getConflicts(this.workspaceId);
// Generate initial merge preview
await this.updateMergePreview();
} catch (error) {
this.$toast.error('Failed to load suggestion data');
} finally {
this.loading = false;
}
},
async updateMergePreview() {
try {
const response = await suggestionService.previewMerge(
this.workspaceId,
this.suggestion.id,
{
strategy: this.selectedStrategy,
selectedRows: this.selectedRows,
}
);
this.mergedData = new TableData(
response.merged_data.data,
response.merged_data.schema,
response.merged_data.reference
);
} catch (error) {
this.$toast.error('Failed to generate merge preview');
}
},
async acceptSuggestion() {
try {
await suggestionService.mergeSuggestion(
this.workspaceId,
this.suggestion.id,
{
strategy: this.selectedStrategy,
selectedRows: this.selectedRows,
}
);
this.$emit('accepted', this.mergedData);
this.$toast.success('Suggestion accepted successfully');
} catch (error) {
this.$toast.error('Failed to accept suggestion');
}
},
// Additional methods...
},
};
</script>
Description
Enhance table suggestion handling to properly support AI-generated suggestions for table data, leveraging workspace schema configuration for intelligent suggestion processing, validation, and user review. This improvement enables better integration of AI suggestions with the table reference resolution system.
Problem
Proposed Solution
Implementation Details
Dependencies
Backend Changes
Enhance Suggestion model for table data:
Enhance SchemaService for suggestion handling:
Add suggestion processing API endpoints:
Frontend Changes
Enhance Suggestion entity for table handling:
Create advanced table suggestion UI components:
Create suggestion conflict resolution components:
Related Files
extralit/argilla-server/src/argilla_server/models/database.py- Enhanced Suggestion modelextralit/argilla-server/src/argilla_server/services/SchemaService.py- Suggestion validation and merging logicextralit/argilla-server/src/argilla_server/api/handlers/v1/suggestions/- Enhanced suggestion handlersextralit/argilla-frontend/v1/domain/entities/question/Suggestion.ts- Enhanced Suggestion entityextralit/argilla-frontend/components/features/table-suggestions/- New suggestion UI componentsextralit/argilla-frontend/v1/infrastructure/services/SuggestionService.ts- Suggestion API clientAcceptance Criteria
Related Issues
This is part of the strategic workspace-level schema management enhancement: