Fix workspace switch race condition, gh auth detection, and file open perf#593
Open
RajPabnani03 wants to merge 1 commit intoathasdev:masterfrom
Open
Fix workspace switch race condition, gh auth detection, and file open perf#593RajPabnani03 wants to merge 1 commit intoathasdev:masterfrom
RajPabnani03 wants to merge 1 commit intoathasdev:masterfrom
Conversation
… perf Fix three open bugs (athasdev#581, athasdev#551, athasdev#572): 1. Bug athasdev#581 - Workspace State Not Preserved When Switching Folders: Move closeBuffersBatch() before new project loading in switchToProject() to prevent race conditions between session save and restore. Old terminal PTY processes are now cleaned up before new ones are spawned. 2. Bug athasdev#551 - Athas not detecting that GitHub CLI is authenticated: Parse gh auth status stderr for authentication indicators instead of relying solely on exit code. gh auth status can return exit code 0 even when the token is expired or invalid (see cli/cli#8845). Now checks for 'Logged in to' as positive confirmation and 'not logged in', 'token is invalid', 'Failed to log in' as failure indicators. 3. Bug athasdev#572 - Athas Lags on CachyOS / File Opening Performance: Remove per-entry symlink resolution from readDirectoryContents() that caused hundreds of stat syscalls during directory listing. Symlinks are still resolved lazily when files are opened. Also combine binary sniffing and content reading into a single readFile() call, eliminating the double-read that occurred for every file open. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2b95d5c to
e871e77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three open bugs (#581, #551, #572) and adds project MCP servers and skills for streamlined development.
Bug Fixes
1. Bug #581 — Workspace State Not Preserved When Switching Folders
Root Cause: In
switchToProject(), the old project's buffers were closed after the new project's background initialization (including session restore) was kicked off viavoid (async () => { ... })(). This created a race condition where closing old terminal buffers could kill PTY processes that the new project's restored terminals were trying to use, or vice versa.Fix: Move
closeBuffersBatch()to execute before the new project's directory reading and session restore, ensuring old workspace state is cleanly torn down before new state is loaded.2. Bug #551 — Athas not detecting that GitHub CLI is authenticated
Root Cause:
gh auth statuscan return exit code 0 even when the token is expired or invalid (known upstream issue cli/cli#8845). The original code only checkedoutput.status.success(), so it would report "authenticated" for invalid/expired tokens.Fix: Parse stderr output to check for authentication failure indicators (
"not logged in","token is invalid","Failed to log in", etc.) even when exit code is 0. Also check for"Logged in to"as positive confirmation when exit code is 0.3. Bug #572 — Athas Lags on CachyOS / File Opening Performance
Root Causes:
readDirectoryContents()calledgetSymlinkInfo()(astatsyscall via Tauri IPC) for every single entry in a directory. For large projects with hundreds/thousands of files, this meant hundreds of sequential I/O calls just to list a directory.handleFileSelect()read files twice — once for binary sniffing (readFile) and once for content (readFileContent), doubling I/O for every file open.Fixes:
readDirectoryContents(). Symlinks are still resolved lazily when a file is opened (inhandleFileSelect) or when a directory is expanded. This eliminates hundreds of stat syscalls during directory listing.readFile()call. The raw bytes are read once, checked for binary content, and then decoded to UTF-8 text usingTextDecoderinstead of reading the file a second time.Changed Files
crates/github/src/api.rsgh auth statusstderr for auth state instead of relying on exit code alonesrc/features/file-system/controllers/file-operations.tsreadDirectoryContents()src/features/file-system/controllers/store.tscloseBuffersBatch()before project switch; combine binary sniff + content read into single I/O passTesting
tsc --noEmit)rustfmtpasses oncrates/github/src/api.rsMCP Servers & Skills
MCP Servers (
.factory/mcp.json)Skills (
.factory/skills/)athas-bug-fixathas-performanceathas-release/athas-release)athas-contribution