AOSSIE-Org / AOSSIE-Org/Ell-ena

feat: AI task creation from natural language has no duplicate detection — saying "remind me to review the PR" twice creates two identical tasks with no warning

オープン
#291 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Dart
スター
54
フォーク
110
PR マージ指標
30日以内にマージされた PR はありません

説明

## 🚀 Problem Statement

Ell-ena's core value is: *"Generate to-do items and tickets using natural language commands."* The chat interface processes user messages via the Gemini NLU pipeline and creates tasks/tickets in the PostgreSQL database. However, there is no duplicate detection — if a user sends the same natural language command twice (common with voice input, network retries, or forgetfulness), two identical tasks are created silently.

For a project management AI assistant, duplicate tasks corrupt the workflow — a developer who sees "Review PR #42" twice on their task list doesn't know which one to check off, and checking off one doesn't remove the other.

## Proposed Fix

**1. Add semantic deduplication in the AI task creation flow:**

When a new task is about to be created, check the vector similarity between the new task's embedding and existing open tasks for the same user:

```typescript
// lib/screens/chat/ or services/ai_service.dart

async function createTaskWithDuplicateCheck(
taskData: TaskInput,
userId: string,
db: SupabaseClient
): Promise<{ task: Task; isDuplicate: boolean; similarTask?: Task }> {

// Generate embedding for new task
const newEmbedding = await generateEmbedding(taskData.title + ' ' + taskData.description);

// Search for semantically similar open tasks (threshold: 0.92 similarity)
const { data: similarTasks } = await db.rpc('find_similar_tasks', {
p_user_id: userId,
p_embedding: newEmbedding,
p_threshold: 0.92,
p_limit: 1,
});

if (similarTasks && similarTasks.length > 0) {
return { task: similarTasks[0], isDuplicate: true, similarTask: similarTasks[0] };
}

// No duplicate found — create the task
const { data: newTask } = await db.from('tasks').insert(taskData).select().single();
return { task: newTask, isDuplicate: false };
}
```

**2. In the Flutter chat UI** — when a duplicate is detected, show a confirmation dialog:

```dart
// lib/screens/chat/chat_screen.dart
if (result.isDuplicate) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: Text('Similar Task Found'),
content: Text(
'A similar task already exists: "${result.similarTask!.title}". '
'Would you like to create a new one anyway?'
),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: Text('No, use existing')),
TextButton(
onPressed: () { Navigator.pop(context); _forceCreateTask(taskData); },
child: Text('Yes, create new')
),
],
),
);
}
```

## Files to Create/Modify

| File | Change |
|---|---|
| `supabase/` | Add `find_similar_tasks` SQL RPC function |
| `lib/services/ai_service.dart` | Add `createTaskWithDuplicateCheck()` |
| `lib/screens/chat/` | Handle duplicate result and show confirmation dialog |

**Suggested labels:** `enhancement`, `frontend`, `backend`, `level: intermediate`

I would like to work on this. Could you please assign it to me?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start by tracing task creation in lib/services/ai_service.dart and the chat flow in lib/screens/chat/, then inspect the existing Supabase schema and functions under supabase/. Done means open tasks for the same user are checked for semantic similarity before creation, and the chat UI clearly handles the existing-task and create-anyway choices.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
dart, flutter, postgresql, sql, supabase
領域
ai, backend, databases, mobile
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。