Skip to content

fix: pagination cap (#50), --time (#35), completions (#36), actionable auth failures (#72/#28/#66) - #104

Open
axsddlr wants to merge 6 commits into
jackwener:mainfrom
axsddlr:fix/open-issues
Open

axsddlr wants to merge 6 commits into
jackwener:mainfrom
axsddlr:fix/open-issues

Conversation

@axsddlr

@axsddlr axsddlr commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Four focused changes covering #50, #35, #36, and the account-safety / Windows-cookie issues (#72, #28, #66, #46). Each commit is independent; scope is 10 files, +649/−42.


#50 — honour an explicit --max for followers/following

_fetch_user_list clamped the requested count to self._max_count, which comes from rateLimit.maxCount (default 200) and was additionally bounded by a hard _ABSOLUTE_MAX_COUNT = 500. The cursor pagination underneath was correct, so an account with more followers than that was silently truncated no matter what --max said.

rateLimit.maxCount is now a default for calls that don't specify a count, not a ceiling on an explicit request. The safety ceiling rises 500 → 10000 and logs a warning when it engages, so truncation is visible instead of silent.

Tweets keep clamping to the configured maxCount — this issue is about user lists, and changing timeline behaviour is out of scope.

test_explicit_max_beyond_old_500_cap_is_fetched   600 users via explicit --max
test_explicit_max_ignores_configured_default      300 users vs a 200 default
test_safety_ceiling_still_applies                 absurd request is capped + warns

Negative control against the previous client.py: 4 of 5 fail.

#35 — --time to choose timestamp style

Output hard-coded relative times ("14d ago"). Adds a root --time {relative,absolute,iso} option plus an optional display.time config key:

  • relative (default) — unchanged
  • absolute — local wall-clock, 2026-03-14 21:08
  • iso — 2026-03-14T21:08:00+00:00

Both the feed table and the detail panel follow it. The detail panel used to print 2026-03-14 21:08 (3d ago); under absolute/iso it now prints one stamp instead of repeating the same value. --json/--yaml are untouched (they already carry createdAt and createdAtLocal).

#36 — shell completions

twitter completion {bash,zsh,fish} prints a completion script.

This uses Click's built-in support, so no dependency is added — the issue suggested shtab, but Click 8 already generates correct scripts and drives completion from the CLI's own command tree, so it cannot drift from the code.

twitter completion bash >> ~/.bashrc
twitter completion zsh  > "${fpath[1]}/_twitter"
twitter completion fish > ~/.config/fish/completions/twitter.fish

Tests assert each shell emits a real script (its completion function / #compdef), and that an unsupported shell or a missing argument errors.

#72 / #28 / #66 / #46 — make the failure mode actionable

Neither can be fully fixed by code here, so these make the cause and the workaround explicit instead of leaving a silent 404 or a misleading hint.

#72 (account flagged as a bot): X treats an unsigned write as automation. Writes now log a prominent warning when x-client-transaction-id is unavailable. Deliberately a warning, not a refusal — the change may still land, and hard-failing writes (as proposed in #101) turns a transient bootstrap failure into a broken command. Reads stay silent, since they usually just 404.

#28 / #66 (Windows Unable to get key for cookie decryption): this is almost always Chrome/Edge 127+ App-Bound Encryption, which browser_cookie3 cannot unwrap. The old hint blamed DPAPI permissions and suggested running as admin — the wrong path. It now names App-Bound Encryption, states it is not a permissions problem, and gives the two workarounds that work: use Firefox (TWITTER_BROWSER=firefox), or export auth_token/ct0 from DevTools / a cookie extension and set the env vars. The DPAPI / "close Chrome" / VSS-shadowcopy advice is kept as a secondary cause.

A full fix for #28/#66 needs a Windows-only ABC key extractor; that is out of scope here.


Verification

ruff      clean (0.15.4)
mypy      clean (1.14.1)
pytest    274 passed, 0 failed   (Python 3.10 and 3.12, Linux)

The Windows-branch tests pin sys.platform, so they assert Windows behaviour on any host — Linux CI caught the first revision not doing that, and the fix is included.

On Windows this branch still shows the repo's 3 pre-existing test_auth failures (the HOME/USERPROFILE issue); that is fixed separately in #102 and is unrelated to these changes.

…ackwener#50)

`_fetch_user_list` clamped the requested count to `self._max_count`, which
comes from `rateLimit.maxCount` (default 200) and was additionally bounded by
a hard `_ABSOLUTE_MAX_COUNT = 500`. The cursor pagination underneath was
correct, so an account with more followers than that was silently truncated no
matter what `--max` said.

Treat `rateLimit.maxCount` as a default for calls that do not specify a count,
not as a ceiling on an explicit request, and clamp only at the safety ceiling.
Raise that ceiling from 500 to 10000 — it exists to stop a typo or a runaway
config, not to cap legitimate requests — and log a warning when it engages so
the truncation is visible instead of silent.

Tweets are left clamping to the configured `maxCount`; this issue is about
user lists, and changing timeline behaviour is out of scope here.

Tests cover 600 users via an explicit --max (the old 500 ceiling), 300 users
against a 200 config default, the safety ceiling, and non-positive counts. A
negative control run against the previous client.py fails 4 of the 5.
Human-readable output hard-coded relative timestamps ("14d ago"), which is
awkward when you need to know *when* something was posted.

Add a root `--time {relative,absolute,iso}` option, plus an optional
`display.time` config key for people who want it always on:

* relative (default) — unchanged behaviour
* absolute — local wall-clock, "2026-03-14 21:08"
* iso — unambiguous, "2026-03-14T21:08:00+00:00"

Rendering goes through a single `_render_time` helper in formatter.py, so both
the feed table and the detail panel follow the setting. The detail panel
previously printed "2026-03-14 21:08 (3d ago)"; under absolute/iso it now prints
one stamp instead of the same value twice.

Structured output (--json/--yaml) is untouched: it already carries both
createdAt and createdAtLocal.
…r#36)

The CLI has ~30 subcommands with their own options, but shipped no completion,
so everything had to be typed from memory.

Add `twitter completion {bash,zsh,fish}`, which prints a completion script.
This uses Click's built-in completion support, so it adds **no dependency** —
the issue suggested shtab, but Click 8 already generates correct scripts for
every shell and drives completion from the CLI's own command tree, meaning it
cannot drift out of sync with the code.

Usage:

    twitter completion bash >> ~/.bashrc
    twitter completion zsh  > "${fpath[1]}/_twitter"
    twitter completion fish > ~/.config/fish/completions/twitter.fish

Tests assert each shell emits a real script (defines its completion function /
compdef), that an unsupported shell is rejected, and that a missing argument
errors rather than printing something useless.
Two advisory fixes for issues that cannot be resolved by code alone.

jackwener#28 / jackwener#66 / jackwener#46 — Windows cookie extraction
`Unable to get key for cookie decryption` on Windows is almost always
Chrome/Edge 127+ **App-Bound Encryption**, which browser_cookie3 cannot unwrap.
The old hint listed DPAPI causes and suggested running as admin, which sends
people down the wrong path. Detect the decrypt diagnostic and give the real
options: use Firefox (still readable), or export auth_token/ct0 from DevTools
or a cookie extension and set them as env vars. The existing DPAPI/VSS-copy
advice is retained as a secondary cause, since it is still valid when the
failure is not ABC.

Not a full fix: decrypting ABC would require a Windows-only key extractor.
That is out of scope here; the issue becomes actionable instead of cryptic.

jackwener#72 — account flagged as a bot
X treats an unsigned write as automation. Writes now log a prominent warning
when x-client-transaction-id is unavailable. Deliberately a warning, not a
refusal: the change may still land, and hard-failing writes (as proposed in
upstream jackwener#101) turns a transient bootstrap failure into a broken command.
Reads stay silent — they usually just 404, so a warning there is noise.

Tests cover both branches, including that a signed write and an unsigned read
do not warn, and that the write still returns headers rather than raising.
Adds the two new user-facing commands to the usage block, per the repo rule in
AGENTS.md that behaviour changes update the README in the same change.
These assertions branch on sys.platform, so they only held when the suite ran
on Windows; Linux CI failed. Pin sys.platform to win32 and clear the SSH vars,
matching how the existing keychain tests do it.

This branch has not been deployed

No deployments
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