Skip to content

Commit d71cd1a

Browse files
tznthouclaude
andauthored
fix(storage): allow excluding 0-session projects (#45)
The "Exclude this project" button on 0 B / 0-session projects silently did nothing because the UI guard bailed on sessionCount === 0. Relax the guard to only bail for date-range-only rules, and show a prevention-focused confirmation dialog for empty project exclusions. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 73accaf commit d71cd1a

3 files changed

Lines changed: 25 additions & 8 deletions

File tree

src/renderer/components/Storage/ConfirmExclusionDialog.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@ const HIGH_IMPACT_RATIO = 0.5
1818
export default function ConfirmExclusionDialog({ title, preview, totalSessions, isApplying, onConfirm, onCancel }: Props) {
1919
const { t } = useI18n()
2020
const [acknowledged, setAcknowledged] = useState(false)
21+
const isEmpty = preview.sessionCount === 0
2122
const impactRatio = totalSessions > 0 ? preview.sessionCount / totalSessions : 0
22-
const highImpact = impactRatio > HIGH_IMPACT_RATIO
23+
const highImpact = !isEmpty && impactRatio > HIGH_IMPACT_RATIO
2324

2425
return (
2526
<div className={styles.backdrop} onClick={() => { if (!isApplying) onCancel() }}>
2627
<div className={styles.dialog} onClick={e => e.stopPropagation()}>
2728
<div className={styles.dialogTitle}>{title}</div>
2829
<div className={styles.dialogSummary}>
29-
<ExclusionPreviewSummary preview={preview} />
30-
{totalSessions > 0 && (
31-
<span>{t('storage.confirm.impactRatio', { percent: (impactRatio * 100).toFixed(1) })}</span>
32-
)}
30+
{isEmpty
31+
? <span>{t('storage.confirm.emptyProjectHint')}</span>
32+
: <>
33+
<ExclusionPreviewSummary preview={preview} />
34+
{totalSessions > 0 && (
35+
<span>{t('storage.confirm.impactRatio', { percent: (impactRatio * 100).toFixed(1) })}</span>
36+
)}
37+
</>
38+
}
3339
</div>
3440

3541
{highImpact && (
@@ -45,7 +51,7 @@ export default function ConfirmExclusionDialog({ title, preview, totalSessions,
4551
disabled={isApplying}
4652
onChange={e => setAcknowledged(e.target.checked)}
4753
/>
48-
{t('storage.confirm.acknowledge')}
54+
{isEmpty ? t('storage.confirm.acknowledgeExclude') : t('storage.confirm.acknowledge')}
4955
</label>
5056

5157
<div className={styles.dialogActions}>
@@ -55,7 +61,9 @@ export default function ConfirmExclusionDialog({ title, preview, totalSessions,
5561
disabled={!acknowledged || isApplying}
5662
onClick={onConfirm}
5763
>
58-
{isApplying ? t('storage.confirm.deleting') : t('storage.confirm.deleteAction')}
64+
{isApplying
65+
? isEmpty ? t('storage.confirm.excluding') : t('storage.confirm.deleting')
66+
: isEmpty ? t('storage.confirm.excludeAction') : t('storage.confirm.deleteAction')}
5967
</button>
6068
</div>
6169
</div>

src/renderer/components/Storage/StoragePage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export default function StoragePage() {
4141
const openConfirm = useCallback(async (rule: ExclusionRuleInput, title: string) => {
4242
try {
4343
const preview = await window.api.previewExclusion(rule)
44-
if (preview.sessionCount === 0) {
44+
const isProjectOnly = !!(rule.projectId && !rule.dateFrom && !rule.dateTo)
45+
if (preview.sessionCount === 0 && !isProjectOnly) {
4546
return
4647
}
4748
setPending({ preview, title })

src/renderer/i18n/messages.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ const zhTW = {
153153
'storage.confirm.impactRatio': '(佔全部 {percent}%)',
154154
'storage.confirm.warningHighImpact': '⚠️ 此操作將刪除超過一半的資料。請再次確認。',
155155
'storage.confirm.acknowledge': '我了解此操作不可復原',
156+
'storage.confirm.acknowledgeExclude': '我了解排除後該專案不再被索引',
157+
'storage.confirm.emptyProjectHint': '此專案目前無任何 session。排除後,未來的 session 也不會被索引。',
158+
'storage.confirm.excludeAction': '確認排除',
159+
'storage.confirm.excluding': '排除中...',
156160
'storage.confirm.deleting': '刪除中...',
157161
'storage.confirm.deleteAction': '確認刪除',
158162
'dashboard.title': '儀表板',
@@ -423,6 +427,10 @@ const en = {
423427
'storage.confirm.impactRatio': '({percent}% of total)',
424428
'storage.confirm.warningHighImpact': '⚠️ This will delete more than half of the data. Please confirm.',
425429
'storage.confirm.acknowledge': 'I understand this is irreversible',
430+
'storage.confirm.acknowledgeExclude': 'I understand this project will no longer be indexed',
431+
'storage.confirm.emptyProjectHint': 'This project currently has no sessions. Once excluded, future sessions will not be indexed either.',
432+
'storage.confirm.excludeAction': 'Confirm exclude',
433+
'storage.confirm.excluding': 'Excluding...',
426434
'storage.confirm.deleting': 'Deleting...',
427435
'storage.confirm.deleteAction': 'Confirm delete',
428436
'dashboard.title': 'Dashboard',

0 commit comments

Comments
 (0)