fix: improve question handling in chat

Updates question card behavior
Improves localized question text
Covers session question actions with tests
This commit is contained in:
Bohdan Triapitsyn
2026-06-03 14:51:17 +03:00
parent a0b22c9960
commit 2163c2e3f7
12 changed files with 208 additions and 22 deletions
+4
View File
@@ -1685,6 +1685,10 @@ export const dict = {
'chat.questionCard.copiedMarkdown': 'Question copied as Markdown',
'chat.questionCard.copiedJson': 'Question copied as JSON',
'chat.questionCard.copyFailed': 'Failed to copy question',
'chat.questionCard.submitFailed': 'Failed to send response',
'chat.questionCard.dismissFailed': 'Failed to dismiss question',
'chat.questionCard.noLongerPending': 'This question is no longer waiting for a response.',
'chat.questionCard.tryAgain': 'Please try again in a moment.',
'chat.textSelection.toast.noProject': 'No project found for this session',
'chat.textSelection.toast.addToNotesFailed': 'Failed to add to notes',
'chat.textSelection.toast.addToNotesSuccess': 'Added selected text to notes',
+4
View File
@@ -1651,6 +1651,10 @@ export const dict: Record<I18nKey, string> = {
"chat.questionCard.copiedMarkdown": "Pregunta copiada como Markdown",
"chat.questionCard.copiedJson": "Pregunta copiada como JSON",
"chat.questionCard.copyFailed": "No se pudo copiar la pregunta",
"chat.questionCard.submitFailed": "No se pudo enviar la respuesta",
"chat.questionCard.dismissFailed": "No se pudo descartar la pregunta",
"chat.questionCard.noLongerPending": "Esta pregunta ya no espera una respuesta.",
"chat.questionCard.tryAgain": "Inténtalo de nuevo en un momento.",
"chat.textSelection.toast.noProject": "No se encontró proyecto para esta sesión",
"chat.textSelection.toast.addToNotesFailed": "No se pudo añadir a las notas",
"chat.textSelection.toast.addToNotesSuccess": "Texto seleccionado añadido a notas",
+4
View File
@@ -1687,6 +1687,10 @@ export const dict: Record<I18nKey, string> = {
'chat.questionCard.copiedMarkdown': '질문을 Markdown으로 복사했습니다',
'chat.questionCard.copiedJson': '질문을 JSON으로 복사했습니다',
'chat.questionCard.copyFailed': '질문 복사에 실패했습니다',
'chat.questionCard.submitFailed': '응답 전송에 실패했습니다',
'chat.questionCard.dismissFailed': '질문 닫기에 실패했습니다',
'chat.questionCard.noLongerPending': '이 질문은 더 이상 응답을 기다리지 않습니다.',
'chat.questionCard.tryAgain': '잠시 후 다시 시도하세요.',
'chat.textSelection.toast.noProject': '이 세션의 프로젝트를 찾을 수 없음',
'chat.textSelection.toast.addToNotesFailed': '메모 추가 실패',
'chat.textSelection.toast.addToNotesSuccess': '선택한 텍스트를 메모에 추가함',
+4
View File
@@ -669,6 +669,10 @@ export const dict: Record<I18nKey, string> = {
'chat.questionCard.copiedMarkdown': 'Pytanie skopiowane jako Markdown',
'chat.questionCard.copiedJson': 'Pytanie skopiowane jako JSON',
'chat.questionCard.copyFailed': 'Nie udało się skopiować pytania',
'chat.questionCard.submitFailed': 'Nie udało się wysłać odpowiedzi',
'chat.questionCard.dismissFailed': 'Nie udało się odrzucić pytania',
'chat.questionCard.noLongerPending': 'To pytanie nie czeka już na odpowiedź.',
'chat.questionCard.tryAgain': 'Spróbuj ponownie za chwilę.',
'chat.textSelection.toast.noProject': 'Nie znaleziono projektu dla tej sesji',
'chat.textSelection.toast.addToNotesFailed': 'Nie udało się dodać do notatek',
'chat.textSelection.toast.addToNotesSuccess': 'Dodano zaznaczony tekst do notatek',
@@ -1651,6 +1651,10 @@ export const dict: Record<I18nKey, string> = {
"chat.questionCard.copiedMarkdown": "Pergunta copiada como Markdown",
"chat.questionCard.copiedJson": "Pergunta copiada como JSON",
"chat.questionCard.copyFailed": "Falha ao copiar a pergunta",
"chat.questionCard.submitFailed": "Falha ao enviar a resposta",
"chat.questionCard.dismissFailed": "Falha ao descartar a pergunta",
"chat.questionCard.noLongerPending": "Esta pergunta não está mais aguardando uma resposta.",
"chat.questionCard.tryAgain": "Tente novamente em instantes.",
"chat.textSelection.toast.noProject": "Não foi encontrado projeto para esta sessão",
"chat.textSelection.toast.addToNotesFailed": "Não foi possível adicionar às notas",
"chat.textSelection.toast.addToNotesSuccess": "Texto selecionado adicionado às notas",
+4
View File
@@ -1651,6 +1651,10 @@ export const dict: Record<I18nKey, string> = {
"chat.questionCard.copiedMarkdown": "Питання скопійовано як Markdown",
"chat.questionCard.copiedJson": "Питання скопійовано як JSON",
"chat.questionCard.copyFailed": "Не вдалося скопіювати питання",
"chat.questionCard.submitFailed": "Не вдалося надіслати відповідь",
"chat.questionCard.dismissFailed": "Не вдалося відхилити питання",
"chat.questionCard.noLongerPending": "Це питання більше не очікує відповіді.",
"chat.questionCard.tryAgain": "Спробуйте ще раз за мить.",
"chat.textSelection.toast.noProject": "Для цієї сесії не знайдено жодного проєкту",
"chat.textSelection.toast.addToNotesFailed": "Не вдалося додати до нотаток",
"chat.textSelection.toast.addToNotesSuccess": "Вибраний текст додано до нотаток",
@@ -1651,6 +1651,10 @@ export const dict: Record<I18nKey, string> = {
'chat.questionCard.copiedMarkdown': '问题已复制为 Markdown',
'chat.questionCard.copiedJson': '问题已复制为 JSON',
'chat.questionCard.copyFailed': '复制问题失败',
'chat.questionCard.submitFailed': '发送回答失败',
'chat.questionCard.dismissFailed': '忽略问题失败',
'chat.questionCard.noLongerPending': '此问题不再等待回答。',
'chat.questionCard.tryAgain': '请稍后重试。',
'chat.textSelection.toast.noProject': '未找到此会话对应的项目',
'chat.textSelection.toast.addToNotesFailed': '添加到笔记失败',
'chat.textSelection.toast.addToNotesSuccess': '已将选中文本添加到笔记',
@@ -1655,6 +1655,10 @@ export const dict: Record<I18nKey, string> = {
'chat.questionCard.copiedMarkdown': '問題已複製為 Markdown',
'chat.questionCard.copiedJson': '問題已複製為 JSON',
'chat.questionCard.copyFailed': '複製問題失敗',
'chat.questionCard.submitFailed': '傳送回答失敗',
'chat.questionCard.dismissFailed': '忽略問題失敗',
'chat.questionCard.noLongerPending': '此問題不再等待回答。',
'chat.questionCard.tryAgain': '請稍後再試。',
'chat.textSelection.toast.noProject': '找不到此會話對應的專案',
'chat.textSelection.toast.addToNotesFailed': '加入筆記失敗',
'chat.textSelection.toast.addToNotesSuccess': '已將選取文字加入筆記',
+6 -2
View File
@@ -57,7 +57,9 @@ type SdkResult<T> = {
function unwrapSdkData<T>(result: SdkResult<T>, operation: string): T {
if (result.error) {
const status = result.response?.status;
throw new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`);
const error = new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`) as Error & { status?: number };
if (status !== undefined) error.status = status;
throw error;
}
if (result.data === undefined || result.data === null) {
throw new Error(`${operation} failed: empty response`);
@@ -68,7 +70,9 @@ function unwrapSdkData<T>(result: SdkResult<T>, operation: string): T {
function unwrapSdkOptional<T>(result: SdkResult<T>, operation: string): T | undefined {
if (result.error) {
const status = result.response?.status;
throw new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`);
const error = new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`) as Error & { status?: number };
if (status !== undefined) error.status = status;
throw error;
}
return result.data;
}