feat(ai): support editing sent user messages

* feat(ai): support editing sent user messages

Adds inline edit support for user messages in the AI chat panel.
Hover over a user message to reveal the edit button; confirming the
edit truncates all subsequent history and re-sends with the new content.

* fix(ai): fix IME composition and ref-focus regression in message edit

- Handle IME composition events in onEditKeydown to prevent accidental
  submission on Enter during CJK candidate selection
- Replace per-render :ref focus callback with nextTick + data attribute
  to avoid cursor jumping on every keystroke
- Extract visibleToActualIndex into aiMessageEdit.ts for testability
- Add 8 unit tests covering index mapping with contextSummary messages

* fix(ai): prevent data loss and mention pollution in message edit

- Guard connection/config before truncating messages to prevent silent data
  loss when send() bails early
- Clear selectedMentions before resend to prevent stale chips from polluting
  edited message content
This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-07-03 15:18:56 +08:00
1 parent f1f4518b67
commit fe4908321e
10 files changed
+169 -4

No files matched your search

+3
View File
@@ -1218,6 +1218,9 @@ export default {
convert: "e.g. convert to PostgreSQL / MySQL / SQL Server",
sampleData: "Describe the sample data or test statements to generate",
},
editMessage: "Edit message",
editResend: "Resend",
editCancel: "Cancel",
},
contextMenu: {
openConnection: "Open Connection",
+3
View File
@@ -1221,6 +1221,9 @@ export default withEnglishFallback({
convert: "P. ej. convertir a PostgreSQL / MySQL / SQL Server",
sampleData: "Describe los datos de ejemplo o sentencias de prueba a generar",
},
editMessage: "Editar mensaje",
editResend: "Reenviar",
editCancel: "Cancelar",
},
contextMenu: {
openConnection: "Abrir conexión",
+3
View File
@@ -1219,6 +1219,9 @@ export default withEnglishFallback({
convert: "es. converti in PostgreSQL / MySQL / SQL Server",
sampleData: "Descrivi i dati di esempio o le istruzioni di test da generare",
},
editMessage: "Modifica messaggio",
editResend: "Invia di nuovo",
editCancel: "Annulla",
},
contextMenu: {
openConnection: "Apri Connessione",
+3
View File
@@ -1219,6 +1219,9 @@ export default withEnglishFallback({
convert: "例: PostgreSQL / MySQL / SQL Serverに変換",
sampleData: "生成するサンプルデータやテスト文を説明してください",
},
editMessage: "メッセージを編集",
editResend: "再送信",
editCancel: "キャンセル",
},
contextMenu: {
openConnection: "接続を開く",
+3
View File
@@ -1220,6 +1220,9 @@ export default withEnglishFallback({
convert: "por exemplo, converter para PostgreSQL / MySQL / SQL Server",
sampleData: "Descreva os dados de exemplo ou instruções de teste a gerar",
},
editMessage: "Editar mensagem",
editResend: "Reenviar",
editCancel: "Cancelar",
},
contextMenu: {
openConnection: "Abrir Conexão",
+3
View File
@@ -1220,6 +1220,9 @@ export default withEnglishFallback({
convert: "例如:转换成 PostgreSQL / MySQL / SQL Server",
sampleData: "描述要生成的样例数据或测试语句",
},
editMessage: "编辑消息",
editResend: "重新发送",
editCancel: "取消",
},
contextMenu: {
openConnection: "打开连接",
+3
View File
@@ -1220,6 +1220,9 @@ export default withEnglishFallback({
convert: "例如:轉換成 PostgreSQL / MySQL / SQL Server",
sampleData: "描述要產生的範例資料或測試語句",
},
editMessage: "編輯訊息",
editResend: "重新傳送",
editCancel: "取消",
},
contextMenu: {
openConnection: "開啟連線",