Skip to content

Make --auto-close today a deadline, and name the real error - #109

Merged
TeoSlayer merged 1 commit into
TeoSlayer:mainfrom
monperrus:fix-auto-close-today
Sep 12, 2026
Merged

TeoSlayer merged 1 commit into
TeoSlayer:mainfrom
monperrus:fix-auto-close-today

Conversation

@monperrus

Copy link
Copy Markdown
Contributor

Fixes #83.

What was wrong

shell help reference lists today among the accepted --auto-close dates, but a bare day keyword resolved to midnight. Midnight today has passed whenever the command runs, so --auto-close today was rejected at every hour of every day — there was no time at which the documented form could work.

The rejection also misreported itself. The unquoted form (--auto-close <value> <command>) tries each prefix of the following arguments and, when no prefix parsed, discarded the parse error and called the value invalid. So --auto-close 2020-01-01 complained about grammar for a date it had read perfectly well, while the quoted --auto-close=2020-01-01 already said the deadline must be in the future.

What changed

  • Bare today now means the end of today, 23:59:59 local. The last second rather than the last minute, so the form still works while 23:59 is on the clock — otherwise the fix would leave a minute a day where it failed again.
  • Bare tomorrow is unchanged. The start of that day is still ahead, so it was already a deadline; touching it would change behaviour people already rely on.
  • normalizeAutoCloseArguments keeps the first token's own error and returns it when no prefix parses, so the unquoted and quoted forms now agree on why a value was refused.
  • shell help reference states what each bare keyword means instead of leaving it to be inferred.

User-visible behaviour

$ shell --auto-close today sleep 600
  Closes     2026-09-11T23:59:59+02:00, or when the task exits

$ shell --auto-close 2020-01-01 sleep 600
shell: auto-close deadline must be in the future

Before, the first printed shell: invalid auto-close value "today" and exited 2, and the second reported the same grammar error.

Security implications

None. --auto-close can only bring a session's deadline earlier than the task's own exit, and this change adds one accepted spelling of a deadline that is at most 24 hours out. It cannot extend a session, and it does not touch the relay, the session protocol, or the encryption path.

Regression tests cover the bare keywords, the unquoted form, that today stays a future deadline at every hour including 23:59:30, and that a past date reports a past deadline. go test -race ./..., go vet ./... and a gofmt check all pass.

🤖 Generated with Claude Code

monperrus added a commit to monperrus/shell.online that referenced this pull request Sep 11, 2026
Keeps the fork's main carrying everything tiramisu runs. The branch is left
alone because it is the head of TeoSlayer#109; rebasing it would
rewrite the pull request.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

# Conflicts:
#	CHANGELOG.md

@TeoSlayer TeoSlayer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useful feature, will amend docs to include it. Good on my end.

@TeoSlayer TeoSlayer mentioned this pull request Sep 12, 2026
@TeoSlayer

Copy link
Copy Markdown
Owner

Integrated into v0.12.1 via #118 after resolving the changelog conflict against current main. The auto-close behavior and regression tests are included. Thank you.

@TeoSlayer TeoSlayer closed this Sep 12, 2026
@TeoSlayer TeoSlayer reopened this Sep 12, 2026
Co-authored-by: Martin Monperrus <martin.monperrus+ai@gnieh.org>
@TeoSlayer
TeoSlayer merged commit 505acf4 into TeoSlayer:main Sep 12, 2026
15 checks passed
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.

"shell --auto-close today" is documented as valid but always fails with "invalid auto-close value"

3 participants