-
Notifications
You must be signed in to change notification settings - Fork 32
🤖 Reorganize utils/ into domain-specific subdirectories with absolute imports #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
ed26bbf to
a92be13
Compare
- Move asyncMutex.ts and mutexMap.ts to utils/concurrency/ - No functional changes, just organizational improvement _Generated with `cmux`_
- Move workspaceValidation.ts and test to utils/validation/ - Tests remain co-located with implementation _Generated with `cmux`_
- Move keybinds.ts, modeUtils.ts and tests to utils/ui/ - Update modeUtils.ts imports for new location _Generated with `cmux`_
- Move cacheStrategy.ts and providerOptions.ts to utils/ai/ - Groups AI model configuration and optimization strategies _Generated with `cmux`_
- Move messageUtils, modelMessageTransform, StreamingMessageAggregator to utils/messages/ - Keep all tests co-located with implementations - Groups message transformation and aggregation logic _Generated with `cmux`_
- Move toolDefinitions, toolPolicy, tools to utils/tools/ - Keep all tests co-located - Groups tool definitions, policies, and instantiation logic _Generated with `cmux`_
- Move tokenizer, tokenStatsCalculator, TokenStatsWorker, modelStats to utils/tokens/ - Move models.json to tokens/ directory - Update tokenizer.ts import to reference tools/toolDefinitions - Keep all tests co-located - Groups token counting, statistics, and model metadata _Generated with `cmux`_
- Update imports in 21 files across components, services, and types - All imports now point to domain-specific subdirectories: - concurrency/ (asyncMutex, mutexMap) - validation/ (workspaceValidation) - ui/ (keybinds, modeUtils) - ai/ (cacheStrategy, providerOptions) - messages/ (messageUtils, modelMessageTransform, StreamingMessageAggregator) - tools/ (toolDefinitions, toolPolicy, tools) - tokens/ (tokenizer, tokenStatsCalculator, TokenStatsWorker, modelStats) - No functional changes, only import path updates _Generated with `cmux`_
- Add @/* path alias to tsconfig.json and vite.config.ts - Convert all relative imports (../, ../../) to absolute imports (@/) - Update tsconfig.main.json to include necessary directories - Exclude web worker files from main process type checking Benefits: - No more import path hell with ../../../ - Clearer, more maintainable imports - Easier refactoring and file moves - Consistent import style across codebase _Generated with `cmux`_
_Generated with `cmux`_
The resolve.alias config was lost during a git checkout. Re-adding it so Vite/Rollup can resolve @/ imports during build. _Generated with `cmux`_
The added includes caused dist/main.js to output as dist/src/main.js, breaking electron-builder. The original config only includes main.ts and constants, which TypeScript then follows to include dependencies. _Generated with `cmux`_
b5a94be to
d1020e3
Compare
Remove PROPOSAL file and JS compilation artifacts that shouldn't be in the PR. _Generated with `cmux`_
ammario
added a commit
that referenced
this pull request
Oct 5, 2025
## Summary
Converts all relative imports (`../`, `../../`, etc.) to absolute
imports using the `@/` alias across the entire codebase.
## Changes
Systematically converted imports for all major directories:
- `../types/` → `@/types/`
- `../utils/` → `@/utils/`
- `../services/` → `@/services/`
- `../components/` → `@/components/`
- `../contexts/` → `@/contexts/`
- `../constants/` → `@/constants/`
- `../hooks/` → `@/hooks/`
- `../styles/` → `@/styles/`
**Files affected:** 22 files
**Net change:** 0 lines (86 insertions, 86 deletions - pure refactor)
## Benefits
- **No more import path hell**: Say goodbye to `../../../types/message`
- **Easier refactoring**: Moving files doesn't break dozens of import
statements
- **Consistency**: All imports follow the same `@/` pattern
- **Clarity**: Import paths are clearer and easier to understand
- **Maintainability**: New developers can find imports more easily
## Example
**Before:**
```typescript
import type { CmuxMessage } from "../../../types/message";
import { StreamManager } from "../../services/streamManager";
import { keybinds } from "../utils/keybinds";
```
**After:**
```typescript
import type { CmuxMessage } from "@/types/message";
import { StreamManager } from "@/services/streamManager";
import { keybinds } from "@/utils/keybinds";
```
## Testing
- ✅ `bun typecheck` passes
- ✅ All imports resolve correctly
- No functional changes, only import path updates
## Notes
This builds on PR #33 which:
- Reorganized utils/ into domain-specific subdirectories
- Added the @/ path alias configuration
_Generated with `cmux`_
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.
Problem
When retrying/resuming after stream interruption, the component wasn't passing provider options (specifically for Anthropic's 1M context window). This caused retries to fall back to the default 200k token limit, triggering "prompt too long" errors.
Additionally, the logic for building was duplicated between and , creating a maintenance burden and risk of divergence.
Solution
1. Created hook
2. Simplified IPC signature
resumeStream(workspaceId, model, options?)→resumeStream(workspaceId, options)3. Updated components
modelprop, removed duplicated codemodelprop to RetryBarrierBenefits
✅ Guaranteed parity - Physically impossible for retry/resume to use different options than send
✅ Current preferences - Retry always uses user's latest settings, not historical ones
✅ Less code - Eliminated ~30 lines of duplication
✅ Simpler props - RetryBarrier interface is cleaner
✅ Easy maintenance - Changes to option logic happen in one place
✅ Type-safe - All passing type checks
Testing
Generated with
cmux