Skip to content

fix(ui): keep the files of an edit in a directory removed on exit - #216

Merged
ingvarch merged 1 commit into
mainfrom
fix/edit-temp-dir
Nov 9, 2026
Merged

ingvarch merged 1 commit into
mainfrom
fix/edit-temp-dir

Conversation

@ingvarch

@ingvarch ingvarch commented Nov 9, 2026

Copy link
Copy Markdown
Owner

What changes

The file urga opens in the editor can hold a job spec, node meta, a namespace or a variable's values. Before, it stayed in the system temp directory when urga exited with the editor open. Now each run of urga makes its own directory, urga-<number> in the temp directory (mode 0700). Every edit file goes there, and urga removes the directory with everything in it on exit.

  • cmd/urga makes the directory before the program starts and removes it after Run returns, also when it returns an error (inEditDir). It passes the directory in ui.Options.EditDir.
  • Bubble Tea handles SIGINT and SIGTERM, not SIGHUP, so closing the terminal killed urga before any cleanup ran. cmd/urga now ends the program on SIGHUP through tea.WithContext. Run returns, the session is saved, and the directory is removed. The error printed is urga: hangup signal received.
  • The edit file is written when the model takes the edit (in the command startEdit returns), not when the resource is read. An edit dropped on its way, for example when the screen changed or urga quit before the read came back, now writes no file, so editFileMsg.release() is gone.
  • Text urga keeps on purpose (a refused edit or a plan that arrives after the screen changed, "Your text is in ...") still goes to the system temp directory, so it is still there after urga exits. A refused edit that comes back after the screen changed is now kept the same way as the other two cases (keepLate), not left in the edit directory.
  • docs/configuration.md says where the edit file is and when it is removed.

What I saw against the dev agent (TMPDIR set to a test directory, EDITOR=vim, e on job web):

  • Before: tmux kill-session with the editor open (SIGHUP) killed urga and vim and left urga-3510826525.hcl in the temp directory.
  • Before and after: kill -TERM with the editor open does nothing until the editor closes. Bubble Tea ignores signals while another program has the terminal. After :q! the file is removed as usual, and q exits.
  • After: tmux kill-session with the editor open leaves nothing named urga-*. Neither does kill -HUP sent only to urga: urga ends once the editor closes. vim's swap file went into the run directory and was removed with it.
  • SIGKILL cannot be handled: the directory stays. docs/configuration.md says so.

Not as the issue planned: it said writeTemp has one caller. keepText calls it too, for text that must survive the exit. So that text stays in the system temp directory, and only edit files go to the run directory.

Issues

Closes #200

Checklist

  • The test for this change was written first and failed
  • make check is green
  • The guide in docs/ is updated if users see a difference
  • The title is a conventional commit: feat(ui): ..., fix(nomad): ...

@ingvarch ingvarch added this to the v0.19.0 milestone Nov 9, 2026
@ingvarch ingvarch added bug Something isn't working ui Screens, keys and the header security Security hardening or a vulnerability fix labels Nov 9, 2026
@ingvarch
ingvarch enabled auto-merge (rebase) November 9, 2026 22:21
@ingvarch
ingvarch merged commit f689fc8 into main Nov 9, 2026
5 checks passed
@ingvarch
ingvarch deleted the fix/edit-temp-dir branch November 9, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security hardening or a vulnerability fix ui Screens, keys and the header

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A temporary edit file stays when urga exits with the editor open

1 participant