Repository navigation
feat(tui): close several windows at once with /close 2,3-5 - #38
Merged
Merged
Conversation
/close now takes a list of window numbers and ranges as well as one number: /close 1,2,3, /close 1-4, /close 2,3-5, /close 2, 3-5 and /close 2 3 5. Items are separated by commas and/or spaces; an item is N or A-B with A <= B, ASCII digits, no sign. /close alone still closes the current window. Every number is the window's number before the command, as the window bar shows it, so /close 2,3 closes the windows that were 2 and 3. A window named twice closes once. The whole argument is checked first and nothing closes on an error: a malformed item or reversed range is "/close takes window numbers: N, a list or ranges (as 2,3-5)", then window 0 anywhere is the server window's error, then the first number past the last window as written is "no window N" (which replaces the server window's error for /close 9). Signs (-1, +2) are now malformed. Each closed window gets its "window closed: <name>" notice in window 0 in window order; the status says "closed <name>" for one window and "closed N windows: 2:#dev, ..." cut after four as "+N more" for several; the layout is saved once. The current window stays current when it stays open, else the nearest open window before it becomes current. Closing focuses nothing, so no read receipt goes and no unread count changes; the last window is dropped when it closes, as before. The logic moves to internal/tui/close.go (closeSpec, closeWins); closeWin, used by the /win list [close] button, now goes through closeWins. specs/ui.md (Windows, the commands table), docs/usage.md and /help describe the forms, with the decisions: numbers as shown before the command, and all or nothing so a typo closes nothing.
TestCloseNoticesAndStatus runs every case with window 0 current, so it could not tell window 0 from the current window: notices sent to the current window instead would have passed it. TestCloseNoticesGoToWindowZero runs /close from a chat window, once one that stays open (window 6, /close 1,3) and once one that closes (window 3, /close 3-4, after which #dev is current). Window 0 gets exactly the "window closed: <name>" notices in window order, and no chat window that stays, the current one before or after included, gets any notice.
A number too large for an int reads as the largest int, so a range whose ends both overflowed, as 99999999999999999999-10000000000000000000, compared as equal and passed the reversed-range check: it was "no window 99999999999999999999", and with ",0" added the server window's error, instead of the /close form error that specs/ui.md gives a reversed range before the window-0 and past-the-end checks. Nothing closed either way; only the error text was wrong. The order of a range's ends now compares the digit text without leading zeros (its length, then digit by digit), which is exact for whole numbers of any length. The int value still serves the window-0 and past-the-end checks, where any overflowing number is past every window. specs/ui.md says the ends are compared as whole numbers of any length, with a decision: the error never depends on the machine's int size. TestCloseSpec gains overflowing ranges, reversed and not, and TestCloseIsAllOrNothing a reversed overflowing range that closes nothing.
Mark the item done in todo/todo.md and add session/2026-11-04-close-ranges.md: the forms, the all-or-nothing rule, the changed error texts, the review results and how to check it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
/close(also/wc,/part) now takes a list and ranges as well as one number:/close 2,3-5,/close 1-4,/close 1,2,3. Commas and/or spaces separate the items./closealone still closes the current window.5-3), window 0 or a missing window (no window N) closes none of them and changes nothing.window closed:notice in window 0, and one status line names them all (cut after four as+N more).no window N(it was the server-window error);+2is now malformed.specs/ui.md (with Decision lines), docs/usage.md and
/help(/close [N,M-K]) describe it.Review
make checkand the race tests pass.