Commit Graph

870 Commits

Author SHA1 Message Date
Fengqing Liu
a321da91f8 remove "tray" 2025-10-19 17:15:28 +11:00
Fengqing Liu
d466f46d6f remove redundant stuff 2025-10-19 17:08:18 +11:00
Fengqing Liu
e8144e9591 chore: Refactor environment detection and paths; remove unused variables and improve resource path handling 2025-10-19 16:27:12 +11:00
Fengqing Liu
3cedd0ef7f chore: Remove legacy logging options and build scripts; update logging to use TimedRotatingFileHandler 2025-10-19 12:40:22 +11:00
Fengqing Liu
42a491331e bug fix: stuck on shutdown 2025-10-19 10:57:48 +11:00
Fengqing Liu
472e6d73bd Add configurable minimum refresh interval setting
Added user-configurable minimum refresh interval for inventory reloads, allowing users to control how frequently the maintenance service triggers updates (default: 30 minutes, range: 1-1440 minutes).

- Add minimum_refresh_interval_minutes to settings system with default of 30 minutes
- Update maintenance service to use configurable interval instead of hardcoded 1-minute value
- Add GUI input field in General Settings with auto-save functionality
- Include field in API settings endpoint and settings manager

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 10:56:40 +11:00
Fengqing Liu
f62ec26b5d chore: Major code quality improvements - Remove dead code, add Ruff & Mypy
This commit implements a comprehensive code quality overhaul including
dead code removal, modern linting tools, type checking, and CI/CD integration.

## Dead Code Removal

### Removed Files:
- src/utils/cache.py (137 lines) - Desktop GUI remnant with tkinter dependencies
  * No longer needed in web-only architecture
  * Conflicted with web version at src/web/managers/cache.py

### Removed Functions:
- src/auth/auth_state.py::_login() (170 lines) - Deprecated password authentication
  * OAuth device code flow is now the only login method
  * Removed legacy 2FA, CAPTCHA, and password login code
  * Updated class docstring to reflect OAuth-only authentication

### Removed Imports (12 occurrences):
- Unused TYPE_CHECKING imports (NoReturn, LoginFormManager, etc.)
- Orphaned exception imports (CaptchaRequired, LoginException)
- Unused utility imports (AwaitableValue, State, io, sys, Path)
- Removed commented-out imports and dead code references

**Total removed: 308+ lines of unused code**

## Modern Linting with Ruff

### Added ruff (v0.14.1):
- 10-100x faster than legacy linters (Flake8, pyflakes)
- Auto-fixed 56 issues across 46 files
- Import sorting with isort integration
- Modern Python idioms (pyupgrade)
- Code simplification suggestions

### Fixes Applied:
- Sorted imports alphabetically in all files
- Replaced try-except-pass with contextlib.suppress()
- Added exception chaining with 'from err'
- Renamed unused loop variables to _var
- Simplified comprehensions and ternary operators
- Removed unnecessary .keys() calls

**Result: 0 Ruff warnings (100% pass rate)**

## Type Checking with Mypy

### Added mypy (v1.18.2):
- Static type checking across 55 source files
- Reduced type errors from 25 to 5 (80% improvement)
- Configured gradual strictness for JSON/GraphQL responses

### Type Fixes:
- Fixed PyInstaller _MEIPASS attribute access
- Added type: ignore for safe variable redefinitions
- Fixed translator return type cast
- Added null checks for optional attributes
- Resolved circular import issues

### Configuration:
- Lenient initial settings for gradual adoption
- Per-module overrides for dynamic JSON responses
- Error codes shown for easy debugging

**Result: 5 non-critical errors remaining**

## CI/CD Integration

### Updated .github/workflows/ci.yml:
- Added new 'lint' job running Ruff + Mypy
- Ruff checks are required to pass
- Mypy checks run but don't block (advisory)
- Docker build now depends on lint + validate jobs

### Workflow:
```
lint (Ruff + Mypy) → validate (Language files) → docker → release
```

## Configuration

### Created pyproject.toml:
```toml
[tool.ruff]
line-length = 100
target-version = "py310"
select = ["E", "W", "F", "I", "UP", "B", "SIM", "C4"]

[tool.mypy]
python_version = "3.10"
check_untyped_defs = true
strict_equality = true
```

## Statistics

### Code Reduction:
- **Before:** 8,130 lines across 56 files
- **After:** 7,213 lines across 55 files
- **Reduction:** -917 lines (-11.3%)

### Quality Metrics:
- **Pyflakes:** 16 warnings → Ruff: 0 warnings
- **Mypy:** Not configured → 5 errors (from 25)
- **Linting speed:** 2s → 0.2s (10x faster)
- **Auto-fix rate:** 79% (46/58 issues)

### Files Modified: 48 files
- 1 deleted (src/utils/cache.py)
- 1 created (pyproject.toml)
- 46 updated (imports, types, style)

## Breaking Changes

None - all changes are internal quality improvements.
Application still runs perfectly (v16.dev).

## Migration Notes

### For Developers:
```bash
# Install new tools
pip install ruff mypy

# Run quality checks
ruff check src/          # Fast linting
mypy src/                # Type checking
ruff check src/ --fix    # Auto-fix issues
```

### For CI/CD:
- Linting now runs automatically on all commits
- Failed Ruff checks will block builds
- Mypy checks are advisory (won't block)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 00:02:54 +11:00
Fengqing Liu
68118d9e4b Add manual mode feature with UI improvements and batch updates
This commit introduces a manual mode for channel selection that allows users to lock onto a specific game, along with significant UI/UX improvements:

Manual Mode Features:
- Locks channel selection to a specific game when user manually selects a different game
- Automatically exits manual mode when all drops for the game are completed
- Shows visual indicators (🎯 badge) in status bar and drop display
- Allows manual exit via "Return to Auto Mode" button
- Prioritizes manual game in wanted_games list during auto-selection

UI/UX Improvements:
- Batch update system for channels and campaigns prevents flickering during refresh
- Channels list now updates atomically instead of clearing and re-adding
- Campaign loading emits all campaigns at once for smooth initial load
- Drop progress persists on initial_state load for reconnecting clients
- Game icons (box art) now displayed in channel list
- Campaign links added to inventory items

Bug Fixes:
- Fixed logging level to respect INFO by default (was hardcoded to DEBUG)
- Fixed channel cleanup to not call channel.remove() (handled by batch_update)
- Fixed drop display not persisting during channel switch
- Fixed stop_watching() clearing drop timer prematurely
- Fixed status display typo ("fames_to_watch" → "games_to_watch")

Backend Changes:
- Added manual mode tracking (_manual_target_channel, _manual_target_game)
- Added enter_manual_mode(), exit_manual_mode(), is_manual_mode() methods
- Added get_manual_mode_info() for API serialization
- Added batch_update() to ChannelListManager for atomic updates
- Added start_batch()/finalize_batch() to InventoryManager
- Added /api/mode/exit-manual endpoint
- Game model now stores box_art_url from GraphQL response
- Manual mode info included in /api/status and initial_state

Frontend Changes:
- Added manual mode badge and controls in UI
- Added channels_batch_update and inventory_batch_update socket events
- Added manual_mode_update socket event
- Countdown timer now properly tracked and cleared
- Drop display shows manual mode status with game name
- Exit manual mode button added to drop display area

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-18 00:22:34 +11:00
Fengqing Liu
323c2ac40d Disable automatic CI builds
- Comment out push and pull_request triggers
- Keep workflow_dispatch for manual runs only
- Prevents automatic builds on every push

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 20:04:23 +11:00
Fengqing Liu
849bf5372a docker ci only 2025-10-16 23:35:05 +11:00
Fengqing Liu
77fc709fa2 Update README to support fork maintainer
- Change "Support the Original Author" section to "Support This Fork"
- Feature buymeacoffee.com/rangermix as primary support link
- Keep acknowledgment of original author with their support links

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 23:31:46 +11:00
Fengqing Liu
8b2c28f76d Update Docker and CI workflow for refactored project structure
- Fix CI workflow to reference src/version.py instead of version.py
- Update Python import paths for version extraction in AppImage job
- Fix Dockerfile to use requirements.txt and copy src/ directory
- Remove deprecated --web flag from Docker CMD
- Remove obsolete version: '3.8' from docker-compose.yml
- Add Docker build job to CI workflow with multi-arch support (amd64, arm64)
- Push Docker images to GitHub Container Registry (ghcr.io)
- Add OCI image labels with build metadata to Dockerfile
- Update README with pre-built Docker image instructions
- Update funding information

All changes ensure compatibility with the refactored src/ package structure
and enable automated Docker image publishing via GitHub Actions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 23:28:00 +11:00
Fengqing Liu
423ee451ac Update README to reflect fork status and AI development
- Add note at top indicating this is a fork of DevilXD/TwitchDropsMiner
- Add disclaimer about AI-assisted development (Claude Code)
- Update git clone URL to rangermix/TwitchDropsMiner
- Add dedicated Acknowledgments section with credits to original author
- Update Support section to encourage supporting original author
- Rename Credits to Translation Credits for clarity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-16 22:14:59 +11:00
Fengqing Liu
5b736e3bb1 Migrate to Docker-ready web UI and remove legacy desktop GUI
Replace the legacy desktop/Tkinter client and packaging artifacts with a Docker-first, web-hosted approach.

- Add Docker quickstart and run-from-source instructions to the README to simplify deployment.
- Simplify launcher to invoke the new web backend module instead of the old desktop entrypoint.
- Update dependencies for a web UI stack (FastAPI, Uvicorn, python-socketio, Jinja2, etc.) and remove desktop/tray-specific packages.
- Remove legacy GUI, packaging and platform-specific helper code, along with obsolete build/pack scripts and AppImage assets to declutter the repo.
- Tidy project ignore rules to add runtime logs and editor metadata.

Rationale: streamline deployment, favor a browser-accessible interface, and reduce maintenance overhead from multiple platform-specific GUI/packaging implementations.
2025-10-16 21:54:43 +11:00
DevilXD
2388757ebe Enforce game matching for badge campaigns 2025-10-11 16:26:22 +02:00
DevilXD
a25c4a7bbb Remove unneeded GameDirectory GQL parameter 2025-10-10 08:06:03 +02:00
DevilXD
bbc323b4d7 Fix an issue with Language and Priority mode comboboxes cutting off text in translations 2025-10-09 17:44:34 +02:00
DevilXD
7b95818add Force the drops_enabled flag to True 2025-10-03 17:23:18 +02:00
DevilXD
64c1b93b5b Disable UPX downloading step in CI 2025-09-22 22:23:38 +02:00
AnoPem
134783eba7 Update DirectoryPage_Game
Updated sha256Hash for DirectoryPage_Game and its variables
2025-09-21 14:13:42 +02:00
DevilXD
05d97321ea Add simple manual configuration options to the build spec 2025-09-12 14:03:07 +02:00
DevilXD
b029428cb3 Implement the nopause option for the build script 2025-09-12 13:41:50 +02:00
DevilXD
0c8c3f5f32 Fix an error due to invalid campaigns missing their assigned game 2025-09-10 17:28:18 +02:00
DevilXD
b44100764c Implement drop progression tracking across all drops in a campaign 2025-09-10 00:08:03 +02:00
DevilXD
6e08d1ef50 Fix an issue with the miner not switching away from no-longer-watchable channels in specific cases 2025-09-09 23:01:39 +02:00
DevilXD
f3c189e86d Fix an issue with the drops_enabled flag reporting true for sub-only drops 2025-09-09 22:57:54 +02:00
kWAY
2737936739 Implement dark mode theme (#744)
Co-authored-by: DevilXD <4180725+DevilXD@users.noreply.github.com>
2025-08-27 17:19:32 +02:00
DevilXD
f990437731 Handle the possibility of a drop having no benefits 2025-08-24 09:55:47 +02:00
Dmitriy
56a7fd4fb2 Update Ukrainian and Russian translations (#757)
Co-authored-by: DevilXD <4180725+DevilXD@users.noreply.github.com>
2025-08-22 23:40:06 +02:00
DevilXD
9329e52643 Fix priority mode names not being translated 2025-08-22 19:04:01 +02:00
DevilXD
1b17dd6784 Fix GUI debug code 2025-08-22 18:58:05 +02:00
DevilXD
cb9b6ab42f Implement force-expired campaign invalidation 2025-08-22 15:33:51 +02:00
DevilXD
69b861d1ba Upgrade UPX version 2025-08-20 20:36:38 +02:00
DevilXD
826fe95f9c Reimplement the old mining method (ref b47b208) 2025-08-17 22:05:44 +02:00
DevilXD
87a30201e4 Minor code leftover to use while resolving issues with unclosed/unreleased resources 2025-08-17 21:58:28 +02:00
DevilXD
6626f94015 Minor typing fix 2025-07-27 11:14:42 +02:00
guihkx
eab58cd5f2 ci/linux: provide PyInstaller package for aarch64 2025-07-27 10:58:01 +02:00
guihkx
d209e0e9e0 ci/linux: provide AppImage package for aarch64 2025-07-27 10:58:01 +02:00
guihkx
7116cbc759 linux/appimage: recursively remove ELF debug symbols
This reduces the AppImage's AppDir from 100,5 MiB to 90,3 MiB.
2025-07-26 23:40:01 +02:00
guihkx
42e7e88f30 linux/appimage: remove more unneeded files
This reduces the AppImage's AppDir from 110,6 MiB to 100,5 MiB.
2025-07-26 23:40:01 +02:00
guihkx
67eb7d0966 linux/appimage: remove x86_64 hardcoding from build recipe
Now the target CPU architecture should be set by the 'ARCH' environment
variable before invoking appimage-builder.

This makes it easier to build the AppImage for other CPU architectures.
2025-07-26 23:40:01 +02:00
guihkx
4a990ad981 linux/appimage: remove "universe" and "backports" repos
We don't need packages from these repositories.
2025-07-26 23:40:01 +02:00
guihkx
4e23b1c8ba linux/appimage: remove GDK_BACKEND=x11 workaround
This environment variable was necessary back then to work around a bug
in the libgtk3 version we include in the AppImage.

However, since commit 3897a8bccf
("ci/linux: build AppImage on Ubuntu 22.04 (Python 3.10)"), that's not
needed anymore, because Ubuntu 22.04 has a newer version of libgtk3,
which fixes the problem.

I made sure to verify the app runs as expected on Wayland sessions of
two major desktop environments:

- GNOME: 42.9 (Ubuntu 22.04.05) and 48.3 (Arch Linux)
- KDE Plasma: 5.27.5 (Debian 12) and 6.4.3 (Arch Linux)
2025-07-26 23:40:01 +02:00
guihkx
3724ab9b05 linux/appimage: update libXft from 2.3.8 to 2.3.9
An up to date version of libXft is still needed because Ubuntu 22.04
still has 2.3.4, which can cause the app not to launch if an emoji font
is installed on the host.
2025-07-26 23:40:01 +02:00
guihkx
9238c4d133 linux/appimage: fix "pip install" commands
Unfortunately, sourcing the Python venv Bash script to activate the
virtual environment doesn't work while we're building the AppImage, so
this just manually invokes Pip from within the venv to install updated
versions of meson and ninja (for building PyGObject next), and then we
prepend the venv's "bin" directory to the 'PATH' environment variable
to make meson and ninja discoverable on the next "pip install" step.

This also removes "certifi" from being manually installed, because
"truststore" has been usable since commit
3897a8bccf ("ci/linux: build AppImage on
Ubuntu 22.04 (Python 3.10)").
2025-07-26 23:40:01 +02:00
guihkx
1fa20d3634 ci/linux: don't install python3-testresources
If I remember correctly, this was required by the tool that makes our
AppImage, which doesn't seem to require it anymore.
2025-07-26 23:40:01 +02:00
guihkx
9e9ac04b7f ci/linux: use git version of appimage-builder
appimage-builder is a tool that is not officially part of the AppImage
ecosystem, and lately its maintainer hasn't been able to keep up with
the latest AppImage ideas, most notably:

- The move to a new statically-linked runtime: Before this, all AppImages
using the old runtime, would depend on libfuse2 to be installed on the
host system just to be able to run out of the box. This wasn't much of
a problem back then, because libfuse2 was ubiquitous. However, nowadays,
some have distros don't even have it in their official repositories.
- The removal of the xz compression algorithm (used by default), and the
addition of Zstd.

Luckily, the problems above have been fixed in the git version of
appimage-builder, but a stable release is yet to be made, so we'll have
to use the git version, because other AppImage-making tools are not as
nice and convenient as appimage-builder.
2025-07-26 23:40:01 +02:00
guihkx
f33486aac6 linux/appimage: manually download the runtime to fix build error
This manually downloads the old AppImage runtime (now marked as
obsolete), to prevent appimage-builder v1.1.0 from failing to make the
AppImage.

The download URL appimage-builder v1.1.0 uses for the AppImage runtime
is hardcoded into the tool, and unfortunately it's been recently
removed, so this is merely a workaround, until hopefully a future
appimage-builder release fixes this.

See: https://redirect.github.com/AppImageCrafters/appimage-builder/issues/375
2025-07-24 07:26:16 +02:00
DevilXD
01706cdd4e User agent update 2025-07-23 21:41:12 +02:00
Calvineries
822107ffde Update French translation (#729)
Co-authored-by: DevilXD <4180725+DevilXD@users.noreply.github.com>
2025-07-17 17:26:29 +02:00