From 5b8bb8587d850d32137dd03ebae2742a22228f12 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 2 Nov 2025 22:00:54 +0000 Subject: [PATCH] Address code review feedback - add logging and constant for virtual branches Co-authored-by: eliandoran <21236836+eliandoran@users.noreply.github.com> --- apps/client/src/widgets/dialogs/branch_prefix.tsx | 5 ++++- apps/server/src/routes/api/branches.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/dialogs/branch_prefix.tsx b/apps/client/src/widgets/dialogs/branch_prefix.tsx index 4a1c025b0..26f6f0dff 100644 --- a/apps/client/src/widgets/dialogs/branch_prefix.tsx +++ b/apps/client/src/widgets/dialogs/branch_prefix.tsx @@ -12,6 +12,9 @@ import { useTriliumEvent } from "../react/hooks.jsx"; import FBranch from "../../entities/fbranch.js"; import type { ContextMenuCommandData } from "../../components/app_context.js"; +// Virtual branches (e.g., from search results) start with this prefix +const VIRTUAL_BRANCH_PREFIX = "virt-"; + export default function BranchPrefixDialog() { const [ shown, setShown ] = useState(false); const [ branches, setBranches ] = useState([]); @@ -23,7 +26,7 @@ export default function BranchPrefixDialog() { if (data?.selectedOrActiveBranchIds && data.selectedOrActiveBranchIds.length > 0) { // Multi-select mode from tree context menu - branchIds = data.selectedOrActiveBranchIds.filter((branchId) => !branchId.startsWith("virt-")); + branchIds = data.selectedOrActiveBranchIds.filter((branchId) => !branchId.startsWith(VIRTUAL_BRANCH_PREFIX)); } else { // Single branch mode from keyboard shortcut or when no selection const notePath = appContext.tabManager.getActiveContextNotePath(); diff --git a/apps/server/src/routes/api/branches.ts b/apps/server/src/routes/api/branches.ts index 86699f5ba..977fd34a7 100644 --- a/apps/server/src/routes/api/branches.ts +++ b/apps/server/src/routes/api/branches.ts @@ -278,18 +278,22 @@ function setPrefixBatch(req: Request) { } const normalizedPrefix = utils.isEmptyOrWhitespace(prefix) ? null : prefix; + let updatedCount = 0; for (const branchId of branchIds) { const branch = becca.getBranch(branchId); if (branch) { branch.prefix = normalizedPrefix; branch.save(); + updatedCount++; + } else { + log.info(`Branch ${branchId} not found, skipping prefix update`); } } return { success: true, - count: branchIds.length + count: updatedCount }; }