[#4] Stale-file protection #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
There is no check for whether the config file changed on disk since BCC loaded it (e.g. Claude itself rewrote it, or a second BCC window is open, or
claude mcp addran in a terminal) beforewrite_config()overwrites it. This is the same class of bug as the "config got clobbered" complaints — silent loss of concurrent changes.Proposed solution
load_config(), record the file'smtimeand content hash at load time (store in the returned structure or via a parallel_file_stampsdict keyed by path).write_config(), re-stat the file before writing. Ifmtimeor hash changed, do not overwrite — instead raise aStaleFileError(or return a sentinel) with a diff of what changed externally.bcc.py, catch this and show a dialog: "File changed externally — reload and reapply your edits, or overwrite anyway."Acceptance criteria
claude mcp addrunning between a BCC load and save is caught.Relevant code
bcc_core.py::load_config(line 135)bcc_core.py::write_config(line 226)