Repository navigation
Refactor logging, improve fishing system, and fix concurrency issues - #65
Conversation
Previously, wizard_test.json was saved to the system temp directory. It is now saved to the application's base directory to ensure the file is stored alongside the executable rather than in a temporary location. #53
Replaced all usages of Assembly.GetExecutingAssembly().Location and AppDomain.CurrentDomain.BaseDirectory with a new AppPaths.ExeDirectory utility. Introduced AppPaths.cs to provide a consistent and reliable way to determine the executable's directory using Environment.ProcessPath. Updated all file and directory path constructions to use this utility, improving maintainability and ensuring correct file operations across different deployment scenarios. Removed unnecessary System.Reflection usings and cleaned up related code. Also removed <IncludeAllContentForSelfExtract> from the project file. #53
- Introduce Logger class with log levels (Debug/Info/Warning/Error), daily log files, and real-time UI event support - Add LogViewerForm for live log viewing, filtering, and file access - Replace all Debug.WriteLine and ad-hoc output with Logger calls across all services - Make log level user-configurable and persist in UserPreferences - Update MainForm with Log Viewer button and show log settings in UI - Update UIElementCoordinates.json and add estate fishing action resource #57
Adds an "Open Folder" button to the Log Viewer form, allowing users to open the Logs directory in File Explorer. The button is initialized in the designer and wired to an event handler that opens the folder if it exists, or displays a message if not. This improves access to previous log files. #57
- Overlay now displays cast and round (sell) progress in real time, with a new "Cast X/Y | Round X/Y" progress line. - Improved timing and detection reliability for fishing actions and popups. - Updated "Red Fishing Button" coordinates for better accuracy. - Log viewer toolbar simplified: removed log level, filter, and category controls; only essential buttons remain. - Log viewer loads last 30 log lines on open; log level is no longer user-configurable or stored in preferences. - Removed logging section from settings and related code. - Minor code cleanups and refactoring. #57
Introduced a "Quick Casting" feature that reduces the post-cast delay from 1500ms to 300ms for faster fishing, with a tradeoff of possible misdetections. Added a corresponding checkbox to the fishing UI, which disables "Wait For Fish" when enabled. Updated UserPreferences and settings logic to support saving/loading this option. Both standard and custom fishing modes now respect the Quick Casting setting.
Quick Casting now skips unreliable fish-caught detection and waits for the bite timeout, improving speed and reliability. The session summary dialog now shows only total casts when Quick Casting is enabled, while normal mode continues to display fish caught and catch rate.
Unify fish detection for QuickCasting and normal casting by always checking for fish caught in a loop after casting. Only apply the casting animation delay for non-QuickCasting. This simplifies the code and improves reliability of fish detection.
…is inaccurate count. The fishing completion dialog now always displays only the total number of casts, removing the previous detailed stats and catch rate.
- File naming: ttrbot_2026-03-04_14-30-05.log (includes time down to the second) - The filename is set once at startup and stays fixed for the session - WriteToFile is simplified — no more date-change checking or writer recycling - 7-day cleanup still runs (on startup now instead of date rollover) - GetCurrentLogFilePath() returns the session file - LogViewerForm message updated from "for today" to "for this session" #57
Updated log file reading to use FileShare.ReadWrite and StreamReader, preventing access errors when the logger has the file open. This ensures the log viewer can always read the latest entries without being blocked by the logger's file lock. #57
Convert static fields to instance fields to prevent state corruption between concurrent sessions. Stop handler now only cancels the token instead of immediately disposing it, preventing ObjectDisposedException. Fixes #60
Add file lock to all read/write operations on UIElementCoordinates.json to prevent data corruption from concurrent access. Fixes #61
Add try-catch for ObjectDisposedException and InvalidOperationException around BeginInvoke calls, matching the pattern already used by fishing's SafeOverlayInvoke. Fixes #62
Replaced Debug.WriteLine with Logger.Error so hook installation failure is visible in the log viewer instead of silently swallowed. Fixes #63
Clipboard.SetText can throw ExternalException if the clipboard is locked by another process. Added try-catch with user-friendly message. Fixes #64
Added changelog categories to release.yml for structured release notes based on PR labels, excluding those with skip-changelog. Enabled automatic generation of release notes during the release process.
Updated AssemblyInfo.cs, project file, and GlobalSettings.cs to reflect new application version 2.2.0.
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub release automation configuration to support auto-generated release notes and label-based changelog categorization.
Changes:
- Enabled
generate_release_noteswhen creating GitHub Releases via the workflow. - Added
.github/release.ymlto define changelog categories and exclusions for generated release notes.
Reviewed changes
Copilot reviewed 42 out of 44 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| .github/workflows/release.yml | Enables auto-generation of GitHub Release notes during the release step. |
| .github/release.yml | Adds label-based changelog categorization/exclusions for generated release notes. |
Files not reviewed (2)
- ToonTown Rewritten Bot/Views/LogViewerForm.Designer.cs: Language not supported
- ToonTown Rewritten Bot/Views/MainForm.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.get_version.outputs.VERSION }} | ||
| files: | | ||
| ${{ steps.create_zip.outputs.ZIP_NAME }} | ||
| draft: false | ||
| prerelease: false | ||
| generate_release_notes: true |
There was a problem hiding this comment.
The PR description references substantial C# changes (structured logging, CoordinatesManager locking, fishing updates, AssemblyInfo version bump), but the actual diff only changes GitHub release configuration. Either the description needs to be updated to match the scope of this PR, or the intended code changes are missing from the PR branch.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73cb9a1def
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Write to file on a background thread to avoid blocking | ||
| Task.Run(() => WriteToFile(entry)); |
There was a problem hiding this comment.
Serialize log writes without spawning a task per entry
Using Task.Run for every log call creates an unbounded stream of background work items, but writes are still serialized by _fileLock, so high-frequency logging now added in hot paths (for example CoreFunctionality.MoveCursor/SimulateDragMove) can build a large queue of pending tasks and degrade fishing timing/throughput under normal runs. A bounded queue with a single dedicated writer thread/task avoids this backlog while keeping logging asynchronous.
Useful? React with 👍 / 👎.
| private readonly string _logDirectory; | ||
| private readonly string _sessionLogFilePath; | ||
|
|
||
| public LogLevel MinimumLevel { get; set; } = LogLevel.Debug; |
There was a problem hiding this comment.
Make debug logging opt-in by default
The logger now defaults to LogLevel.Debug, and this commit also adds many debug statements in frequently executed automation paths, so a normal fishing session will continuously format and persist debug entries even when the user did not ask for diagnostics. This can materially increase I/O and CPU overhead compared with the previous Debug.WriteLine behavior; defaulting to Info (with an explicit debug toggle) would avoid performance regressions in production use.
Useful? React with 👍 / 👎.
Changed the default MinimumLevel in the Logger class from Debug to Info, so only Info-level and higher messages are logged by default. Debug messages will now be ignored unless explicitly enabled.
Refactor logging, improve fishing system, and fix concurrency issues
This pull request introduces several improvements and refactorings across the codebase, focusing on enhanced logging, improved thread safety for file operations, and better configuration for release management. The most significant changes include adding structured logging throughout the bot's core services, making file access in
CoordinatesManagerthread-safe, and updating release process configuration files.Logging and Observability Improvements:
System.Diagnostics.Debug.WriteLineand similar ad-hoc logging with structured calls to theLoggerutility throughoutCoreFunctionality.cs,CoordinatesManager.cs, andDoodleTraining.cs, providing more consistent and informative logs for mouse actions, coordinate resolutions, and error cases. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]Thread Safety and File Handling:
_fileLock) inCoordinatesManager.csand wrapped all file read/write operations in lock statements to ensure thread safety when accessing or modifying the coordinates JSON file. [1] [2] [3] [4] [5] [6] [7] [8]Code Refactoring and Clean-up:
DoodleTraining.csto use instance fields instead of static fields for training parameters, improving encapsulation and thread safety. Also added logging for training start.CoordinatesManager.csandCoreFunctionality.csto useAppPaths.ExeDirectoryinstead of reflection-based path resolution, simplifying code and improving reliability. [1] [2]using System.Reflection;fromCoordinatesManager.cs.Release Process Enhancements:
.github/release.ymlconfiguration to categorize changelog entries by label and exclude entries with theskip-changeloglabel..github/workflows/release.ymlto enable automatic generation of release notes.Versioning:
2.1.0.0to2.2.0.0inAssemblyInfo.cs.