Skip to content

Commit 5b8bb85

Browse files
Copiloteliandoran
andcommitted
Address code review feedback - add logging and constant for virtual branches
Co-authored-by: eliandoran <[email protected]>
1 parent 7cdd8ff commit 5b8bb85

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

apps/client/src/widgets/dialogs/branch_prefix.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { useTriliumEvent } from "../react/hooks.jsx";
1212
import FBranch from "../../entities/fbranch.js";
1313
import type { ContextMenuCommandData } from "../../components/app_context.js";
1414

15+
// Virtual branches (e.g., from search results) start with this prefix
16+
const VIRTUAL_BRANCH_PREFIX = "virt-";
17+
1518
export default function BranchPrefixDialog() {
1619
const [ shown, setShown ] = useState(false);
1720
const [ branches, setBranches ] = useState<FBranch[]>([]);
@@ -23,7 +26,7 @@ export default function BranchPrefixDialog() {
2326

2427
if (data?.selectedOrActiveBranchIds && data.selectedOrActiveBranchIds.length > 0) {
2528
// Multi-select mode from tree context menu
26-
branchIds = data.selectedOrActiveBranchIds.filter((branchId) => !branchId.startsWith("virt-"));
29+
branchIds = data.selectedOrActiveBranchIds.filter((branchId) => !branchId.startsWith(VIRTUAL_BRANCH_PREFIX));
2730
} else {
2831
// Single branch mode from keyboard shortcut or when no selection
2932
const notePath = appContext.tabManager.getActiveContextNotePath();

apps/server/src/routes/api/branches.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,22 @@ function setPrefixBatch(req: Request) {
278278
}
279279

280280
const normalizedPrefix = utils.isEmptyOrWhitespace(prefix) ? null : prefix;
281+
let updatedCount = 0;
281282

282283
for (const branchId of branchIds) {
283284
const branch = becca.getBranch(branchId);
284285
if (branch) {
285286
branch.prefix = normalizedPrefix;
286287
branch.save();
288+
updatedCount++;
289+
} else {
290+
log.info(`Branch ${branchId} not found, skipping prefix update`);
287291
}
288292
}
289293

290294
return {
291295
success: true,
292-
count: branchIds.length
296+
count: updatedCount
293297
};
294298
}
295299

0 commit comments

Comments
 (0)