New Entry based on currently selected one #2

Closed
opened 2025-08-19 07:04:33 +00:00 by phg · 2 comments
Owner
When creating a new Entry,
Given I want to use an already existing Entry as base,
When I've selected the Entry I want to use as base for my new Entry,
And I press the defined key binding,
Then the add Entry modal should be pre-filled with the values of the selected Entry.

Key Binding: Shift+n

```gherkin When creating a new Entry, Given I want to use an already existing Entry as base, When I've selected the Entry I want to use as base for my new Entry, And I press the defined key binding, Then the add Entry modal should be pre-filled with the values of the selected Entry. ``` Key Binding: `Shift+n`
phg added the
Kind/Feature
label 2025-08-19 07:04:33 +00:00
phg added the
Priority
Medium
label 2026-09-03 07:40:45 +00:00
Author
Owner

Grilled specification

This design was grilled and confirmed on 2026-09-06.

Behavior

  • Add Shift+N as New from selected. Plain n remains the blank Add action.
  • Both actions use the existing Privileged Mode and minimum-terminal-size mutation gates.
  • Resolve the source from the currently highlighted visible Host Entry at invocation time. Filtering and display sorting must not cause a hidden or differently positioned Host Entry to be used.
  • Snapshot source values when the editor opens. Later source changes, including DNS worker updates, must not alter the form.
  • If no Host Entry is visible and selected, do not open the editor. Report: No Host Entry selected; use n to add a blank Host Entry.

Prefill rules

Copy only user-editable form state:

  • Entry Type
  • Canonical Hostname and Aliases, preserving their order
  • Comment
  • For an IP Entry: IP address and Active/Inactive state
  • For a DNS Entry: configured DNS name

Do not copy derived DNS state, including stored or resolved IP values, resolution time, or resolution status. A new DNS Entry starts inactive and follows the ordinary new-entry resolution flow.

A Default Entry may be used as the source. Submission continues to use ordinary validation and duplicate behavior; this action adds no special uniqueness rule or confirmation.

Entry Editor interaction

  • Keep the title Add Host Entry.
  • Show a muted source line: Based on: <Canonical Hostname>.
  • Initially focus Hostnames with the cursor at the end and no selected text. Blank Add retains its current focus behavior.
  • When switching Entry Type, preserve Hostnames and Comment.
  • Maintain separate IP-address and DNS-name drafts so switching back restores each value.
  • DNS remains inactive and cannot be activated.
  • Returning to IP restores its prior Active/Inactive draft.

Existing pipeline

Submission and cancellation reuse the ordinary Add pipeline, including validation, saving, rollback on failure, command history, undo, resulting selection, status feedback, and DNS resolution. Cancel creates no entry and performs no write.

Documentation

  • Document Shift+N — New from selected in the in-app help and complete user-guide key reference.
  • Keep the compact footer as n New.
  • No glossary change or ADR is needed.

Acceptance criteria

  1. Plain n opens blank Add; Shift+N opens New from selected.
  2. Read-only Mode and the minimum-size mutation lock block both through the existing feedback path.
  3. With an empty file or zero visible filter matches, Shift+N opens nothing and reports the agreed message.
  4. Under filtering and sorting, the highlighted visible Host Entry is the source, including when equal-valued duplicates exist.
  5. An IP source prefills type, ordered hostnames, IP address, comment, and Active/Inactive state.
  6. A DNS source prefills type, ordered hostnames, configured DNS name, and comment; it resets derived resolution state, starts inactive, and uses normal resolution after submission.
  7. Editing, cancelling, or submitting never mutates the source Host Entry.
  8. Default Entries are valid sources, and unchanged submission follows ordinary duplicate-add behavior.
  9. Initial focus, cursor placement, source line, and type-switch draft restoration match the interaction rules above.
  10. A source change after modal opening does not alter the captured form state.
  11. Cancel performs no command or save; submit retains existing save, rollback, selection, undo, and status semantics.
  12. In-app help and the user guide document the new shortcut; the footer remains compact.
## Grilled specification This design was grilled and confirmed on 2026-09-06. ### Behavior - Add `Shift+N` as **New from selected**. Plain `n` remains the blank Add action. - Both actions use the existing Privileged Mode and minimum-terminal-size mutation gates. - Resolve the source from the currently highlighted **visible Host Entry** at invocation time. Filtering and display sorting must not cause a hidden or differently positioned Host Entry to be used. - Snapshot source values when the editor opens. Later source changes, including DNS worker updates, must not alter the form. - If no Host Entry is visible and selected, do not open the editor. Report: `No Host Entry selected; use n to add a blank Host Entry.` ### Prefill rules Copy only user-editable form state: - Entry Type - Canonical Hostname and Aliases, preserving their order - Comment - For an IP Entry: IP address and Active/Inactive state - For a DNS Entry: configured DNS name Do not copy derived DNS state, including stored or resolved IP values, resolution time, or resolution status. A new DNS Entry starts inactive and follows the ordinary new-entry resolution flow. A Default Entry may be used as the source. Submission continues to use ordinary validation and duplicate behavior; this action adds no special uniqueness rule or confirmation. ### Entry Editor interaction - Keep the title **Add Host Entry**. - Show a muted source line: `Based on: <Canonical Hostname>`. - Initially focus Hostnames with the cursor at the end and no selected text. Blank Add retains its current focus behavior. - When switching Entry Type, preserve Hostnames and Comment. - Maintain separate IP-address and DNS-name drafts so switching back restores each value. - DNS remains inactive and cannot be activated. - Returning to IP restores its prior Active/Inactive draft. ### Existing pipeline Submission and cancellation reuse the ordinary Add pipeline, including validation, saving, rollback on failure, command history, undo, resulting selection, status feedback, and DNS resolution. Cancel creates no entry and performs no write. ### Documentation - Document `Shift+N — New from selected` in the in-app help and complete user-guide key reference. - Keep the compact footer as `n New`. - No glossary change or ADR is needed. ### Acceptance criteria 1. Plain `n` opens blank Add; `Shift+N` opens New from selected. 2. Read-only Mode and the minimum-size mutation lock block both through the existing feedback path. 3. With an empty file or zero visible filter matches, `Shift+N` opens nothing and reports the agreed message. 4. Under filtering and sorting, the highlighted visible Host Entry is the source, including when equal-valued duplicates exist. 5. An IP source prefills type, ordered hostnames, IP address, comment, and Active/Inactive state. 6. A DNS source prefills type, ordered hostnames, configured DNS name, and comment; it resets derived resolution state, starts inactive, and uses normal resolution after submission. 7. Editing, cancelling, or submitting never mutates the source Host Entry. 8. Default Entries are valid sources, and unchanged submission follows ordinary duplicate-add behavior. 9. Initial focus, cursor placement, source line, and type-switch draft restoration match the interaction rules above. 10. A source change after modal opening does not alter the captured form state. 11. Cancel performs no command or save; submit retains existing save, rollback, selection, undo, and status semantics. 12. In-app help and the user guide document the new shortcut; the footer remains compact.
Author
Owner

Feat #2: Implemented New from selected (Shift+N) in f2e2d45. The selected visible Host Entry now snapshots into the Add Host Entry form, including the DNS/IP draft and activation rules; help and user documentation are updated. Verified with mise run check (361 passed).

Feat #2: Implemented New from selected (Shift+N) in f2e2d45. The selected visible Host Entry now snapshots into the Add Host Entry form, including the DNS/IP draft and activation rules; help and user documentation are updated. Verified with `mise run check` (361 passed).
phg closed this issue 2026-09-06 16:12:59 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: phg/hosts#2
No description provided.