diff --git a/client/src/components/lanes/LaneChangesPanel.tsx b/client/src/components/lanes/LaneChangesPanel.tsx index c7923a9f..ebf8794d 100644 --- a/client/src/components/lanes/LaneChangesPanel.tsx +++ b/client/src/components/lanes/LaneChangesPanel.tsx @@ -1476,13 +1476,21 @@ export function LaneChangesPanel({ // that names how many untracked files it will delete. const discardTicked = async () => { if (!tickedPaths.length) return; + // Tracked and untracked counted apart: an untracked file is deleted, not + // reverted, and counting it in both told "10 changed + 10 new" for 10. + const untracked = files.filter((f) => f.untracked && tickedPaths.includes(f.path)).length; + const tracked = tickedPaths.length - untracked; const ok = await confirmDialog({ title: t("changes.discardTickedTitle"), - message: t("changes.discardTickedConfirm", { - count: tickedPaths.length, - untracked: files.filter((f) => f.untracked && tickedPaths.includes(f.path)).length, - }), - confirmLabel: t("changes.discardTicked"), + message: t( + untracked === 0 + ? "changes.discardTickedConfirmTracked" + : tracked === 0 + ? "changes.discardTickedConfirmNew" + : "changes.discardTickedConfirm", + { count: tracked, untracked } + ), + confirmLabel: t("changes.discardTicked", { count: tickedPaths.length }), }); if (!ok) return; const lane = laneId; diff --git a/client/src/components/lanes/__tests__/LaneChangesPanel.test.tsx b/client/src/components/lanes/__tests__/LaneChangesPanel.test.tsx index 2423098a..ac2086b2 100644 --- a/client/src/components/lanes/__tests__/LaneChangesPanel.test.tsx +++ b/client/src/components/lanes/__tests__/LaneChangesPanel.test.tsx @@ -844,9 +844,18 @@ describe("LaneChangesPanel", () => { // notes.txt (unversioned) starts unticked; untick docs/API.md too. await user.click(tickOf("docs/API.md")); + vi.mocked(confirmDialog).mockClear(); vi.mocked(confirmDialog).mockResolvedValueOnce(false); await user.click(screen.getByTestId("lane-changes-discard-all")); expect(api.lanes.gitAction).not.toHaveBeenCalled(); + // The confirm button carries its count, and a tracked-only selection + // says nothing about new files to delete. + expect(confirmDialog).toHaveBeenCalledWith( + expect.objectContaining({ + confirmLabel: "Discard (1)", + message: expect.not.stringMatching(/new file|\{\{/), + }) + ); await user.click(screen.getByTestId("lane-changes-discard-all")); await waitFor(() => diff --git a/client/src/i18n/locales/en/lanes.json b/client/src/i18n/locales/en/lanes.json index cb5135fb..1405bdc0 100644 --- a/client/src/i18n/locales/en/lanes.json +++ b/client/src/i18n/locales/en/lanes.json @@ -536,6 +536,8 @@ "changes.discardTicked": "Discard ({{count}})", "changes.discardTickedTitle": "Discard the ticked changes?", "changes.discardTickedConfirm": "The ticked changes in {{count}} file(s) go back to the last commit, and {{untracked}} ticked new file(s) git does not track yet are deleted. Unticked files and blocks are kept. This cannot be undone.", + "changes.discardTickedConfirmTracked": "The ticked changes in {{count}} file(s) go back to the last commit. Unticked files and blocks are kept. This cannot be undone.", + "changes.discardTickedConfirmNew": "{{untracked}} ticked new file(s) git does not track yet are deleted. Unticked files are kept. This cannot be undone.", "changes.amendAndPush": "Amend and Push", "changes.pushFailed": "Committed, but the push failed: {{error}}", "changes.tickFile": "Include {{path}} in the commit", diff --git a/client/src/i18n/locales/vi/lanes.json b/client/src/i18n/locales/vi/lanes.json index 83109af9..33ff0cbb 100644 --- a/client/src/i18n/locales/vi/lanes.json +++ b/client/src/i18n/locales/vi/lanes.json @@ -536,6 +536,8 @@ "changes.discardTicked": "Bỏ ({{count}})", "changes.discardTickedTitle": "Bỏ các thay đổi đã chọn?", "changes.discardTickedConfirm": "Các thay đổi đã chọn trong {{count}} file sẽ trở về commit cuối, và {{untracked}} file mới đã chọn chưa được git theo dõi sẽ bị xoá. File và đoạn không chọn được giữ nguyên. Không thể hoàn tác.", + "changes.discardTickedConfirmTracked": "Các thay đổi đã chọn trong {{count}} file sẽ trở về commit cuối. File và đoạn không chọn được giữ nguyên. Không thể hoàn tác.", + "changes.discardTickedConfirmNew": "{{untracked}} file mới đã chọn chưa được git theo dõi sẽ bị xoá. File không chọn được giữ nguyên. Không thể hoàn tác.", "changes.amendAndPush": "Amend và Push", "changes.pushFailed": "Đã commit, nhưng push thất bại: {{error}}", "changes.tickFile": "Đưa {{path}} vào commit",