aft icon indicating copy to clipboard operation
aft copied to clipboard

format_on_edit from the session's project reformats files in other repos

Open jjjermiah opened this issue 4 days ago • 1 comments

A session rooted in one repo reformats files it edits in a different repo, using the first repo's formatter setting.

rnd.gateway/.cortexkit/aft.jsonc sets format_on_edit: true and formatter.typescript: "biome". My user-level aft.jsonc names the same formatter and has format_on_edit: false. From a session in rnd.gateway I changed one line of a client.ts that lives in another git repo. That repo has no .cortexkit/aft.jsonc and no biome config, and the file is written with 2-space indents and no semicolons.

edit answered Edited (+230/-151). Auto-formatted — extensive reflow and the file came back in biome's defaults, with tabs and semicolons. I restored it with aft_safety undo. This is AFT 0.68.0.

#1293 settled that formatting is a project setting, which is why this surprised me: the file's own repo never turned it on. I expected a file outside the session's project root to be left as written, or to follow the config of the repo it lives in.

Is applying the session project's setting to outside paths intended? If it is, a way to scope format_on_edit to the project root would cover it.

jjjermiah avatar Nov 30 '26 07:11 jjjermiah

Thanks, @jjjermiah. Confirmed, and it isn't intended.

edit, write and patch take their settings from the project the session is bound to, and they use those settings for every file they write, including a file in another repository. So rnd.gateway's format_on_edit: true and biome reached client.ts. AFT also started Biome from rnd.gateway's folder, not from the other repository.

Proposed fix: a file outside the session's project only uses your user-level formatting settings. In your case that is format_on_edit: false, so the edit would have come back as Edited (+1/-1)., with nothing reformatted. If you turn formatting on at the user level, the formatter runs from the file's own folder, so it finds that repository's own style config. AFT then uses a formatter from your PATH, and never one from the other repository's node_modules/.bin. A session bound to the other repository keeps using that repository's own project settings.

I'll post here when it ships.

aft-alfonso[bot] avatar Nov 30 '26 08:11 aft-alfonso[bot]