diff --git a/apps/desktop/src/renderer/components/shared/HistoryEntryCard.tsx b/apps/desktop/src/renderer/components/shared/HistoryEntryCard.tsx
index 5dfd909..890360c 100644
--- a/apps/desktop/src/renderer/components/shared/HistoryEntryCard.tsx
+++ b/apps/desktop/src/renderer/components/shared/HistoryEntryCard.tsx
@@ -11,6 +11,7 @@ import { PhysicalButton, TactileBadge } from '@d3ro/ui/components/ds'
import { d3roPalette, d3roFocusRing, d3roRadius, d3roTransition, typoSx } from '@d3ro/ui/theme'
import { useI18n } from '@d3ro/i18n'
import type { HistoryEntry, MemoTag } from '@d3ro/core/types'
+import { MEMO_TAG_MAX_LENGTH } from '@d3ro/core/memo-tag-policy'
import { formatDuration } from '../../utils/formatters'
import { isImeComposingEvent } from '../../utils/keyboard'
import { recordModeLabelKey } from '../../utils/display-labels'
@@ -38,7 +39,8 @@ const browserHistoryAudioPort: HistoryAudioPort = {
}
interface TagFailure {
- kind: 'add' | 'remove'
+ /** too-long 은 다시 시도해도 같으니 재시도 대신 안내만 한다. */
+ kind: 'add' | 'remove' | 'too-long'
tag: string
}
@@ -312,8 +314,16 @@ function RecordDetail({
setTagFailure({ kind: 'add', tag: outcome.tag })
return
}
+ if (outcome.status === 'too-long') {
+ setTagFailure({ kind: 'too-long', tag: outcome.tag })
+ return
+ }
setTagFailure(null)
- setTags((prev) => [...prev.filter((tg) => tg.tag !== outcome.tag.tag), outcome.tag])
+ // 이미 붙어 있는 태그(대소문자만 다름)면 목록은 그대로 두고 입력만 닫는다.
+ if (outcome.status === 'added') {
+ const added = outcome.tag
+ setTags((prev) => [...prev.filter((tg) => tg.tag !== added.tag), added])
+ }
setTagInput('')
setShowTagInput(false)
onTagsChanged?.()
@@ -334,7 +344,7 @@ function RecordDetail({
)
const handleRetryTag = useCallback(() => {
- if (!tagFailure) return
+ if (!tagFailure || tagFailure.kind === 'too-long') return
if (tagFailure.kind === 'remove') {
void handleRemoveTag(tagFailure.tag)
return
@@ -354,7 +364,7 @@ function RecordDetail({
e.stopPropagation()
setShowTagInput(false)
setTagInput('')
- setTagFailure((prev) => (prev?.kind === 'add' ? null : prev))
+ setTagFailure((prev) => (prev?.kind === 'add' || prev?.kind === 'too-long' ? null : prev))
}
},
[handleAddTag],
@@ -484,7 +494,7 @@ function RecordDetail({
value={tagInput}
onChange={(e) => {
setTagInput(e.target.value)
- if (tagFailure?.kind === 'add') setTagFailure(null)
+ if (tagFailure?.kind === 'add' || tagFailure?.kind === 'too-long') setTagFailure(null)
}}
onKeyDown={handleTagKeyDown}
onBlur={() => {
@@ -492,7 +502,7 @@ function RecordDetail({
}}
autoFocus
placeholder={t('memo.tagPlaceholder')}
- inputProps={{ 'aria-label': t('memo.addTag'), 'aria-invalid': tagFailure?.kind === 'add' }}
+ inputProps={{ 'aria-label': t('memo.addTag'), 'aria-invalid': tagFailure?.kind === 'add' || tagFailure?.kind === 'too-long' }}
sx={{
...typoSx('small'),
height: 24,
@@ -500,13 +510,18 @@ function RecordDetail({
minWidth: 160,
color: d3roPalette.text.primary,
bgcolor: d3roPalette.bg.input,
- border: `1px solid ${tagFailure?.kind === 'add' ? d3roPalette.status.danger : d3roPalette.accent.main}`,
+ border: `1px solid ${tagFailure?.kind === 'add' || tagFailure?.kind === 'too-long' ? d3roPalette.status.danger : d3roPalette.accent.main}`,
borderRadius: d3roRadius.small,
'& input::placeholder': { color: d3roPalette.text.tertiary, opacity: 1 },
}}
/>
)}
- {tagFailure && (
+ {tagFailure?.kind === 'too-long' && (
+
+ {t('memo.tagTooLong', { max: MEMO_TAG_MAX_LENGTH })}
+
+ )}
+ {tagFailure && tagFailure.kind !== 'too-long' && (
{`#${tagFailure.tag} · ${t('common.retry')}`}
diff --git a/apps/desktop/src/renderer/components/shared/history-entry-card-actions.ts b/apps/desktop/src/renderer/components/shared/history-entry-card-actions.ts
index afbd848..87fc467 100644
--- a/apps/desktop/src/renderer/components/shared/history-entry-card-actions.ts
+++ b/apps/desktop/src/renderer/components/shared/history-entry-card-actions.ts
@@ -3,7 +3,8 @@
// 렌더러 전역(window.electronAPI, URL, Audio)에 직접 닿지 않고 포트를 주입받아
// 노드 테스트에서 그대로 검증할 수 있다. 어댑터는 컴포넌트(구성 루트)가 만든다.
-import type { IPCResult } from '@d3ro/core/errors'
+import { ErrorCode, type IPCResult } from '@d3ro/core/errors'
+import { validateMemoTag } from '@d3ro/core/memo-tag-policy'
import type {
AddTagParams,
GetTagsParams,
@@ -25,6 +26,8 @@ export interface MemoTagPort {
export type AddEntryTagOutcome =
| { status: 'empty' }
| { status: 'added'; tag: MemoTag }
+ | { status: 'too-long'; tag: string }
+ | { status: 'duplicate'; tag: string }
| { status: 'failed'; tag: string }
/** 항목의 태그를 불러온다. 실패하면 null — 호출자가 기존 목록을 유지한다. */
@@ -45,9 +48,13 @@ export async function addEntryTag(
): Promise {
const tag = rawTag.trim()
if (!tag) return { status: 'empty' }
+ // 다시 시도해도 똑같이 거절될 입력은 '재시도'로 보여 주지 않는다.
+ if (validateMemoTag(tag) === 'too-long') return { status: 'too-long', tag }
try {
const result = await port.addTag({ historyId, tag })
- return result.success ? { status: 'added', tag: result.data } : { status: 'failed', tag }
+ if (result.success) return { status: 'added', tag: result.data }
+ if (result.error.code === ErrorCode.MemoTagDuplicate) return { status: 'duplicate', tag }
+ return { status: 'failed', tag }
} catch {
return { status: 'failed', tag }
}
diff --git a/apps/desktop/tests/unit/history-entry-card-redteam-r2-33.test.ts b/apps/desktop/tests/unit/history-entry-card-redteam-r2-33.test.ts
index aea84d0..949d1d2 100644
--- a/apps/desktop/tests/unit/history-entry-card-redteam-r2-33.test.ts
+++ b/apps/desktop/tests/unit/history-entry-card-redteam-r2-33.test.ts
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import { describe, expect, it, vi } from 'vitest'
-import type { IPCResult } from '@d3ro/core/errors'
+import { ErrorCode, type IPCResult } from '@d3ro/core/errors'
import type { HistoryAudioSource, MemoTag } from '@d3ro/core/types'
import {
HistoryAudioPlayer,
@@ -58,6 +58,19 @@ describe('HistoryEntryCard — 메모 태그 계약', () => {
expect(seen).toEqual([{ historyId: 'h1' }, { historyId: 'h1', tag: 'meeting' }, { historyId: 'h1', tag: 'work' }])
})
+ it('너무 긴 태그는 호출 없이 too-long, 중복 거절은 duplicate 로 알린다 — 재시도로 보이지 않는다', async () => {
+ const { port } = memoPort()
+ expect(await addEntryTag(port, 'h1', 'a'.repeat(81))).toEqual({ status: 'too-long', tag: 'a'.repeat(81) })
+ expect(port.addTag).not.toHaveBeenCalled()
+
+ const dupPort: MemoTagPort = {
+ ...port,
+ addTag: async () =>
+ ({ success: false, error: { code: ErrorCode.MemoTagDuplicate, message: 'dup' } }) as IPCResult,
+ }
+ expect(await addEntryTag(dupPort, 'h1', 'Work')).toEqual({ status: 'duplicate', tag: 'Work' })
+ })
+
it('빈 입력은 호출하지 않고, 실패·예외는 failed/false/null로 알린다', async () => {
const { port } = memoPort()
expect(await addEntryTag(port, 'h1', ' ')).toEqual({ status: 'empty' })
diff --git a/packages/i18n/src/locales/en.json b/packages/i18n/src/locales/en.json
index ea543bc..5da951e 100644
--- a/packages/i18n/src/locales/en.json
+++ b/packages/i18n/src/locales/en.json
@@ -228,6 +228,7 @@
"common.stop": "Stop",
"memo.addTag": "Add Tag",
"memo.tagPlaceholder": "Type a tag and press Enter",
+ "memo.tagTooLong": "Tags can be up to {{max}} characters",
"memo.export": "Export as Markdown",
"memo.clearFilter": "Clear filter",
"voiceCommand.title": "Voice Commands",
diff --git a/packages/i18n/src/locales/ko.json b/packages/i18n/src/locales/ko.json
index b6cfbce..f477dd4 100644
--- a/packages/i18n/src/locales/ko.json
+++ b/packages/i18n/src/locales/ko.json
@@ -236,6 +236,7 @@
"common.stop": "중지",
"memo.addTag": "태그 추가",
"memo.tagPlaceholder": "태그 입력 후 Enter",
+ "memo.tagTooLong": "태그는 {{max}}자까지 쓸 수 있어요",
"memo.export": "마크다운 내보내기",
"memo.clearFilter": "필터 해제",
"voiceCommand.title": "음성 명령어",