Skip to content

Feature: display banner only on the first run - #62

Merged
avelino merged 5 commits into
avelino:mainfrom
cereda:feature/one-time-banner
Oct 16, 2026
Merged

avelino merged 5 commits into
avelino:mainfrom
cereda:feature/one-time-banner

Conversation

@cereda

@cereda cereda commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Hopefully a better understanding of #39. 😉

Added --one-time-banner to jbundle. When present, the underlying wrapper will use the app_hash string to look for a file of the same name inside ${HOME}/.jbundle/runs. During the first app run, this file does not exist, so the banner is displayed as expected, and the file is created. Subsequent runs will check for the file, and since it exists, the banner will be omitted.

I need some coffee now. ☕ 🦆

@cereda

cereda commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

Clippy works locally, so I blame GH's CI. 😅

@avelino avelino 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.

Clean implementation, follows the existing compact_banner pattern. A few points before merge:

Tests

  • Missing test for happy path: one_time_banner = true generating stub with JBUNDLE_RUNS and [ ! -e ... ] logic
  • Missing test for default case: one_time_banner = false not containing JBUNDLE_RUNS
  • Missing test for compact_banner = true + one_time_banner = true combination

Cleanup of ~/.jbundle/runs/

This directory will accumulate marker files indefinitely. At minimum document this, ideally clean up alongside jbundle clean.

Race condition

If two instances of the same binary run in parallel for the first time, both pass the [ ! -e ... ] check before the touch. Banner shows up twice. No need to fix now, but document as a known limitation

@avelino

avelino commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Hey @cereda, this one is a nice touch for CLI tools, thanks! I pushed a commit on your branch to merge main in and harden one thing:

The stub runs with set -e, so if the marker under ~/.jbundle/runs couldn't be written (read-only HOME, a sandbox, some CI containers) the touch would kill the app before it started. Now a failed write just means the banner shows and the app carries on. I moved the logic into a small one_time_banner_block helper and added tests that actually run it: first run shows the banner, second run doesn't, and a HOME that can't be written still starts.

cargo test is green, clippy and fmt are clean.

One note on order: this touches the same lines as #61, so I'd land #61 first and then I'll merge main back in here and make --one-time-banner work with every --banner-size (with off it's simply a no-op). I'll take care of that part.

@avelino
avelino dismissed their stale review October 12, 2026 16:56

Addressed in 8bf16c9 and 3d59ded: tests for the one-time path, the default without markers and compact + one-time together; markers now live under ~/.jbundle/cache/runs so jbundle clean removes them; the parallel first-run double banner is documented as a known limitation.

- a marker that can't be written (read-only HOME, sandbox) no longer
  kills the app under set -e; the banner shows and the app starts
- banner logic moved to one_time_banner_block, JBUNDLE_RUNS only set
  when the option is on
- tests: first run shows the banner, second run doesn't, read-only HOME
  still starts

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
- markers move to ~/.jbundle/cache/runs so jbundle clean removes them
- test for compact_banner + one_time_banner together
- document where markers live and the parallel first-run limitation

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
@avelino
avelino force-pushed the feature/one-time-banner branch from 3d59ded to 0e3e7c3 Compare October 16, 2026 11:32
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>

# Conflicts:
#	src/pack/stub.rs
Resolve conflicts with the banner_size option from avelino#61: one_time_banner now
wraps whatever banner_size selects, and adds no marker when the banner is off.

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
@avelino
avelino merged commit 5122eb0 into avelino:main Oct 16, 2026
10 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.

2 participants