Skip to content

feat(work-files): delete file + JSON/JSONL format buttons - #16

Merged
JeanBaptisteRenard merged 1 commit into
mainfrom
feat/work-files-delete-and-format
May 24, 2026
Merged

JeanBaptisteRenard merged 1 commit into
mainfrom
feat/work-files-delete-and-format

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown
Collaborator

Two additions to the work-files viewer panel

Delete

  • New `delete-work-file` IPC, same path guard as `read-work-file` (must contain `/.work-files/` segment).
  • Trash-can button in the toolbar.
  • Confirms via `window.confirm` before unlinking; on success closes the panel and reloads the list.

Format

  • Toolbar button shown only for `.json` and `.jsonl` files.
  • `.json` → `JSON.stringify(parse(content), null, 2)`.
  • `.jsonl` → each line pretty-printed, joined with `---` separator so the multi-record nature stays visible.
  • Reads/writes the editor's document, doesn't touch disk.

Checks

  • `npm test` — 53/53 pass
  • `npm run lint` — 0 errors

Out of scope

A proper JSON tree explorer view was considered but skipped — the format button covers the immediate need (readable indentation) without adding a new view component. Easy follow-up if needed.

Adds two new actions to the work-files viewer panel:

1. Delete: confirms via window.confirm, calls delete-work-file IPC
   (guarded by the same /.work-files/ path check as read-work-file),
   then closes the panel and reloads the list.

2. Format: pretty-prints in-place. For .json files, JSON.stringify with
   2-space indent. For .jsonl, each line is pretty-printed and lines are
   joined with --- so the multi-record structure stays visible. Button
   only appears for .json / .jsonl extensions.

Both options are opt-in via ViewerPanel constructor (format: true,
onDelete: handler) and only wired for the work-files panel.
@JeanBaptisteRenard
JeanBaptisteRenard merged commit d20a426 into main May 24, 2026
6 checks passed
@JeanBaptisteRenard
JeanBaptisteRenard deleted the feat/work-files-delete-and-format branch May 24, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant