Repository navigation
Fix: clarify uninstall/reinstall two-step + optional package removal - #430
Conversation
`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
|
| 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]
%%{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]
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
| console.print( | ||
| f" [dim]To reinstall FRESH: {_package_reinstall_hint()}[/dim]" | ||
| ) |
There was a problem hiding this 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.
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.| "--remove-package", | ||
| is_flag=True, | ||
| help="Also remove the tokenjam package (runs pipx/pip uninstall). " | ||
| "With --yes, removes it without a second prompt.", | ||
| ) |
There was a problem hiding this 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.
| "--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!
… (#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]>
tj uninstallremoves data, config, daemon, MCP registration, and editor wiring, but leaves the pip/pipx package in place. The old closing line only saidpipx uninstall tokenjamand never explained that a later plainpipx install tokenjamno-ops when the package is still present — so a "fresh install" silently does nothing (the exact pain Anil hit).Summary
tj uninstall.--remove-packageflag for non-interactive--yesruns).Messaging change
The closing output now:
pipx uninstall tokenjam/pip uninstall tokenjam, picked by install method).pipx upgrade tokenjam(orpipx install --force tokenjam), orpip install --upgrade tokenjam— with an explicit note that a plaininstallno-ops when tokenjam is already present.Optional package-removal prompt
--yes): after cleanup, promptsAlso remove the tokenjam package now? (runs pipx uninstall tokenjam)— default No.--remove-packagetriggers the same removal without a second prompt.pipx uninstall tokenjam). For pip/venv installs (or a missingpipx), it prints the exact command rather than guessing at the wrong environment. Ifpipx uninstallfails, it surfaces the error and the manual command instead of claiming success.Tests / Verification
tests/integration/test_cli_uninstall.py(CliRunner, 6 tests): package-remains messaging + FRESH-reinstall command form; pip-vs-pipx hint selection;--remove-packageruns 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
🤖 Generated with Claude Code