Skip to content

Add edit mode for data sets/members: e to edit, explicit save only (ctrl+s)#25

Merged
Tannex merged 2 commits into
mainfrom
issue-17-edit-mode
Jul 19, 2026
Merged

Add edit mode for data sets/members: e to edit, explicit save only (ctrl+s)#25
Tannex merged 2 commits into
mainfrom
issue-17-edit-mode

Conversation

@Tannex

@Tannex Tannex commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Closes #17. Stacked on #24 (issue-16-dataset-favorites); merge that first — this PR's own changes are the last commit.

What

  • internal/zosmf: new opt-in TextEditor interface (ReadText/WriteText) implemented by Client and LazyClient. ReadText requests X-IBM-Return-Etag and captures the ETag; WriteText sends a text-mode PUT with If-Match so a host-side change fails the save (IsConflict detects HTTP 412). The read-only Browser interface is deliberately unchanged — cqt type-asserts for the write surface and degrades gracefully.
  • internal/cqt: e on a PS data set (dataset list) or PDS member (member list) fetches text and opens a full-area textarea editor with EDIT <target> chrome and a MODIFIED indicator; enter behavior is unchanged. RECFM U (load libraries) and unsupported DSORGs get a status message instead of an editor. ctrl+s is the only write path: it validates every line against LRECL (minus the RDW for V formats) and rejects the save naming the offending line. Conflicts keep the buffer and offer ctrl+r (explicit reload). esc on a dirty buffer asks for confirmation (d discards, esc/any key keeps editing); clean exit is immediate. Inside the editor q types into the buffer; ctrl+c still quits.
  • cmd/cqt: --read-only flag disables e entirely; demo mode implements the full edit/save/conflict flow in memory (shared across demo profiles).
  • README: keys table, synopsis, and a new Edit mode section (including the stty -ixon note for terminals that reserve ctrl+s).

Decisions on the issue's open questions

  • LRECL overflow: reject on save, pointing at the offending line (no truncation).
  • e from the records view: out of scope for v1 — lists only.
  • ctrl+s vs XOFF: kept ctrl+s; documented stty -ixon in the README.
  • Encoding: write-back uses z/OSMF text mode (same conversion contract as the existing FetchText read path); the buffer round-trips byte-identically with a single trailing newline normalized.
  • If the host returns no ETag on fetch, the editor warns that saves cannot detect concurrent changes and omits If-Match rather than blocking editing.

Validation

go build ./... && go vet ./... && go test ./... all pass. New tests: 6 in internal/zosmf (conditional GET/PUT headers, ETag round-trip, 412 conflict detection, target normalization) and 9 in internal/cqt (open/eligibility, dirty tracking, save gating, LRECL rejection, conflict + reload, discard confirmation, key routing, --read-only, missing write surface), plus demo round-trip/conflict tests in cmd/cqt.

🤖 Generated with Claude Code

Review follow-up

  • Encoding: text-mode payloads are ISO 8859-1 on the wire; the editor now decodes them to UTF-8 on fetch and encodes back on save, so ÆØÅ round-trips. LRECL validation measures encoded host bytes.
  • Line numbers: fixed five-column gutter.
  • Scroll inertia: profiled to ~19 ms per keypress at 1000 lines (the textarea re-renders its whole buffer per update, slower than key repeat, so events queued and drained after release). Held navigation keys are now coalesced into one batch per 12 ms tick.
  • ctrl+c: removed inside the editor (and the jq popup); esc with the dirty confirm is the way out.

@Tannex
Tannex force-pushed the issue-16-dataset-favorites branch from eb9a420 to fd44fae Compare July 19, 2026 10:05
@Tannex
Tannex force-pushed the issue-17-edit-mode branch 2 times, most recently from 42b1a4d to 8591b6a Compare July 19, 2026 10:09
@Tannex Tannex linked an issue Jul 19, 2026 that may be closed by this pull request
6 tasks
@Tannex
Tannex force-pushed the issue-16-dataset-favorites branch from 1e5213f to 8c8cba3 Compare July 19, 2026 11:28
Press e on a PS data set or PDS member to open its text content in a
full-area textarea editor; enter keeps its browse behavior. Nothing is
ever written implicitly: ctrl+s is the only write path, validating each
line against the data set LRECL before sending an If-Match conditional
PUT through a new opt-in zosmf.TextEditor surface (the read-only Browser
interface is unchanged). Conflicts surface in the status line with the
buffer intact and ctrl+r as an explicit reload. Dirty exits require a
confirmation; --read-only disables edit mode entirely. Demo mode
supports the full flow in memory, including ETag conflicts.

Closes #17

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Tannex
Tannex force-pushed the issue-17-edit-mode branch from 8591b6a to 67c351c Compare July 19, 2026 11:30
Base automatically changed from issue-16-dataset-favorites to issue-15-dsn-copybook-mappings July 19, 2026 12:18
Base automatically changed from issue-15-dsn-copybook-mappings to main July 19, 2026 12:19
@Tannex

Tannex commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Edit mode does not seem to map encoding very well, ÆØÅ renders fine in view, but not in edit.

@Tannex

Tannex commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Always reserve 5 characters for line number

@Tannex

Tannex commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Holding arrow down in edit mode will keep scrolling for a bit after it is released

@Tannex

Tannex commented Jul 19, 2026

Copy link
Copy Markdown
Owner Author

Get rid of explicit ctrl+c binding in edit mode.

- Decode text-mode payloads from ISO 8859-1 (the z/OSMF wire encoding)
  into UTF-8 on fetch and encode back on save, so ÆØÅ round-trips in the
  editor exactly as it renders in the browse view. LRECL validation now
  measures encoded host bytes, not UTF-8 bytes, and unmappable runes are
  rejected with their line number.
- Reserve a fixed five-column line-number gutter (MaxHeight=99999 also
  sizes the textarea's wrap cache; files past that line count were
  already impractical to edit).
- Fix scroll inertia when holding an arrow key: the textarea re-renders
  its whole buffer per update (~19ms/keypress at 1000 lines, profiled),
  slower than terminal key repeat, so events queued and kept scrolling
  after release. Repeat-prone navigation keys are now coalesced and
  applied in one batch per 12ms tick, costing a single re-render.
- Remove the explicit ctrl+c quit binding inside the editor; esc (with
  the dirty confirm) is the way out, quitting stays on the list screens.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Tannex
Tannex merged commit 10fd282 into main Jul 19, 2026
4 checks passed
@Tannex
Tannex deleted the issue-17-edit-mode branch July 19, 2026 13:52
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.

Edit mode for datasets/members: e to edit, explicit save only (ctrl+s)

1 participant