Address code review feedback - add logging and constant for virtual branches

Co-authored-by: eliandoran <21236836+eliandoran@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-02 22:00:54 +00:00
parent 7cdd8ffbe2
commit 5b8bb8587d
2 changed files with 9 additions and 2 deletions

View File

@@ -12,6 +12,9 @@ import { useTriliumEvent } from "../react/hooks.jsx";
import FBranch from "../../entities/fbranch.js"; import FBranch from "../../entities/fbranch.js";
import type { ContextMenuCommandData } from "../../components/app_context.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() { export default function BranchPrefixDialog() {
const [ shown, setShown ] = useState(false); const [ shown, setShown ] = useState(false);
const [ branches, setBranches ] = useState<FBranch[]>([]); const [ branches, setBranches ] = useState<FBranch[]>([]);
@@ -23,7 +26,7 @@ export default function BranchPrefixDialog() {
if (data?.selectedOrActiveBranchIds && data.selectedOrActiveBranchIds.length > 0) { if (data?.selectedOrActiveBranchIds && data.selectedOrActiveBranchIds.length > 0) {
// Multi-select mode from tree context menu // 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 { } else {
// Single branch mode from keyboard shortcut or when no selection // Single branch mode from keyboard shortcut or when no selection
const notePath = appContext.tabManager.getActiveContextNotePath(); const notePath = appContext.tabManager.getActiveContextNotePath();

View File

@@ -278,18 +278,22 @@ function setPrefixBatch(req: Request) {
} }
const normalizedPrefix = utils.isEmptyOrWhitespace(prefix) ? null : prefix; const normalizedPrefix = utils.isEmptyOrWhitespace(prefix) ? null : prefix;
let updatedCount = 0;
for (const branchId of branchIds) { for (const branchId of branchIds) {
const branch = becca.getBranch(branchId); const branch = becca.getBranch(branchId);
if (branch) { if (branch) {
branch.prefix = normalizedPrefix; branch.prefix = normalizedPrefix;
branch.save(); branch.save();
updatedCount++;
} else {
log.info(`Branch ${branchId} not found, skipping prefix update`);
} }
} }
return { return {
success: true, success: true,
count: branchIds.length count: updatedCount
}; };
} }