Skip to content

Commit 1d52faf

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent f9991f2 commit 1d52faf

13 files changed

Lines changed: 38 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
3737
- **Settings UI for v2.0.0 platform features** — added sections/cards for migration rehearsal/integrity checks, passphrase-protected backups, archive scheduler and compression, profile management, and database encryption.
3838
- **CI quality gates** — added `npm test`, Rust `cargo test`, Tauri build smoke test, offline critical-journey tests, and migration-rehearsal job to `.github/workflows/ci.yml`.
3939
- **Dashboard Insights enhancements** — added saved views, distraction hotspot card, and Apps/Categories/Projects comparison tabs.
40+
- **VS Code Insights manual refresh** — added a refresh button to the VS Code Insights page header, matching the browser extension refresh behavior.
4041
- **Focus rule backend integration** — Focus Mode rules now persist in the backend `focus_rules` table with CRUD commands and backend-driven auto start/stop.
4142
- **Profile state isolation** — moved profile metadata and `current_profile_id` into a separate unencrypted `app_state.db` so profile switching remains reliable even when individual profile databases are encrypted.
4243
- **Full Japanese, Korean, French, German, and Spanish localization** — completed frontend translations across all desktop namespaces (`common`, `dashboard`, `widgets`, `settings`, `limits`, `categories`, `goals`, `focus`, `browserUsage`) for `ja`, `ko`, `fr`, `de`, and `es`.

src/i18n/locales/de/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "Wochenvoreinstellung",
180180
"month": "Monatsvoreinstellung",
181181
"backToToday": "Zurück zu heute"
182-
}
182+
},
183+
"refresh": "Aktualisieren"
183184
}

src/i18n/locales/en/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "Week preset",
180180
"month": "Month preset",
181181
"backToToday": "Back to today"
182-
}
182+
},
183+
"refresh": "Refresh"
183184
}

src/i18n/locales/es/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "Preajuste de semana",
180180
"month": "Preajuste de mes",
181181
"backToToday": "Volver a hoy"
182-
}
182+
},
183+
"refresh": "Actualizar"
183184
}

src/i18n/locales/fr/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "Préréglage semaine",
180180
"month": "Préréglage mois",
181181
"backToToday": "Retour à aujourd'hui"
182-
}
182+
},
183+
"refresh": "Rafraîchir"
183184
}

src/i18n/locales/ja/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "週のプリセット",
180180
"month": "月のプリセット",
181181
"backToToday": "今日に戻る"
182-
}
182+
},
183+
"refresh": "更新"
183184
}

src/i18n/locales/ko/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "주 프리셋",
180180
"month": "월 프리셋",
181181
"backToToday": "오늘로 돌아가기"
182-
}
182+
},
183+
"refresh": "새로고침"
183184
}

src/i18n/locales/zh-CN/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "周预设",
180180
"month": "月预设",
181181
"backToToday": "一键回到今天"
182-
}
182+
},
183+
"refresh": "刷新"
183184
}

src/i18n/locales/zh-TW/dashboard.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,6 @@
179179
"week": "週預設",
180180
"month": "月預設",
181181
"backToToday": "一鍵回到今天"
182-
}
182+
},
183+
"refresh": "重新整理"
183184
}

src/pages/VsCodeInsights/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default function VsCodeInsights() {
4444
const [trackingLevel, setTrackingLevel] = useState<string>("standard");
4545
const [focusEnabled, setFocusEnabled] = useState(false);
4646
const [saving, setSaving] = useState(false);
47+
const [refreshing, setRefreshing] = useState(false);
4748

4849
const range = useMemo(() => {
4950
if (periodMode === "month") {
@@ -108,6 +109,15 @@ export default function VsCodeInsights() {
108109
}
109110
};
110111

112+
const handleRefresh = async () => {
113+
setRefreshing(true);
114+
try {
115+
await fetchVsCodeStatsForRange(range.start, range.end);
116+
} finally {
117+
setRefreshing(false);
118+
}
119+
};
120+
111121
// Conditional section visibility: show if data exists OR level covers it
112122
const showLanguage = vscodeLanguageStats.length > 0 || trackingLevel === "standard" || trackingLevel === "detailed";
113123
const showProject = vscodeProjectStats.length > 0 || trackingLevel === "detailed";
@@ -128,14 +138,23 @@ export default function VsCodeInsights() {
128138
<div className="flex items-center gap-2">
129139
{/* Tracking on/off toggle in header */}
130140
<button
131-
disabled={saving}
141+
disabled={saving || refreshing}
132142
onClick={onToggleTracking}
133143
title={t("dashboard:vscodeTrackingToggle")}
134144
className={`ui-btn-secondary !text-xs !px-3 !py-1.5 disabled:opacity-60 ${!trackingEnabled ? "opacity-50" : ""}`}
135145
>
136146
{trackingEnabled ? t("dashboard:statusEnabled") : t("dashboard:statusDisabled")}
137147
</button>
138148

149+
<button
150+
disabled={refreshing}
151+
onClick={handleRefresh}
152+
title={t("dashboard:refresh")}
153+
className="ui-btn-secondary !text-xs !px-3 !py-1.5 disabled:opacity-60"
154+
>
155+
{refreshing ? t("common:loading") : t("dashboard:refresh")}
156+
</button>
157+
139158
<select
140159
className="ui-select !w-24 !py-1.5 !text-xs"
141160
value={periodMode}

0 commit comments

Comments
 (0)