Expand description
The scratch file service (createscratchfile, movescratchfile), moved out of register_editor_handlers
unchanged as named functions. Spec: docs/specs/SPEC_EDITOR_WIDGET_DEFAULT_UX_2026_06_14.md. Each takes the
userβs home folder as a parameter, so a test can point it at a temp dir.
StructsΒ§
- Candidate π
- A saved-nowhere scratch buffer that could be handed out again.
ConstantsΒ§
- OUTSIDE_
HOME π - The refusal for a destination the Editor may not write: the same limit as its saves.
- THIRTY_
DAYS_ πMS
FunctionsΒ§
- claim_
most_ πrecent - Phase 2: try to atomically claim the most recent candidate. Claim files stop two concurrent calls returning the same backing file to different panes. Each claim file stores the per-process session token; a claim from a previous process (crash/restart) has a different token and is cleared so recovery works.
- copy_
to_ πnew_ file - Writes all of
fromto a new file atdest. The file is created exclusively, so one that appeared since any earlier check is never replaced; a write that fails part-way leaves nothing behind. - create_
scratch_ πfile - Creates a scratch buffer file in
~/.agentmux/cache/scratch/, or hands out the most recent unclaimed one. - mint_
scratch π - No reusable candidate: a fresh UUID pair, claimed so subsequent calls donβt immediately reuse it.
- move_
scratch_ πfile - Promotes a scratch buffer to a real user-chosen path (Save As, or a name typed into its tab). The errors are sentences, shown to the person as they are.
- save_
error π - A failed save as a sentence for the person.
- scan_
candidates π - Phase 1: scan the
.md.metafiles, collecting candidates (not saved, not expired, not inexclude_scratch_ids) and pruning expired pairs. - scratch_
dir_ πof