Skip to content

Fix: clarify uninstall/reinstall two-step + optional package removal - #430

Merged
anilmurty merged 3 commits into
mainfrom
fix/uninstall-reinstall-ux
Jul 8, 2026
Merged

anilmurty merged 3 commits into
mainfrom
fix/uninstall-reinstall-ux

Conversation

@anilmurty

Copy link
Copy Markdown
Contributor

tj uninstall removes data, config, daemon, MCP registration, and editor wiring, but leaves the pip/pipx package in place. The old closing line only said pipx uninstall tokenjam and never explained that a later plain pipx install tokenjam no-ops when the package is still present — so a "fresh install" silently does nothing (the exact pain Anil hit).

Summary

  • Make the uninstall two-step crystal clear at the end of tj uninstall.
  • Optionally offer to remove the package too — a safe, default-No prompt (plus a --remove-package flag for non-interactive --yes runs).

Messaging change

The closing output now:

  • States plainly that data/config/wiring are removed but the package remains.
  • Gives the full removal command (pipx uninstall tokenjam / pip uninstall tokenjam, picked by install method).
  • Gives the command that actually reinstalls FRESH — pipx upgrade tokenjam (or pipx install --force tokenjam), or pip install --upgrade tokenjam — with an explicit note that a plain install no-ops when tokenjam is already present.

Optional package-removal prompt

  • Interactive (no --yes): after cleanup, prompts Also remove the tokenjam package now? (runs pipx uninstall tokenjam) — default No.
  • Non-interactive: --remove-package triggers the same removal without a second prompt.
  • Safety: only a pipx-managed install is auto-run (pipx uninstall tokenjam). For pip/venv installs (or a missing pipx), it prints the exact command rather than guessing at the wrong environment. If pipx uninstall fails, it surfaces the error and the manual command instead of claiming success.

Tests / Verification

  • New tests/integration/test_cli_uninstall.py (CliRunner, 6 tests): package-remains messaging + FRESH-reinstall command form; pip-vs-pipx hint selection; --remove-package runs pipx; non-pipx prints the command and does not run a subprocess; interactive prompt is offered; pipx-failure falls back to the manual command.
  • ruff check tokenjam/ clean; pytest tests/unit/ (1593 passed, 2 skipped) and the CLI integration tests green locally.

What's NOT in this PR

  • No change to what gets deleted (data/config/daemon/MCP/wiring behavior is untouched) — this is purely closing UX + the opt-in package-removal path.
  • No auto-run for pip/venv installs — deliberately printed, not executed, to avoid touching the wrong environment.

🤖 Generated with Claude Code

anilmurty and others added 2 commits July 8, 2026 16:20
`tj uninstall` removes data, config, daemon, MCP registration, and editor
wiring, but leaves the pip/pipx package in place. The closing message only
mentioned `pipx uninstall tokenjam` and never explained that a later plain
`pipx install tokenjam` no-ops when the package is still present — which reads
as a "fresh install" that silently does nothing.

Make the two-step crystal clear: state that the package remains, give the full
removal command, and give the command that actually reinstalls FRESH
(`pipx upgrade` / `pipx install --force`, or `pip install --upgrade`), with an
explicit note that a plain `install` no-ops when already present.

Also offer to remove the package as part of uninstall — an interactive
default-No `[y/N]` prompt (or the `--remove-package` flag for `--yes` runs).
Only a pipx-managed install is auto-run via `pipx uninstall tokenjam`; for
pip/venv installs (or a missing pipx) we print the exact command rather than
guessing at the wrong environment. Failures fall back to the manual command
instead of claiming success.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015e3DZGhb1R5sXX2x52Y2Ar
@anilmurty
anilmurty marked this pull request as ready for review July 8, 2026 23:53
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves the tj uninstall closing UX: it clarifies that the pip/pipx package remains after tj uninstall, adds a --remove-package flag for non-interactive removal, and introduces an interactive prompt (default No) for optional package cleanup.

  • cmd_uninstall.py gains _installed_via_pipx(), _package_reinstall_hint(), _remove_package(), and the --remove-package option; the closing output now shows the full two-step guidance with the correct fresh-reinstall command form.
  • tests/integration/test_cli_uninstall.py is a new 6-test CliRunner suite covering messaging, pip/pipx hint selection, the --remove-package flag, the non-pipx safe-print path, the interactive prompt, and the pipx failure fallback.

Confidence Score: 3/5

Safe to merge with the reinstall-hint fix; without it, users who fully remove the package via --remove-package are told to run pipx upgrade tokenjam which will fail immediately.

After pipx uninstall tokenjam succeeds in _remove_package(), the code prints _package_reinstall_hint() which returns pipx upgrade tokenjam (or: pipx install --force tokenjam). pipx upgrade requires the package to already be installed, so the primary suggested command errors out on the very scenario this flow was designed to handle.

tokenjam/cli/cmd_uninstall.py — specifically the reinstall hint printed inside _remove_package() after a successful uninstall.

Important Files Changed

Filename Overview
tokenjam/cli/cmd_uninstall.py Adds --remove-package flag, interactive prompt, and _remove_package() helper. The reinstall hint printed after a successful pipx uninstall recommends pipx upgrade tokenjam which fails when the package is no longer installed; after removal, plain pipx install tokenjam is the correct command.
tests/integration/test_cli_uninstall.py New 6-test integration suite covering messaging, pip-vs-pipx hint selection, --remove-package flag, non-pipx no-subprocess guarantee, interactive prompt, and pipx failure fallback. All tests use --yes via the _run helper, so the --remove-package-without-yes path has no coverage.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[tj uninstall] --> B{--yes?}
    B -- No --> C[Confirm: delete all data?]
    C -- No --> D[Cancelled]
    C -- Yes --> E[Run cleanup steps 1-11]
    B -- Yes --> E
    E --> F[Print: data/config/wiring removed\npackage still installed]
    F --> G{--remove-package flag?}
    G -- Yes --> H[_remove_package]
    G -- No --> I{--yes flag?}
    I -- No --> J[Prompt: Also remove package? default=No]
    J -- Yes --> H
    J -- No --> K[Print two-step guidance\nuninstall + FRESH reinstall hint]
    I -- Yes --> K
    H --> L{_installed_via_pipx AND pipx on PATH?}
    L -- Yes --> M[subprocess: pipx uninstall tokenjam]
    M --> N{returncode == 0?}
    N -- Yes --> O[Print: removed\nPrint: reinstall hint]
    N -- No --> P[Print: error + manual command]
    L -- No --> Q[Print: not pipx-managed\nPrint: manual uninstall command]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[tj uninstall] --> B{--yes?}
    B -- No --> C[Confirm: delete all data?]
    C -- No --> D[Cancelled]
    C -- Yes --> E[Run cleanup steps 1-11]
    B -- Yes --> E
    E --> F[Print: data/config/wiring removed\npackage still installed]
    F --> G{--remove-package flag?}
    G -- Yes --> H[_remove_package]
    G -- No --> I{--yes flag?}
    I -- No --> J[Prompt: Also remove package? default=No]
    J -- Yes --> H
    J -- No --> K[Print two-step guidance\nuninstall + FRESH reinstall hint]
    I -- Yes --> K
    H --> L{_installed_via_pipx AND pipx on PATH?}
    L -- Yes --> M[subprocess: pipx uninstall tokenjam]
    M --> N{returncode == 0?}
    N -- Yes --> O[Print: removed\nPrint: reinstall hint]
    N -- No --> P[Print: error + manual command]
    L -- No --> Q[Print: not pipx-managed\nPrint: manual uninstall command]
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
tokenjam/cli/cmd_uninstall.py:249-251
**Wrong reinstall hint after successful package removal**

After `pipx uninstall tokenjam` succeeds the package venv is gone, so the printed hint `pipx upgrade tokenjam` will immediately fail with "tokenjam is not installed" — `pipx upgrade` requires the package to already exist. `pipx install --force tokenjam` (the secondary suggestion) would work, but the primary command is wrong. The correct command after a full uninstall is a plain `pipx install tokenjam`; the "no-ops when already present" caveat that justifies the upgrade/force form doesn't apply once the package is actually gone.

### Issue 2 of 2
tokenjam/cli/cmd_uninstall.py:49-53
The `--remove-package` help text says "runs pipx/pip uninstall" but for non-pipx installs it deliberately only prints the command and never runs it. The help text should reflect that distinction so users aren't surprised when the flag doesn't run anything for their pip/venv install.

```suggestion
    "--remove-package",
    is_flag=True,
    help="Also remove the tokenjam package. For pipx installs, runs "
    "`pipx uninstall tokenjam` automatically; for pip/venv installs, "
    "prints the command instead (to avoid touching the wrong environment). "
    "With --yes, skips the interactive prompt.",
)
```

Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/uninstall-r..." | Re-trigger Greptile

Comment on lines +249 to +251
console.print(
f" [dim]To reinstall FRESH: {_package_reinstall_hint()}[/dim]"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Wrong reinstall hint after successful package removal

After pipx uninstall tokenjam succeeds the package venv is gone, so the printed hint pipx upgrade tokenjam will immediately fail with "tokenjam is not installed" — pipx upgrade requires the package to already exist. pipx install --force tokenjam (the secondary suggestion) would work, but the primary command is wrong. The correct command after a full uninstall is a plain pipx install tokenjam; the "no-ops when already present" caveat that justifies the upgrade/force form doesn't apply once the package is actually gone.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tokenjam/cli/cmd_uninstall.py
Line: 249-251

Comment:
**Wrong reinstall hint after successful package removal**

After `pipx uninstall tokenjam` succeeds the package venv is gone, so the printed hint `pipx upgrade tokenjam` will immediately fail with "tokenjam is not installed" — `pipx upgrade` requires the package to already exist. `pipx install --force tokenjam` (the secondary suggestion) would work, but the primary command is wrong. The correct command after a full uninstall is a plain `pipx install tokenjam`; the "no-ops when already present" caveat that justifies the upgrade/force form doesn't apply once the package is actually gone.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +49 to +53
"--remove-package",
is_flag=True,
help="Also remove the tokenjam package (runs pipx/pip uninstall). "
"With --yes, removes it without a second prompt.",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The --remove-package help text says "runs pipx/pip uninstall" but for non-pipx installs it deliberately only prints the command and never runs it. The help text should reflect that distinction so users aren't surprised when the flag doesn't run anything for their pip/venv install.

Suggested change
"--remove-package",
is_flag=True,
help="Also remove the tokenjam package (runs pipx/pip uninstall). "
"With --yes, removes it without a second prompt.",
)
"--remove-package",
is_flag=True,
help="Also remove the tokenjam package. For pipx installs, runs "
"`pipx uninstall tokenjam` automatically; for pip/venv installs, "
"prints the command instead (to avoid touching the wrong environment). "
"With --yes, skips the interactive prompt.",
)
Prompt To Fix With AI
This is a comment left during a code review.
Path: tokenjam/cli/cmd_uninstall.py
Line: 49-53

Comment:
The `--remove-package` help text says "runs pipx/pip uninstall" but for non-pipx installs it deliberately only prints the command and never runs it. The help text should reflect that distinction so users aren't surprised when the flag doesn't run anything for their pip/venv install.

```suggestion
    "--remove-package",
    is_flag=True,
    help="Also remove the tokenjam package. For pipx installs, runs "
    "`pipx uninstall tokenjam` automatically; for pip/venv installs, "
    "prints the command instead (to avoid touching the wrong environment). "
    "With --yes, skips the interactive prompt.",
)
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@anilmurty
anilmurty merged commit 1c0c723 into main Jul 8, 2026
4 checks passed
@anilmurty
anilmurty deleted the fix/uninstall-reinstall-ux branch July 8, 2026 23:56
anilmurty added a commit that referenced this pull request Jul 9, 2026
… (#434)

Five review findings from the just-merged onboarding batch, addressed
together because they cluster around the same onboard/uninstall UX and
the SDK exporter/backfill idempotency touched in that batch.

#432 (P1): the combination path double-ran the Codex backfill and printed
the closing home banner up to three times. `_onboard_codex` ran its own
backfill AND printed the banner, `_onboard_claude_code` printed the banner
too, and `_onboard_combination` did both again. Fix: give both per-path
sub-onboarders a `standalone: bool = True` parameter. The combination flow
passes `standalone=False`, which suppresses each sub-onboarder's own Codex
backfill and closing banner — so the backfill runs exactly once (in the
combination leg) and the banner prints exactly once (at the very end).
Single-path flows keep `standalone=True` and are unchanged.

#430 (P1): after a successful `pipx uninstall tokenjam`, the venv is gone,
so the printed reinstall hint `pipx upgrade tokenjam` would fail ("not
installed"). Added `_package_fresh_install_hint()` (bare `pipx install` /
`pip install`) and use it only on the successful-removal path. The
upgrade/--force hint stays where it belongs — when the package REMAINS
(a plain install would no-op there).

#430 (P2): `--remove-package` help text overstated ("runs pipx/pip
uninstall") — for non-pipx installs it only PRINTS the command. Reworded
the help + option text and the interactive confirm prompt so they say
"runs" for pipx and "prints … for you to run" for pip/venv.

#431 (P2): a whitespace-only ingest secret was truthy, so `TjHttpExporter`
built `Authorization: Bearer  ` — the same illegal header value the empty
case already guards against. Now guard on `.strip()` so a blank secret
omits the header entirely.

#433 (P2): `ingest_codex` issued one `SELECT 1 FROM spans WHERE span_id=$1`
per span. Aligned it with the Claude Code path's bulk idempotency by
reusing `core.backfill._existing_span_ids` — one chunked
`WHERE span_id IN (...)` per session partitions new-vs-existing spans,
replacing the per-span existence SELECT. Backends without a `conn`
(InMemoryBackend) fall back to plain inserts and let the PRIMARY KEY
conflict skip duplicates.

Tests: combination path backfills each source ONCE and prints the banner
ONCE (TestCombinationPathNoDoubleRun); after-removal reinstall hint is
`pipx install` not upgrade; prompt wording matches install type;
whitespace-only secret omits the Authorization header; a DuckDB-backed
idempotency test exercises the new bulk `_existing_span_ids` path.


Claude-Session: https://claude.ai/code/session_015e3DZGhb1R5sXX2x52Y2Ar

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

1 participant