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 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<FBranch[]>([]);
@ -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();

View File

@ -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
};
}