* fix: remove unnecessary websocket.js file and replace its usage directly in `WebSocketContext`
* fix: connect() doesn't need to be async
* fix: update WebSocket context import to use useWebSocket hook
* fix: use `useRef` for WebSocketContext
The main issue with using states was, previously the websocket never closed
properly on unmount, so multiple connections could be opened.
This was because the useEffect cleanup function was closing an old websocket
(that was initialized to null) instead of the current one.
We could have fixed this by adding `ws` to the useEffect dependency array, but
this was unnecessary since `ws` doesn't affect rendering so we shouldn't use a state.
* fix: replace `WebSocketContext` default value with null and add type definitions
* fix: add type definition for WebSocket URL and remove redundant protocol declaration
* fix: Prevent WebSocket reconnection attempts after unmount
Right now, when the WebSocketContext component unmounts,
there is still a pending reconnection attempt that tries
to reconnect the WebSocket after 3 seconds.
* refactor: Extract WebSocket URL construction into a separate function
* refactor: Centralize platform mode detection using IS_PLATFORM constant; use `token` from Auth context in WebSocket connection
* refactor: Use IS_PLATFORM constant for platform detection in authenticatedFetch function (backend)
* refactor: move IS_PLATFORM to config file for both frontend and backend
The reason we couldn't place it in shared/modelConstants.js is that the
frontend uses Vite which requires import.meta.env for environment variables,
while the backend uses process.env. Therefore, we created separate config files
for the frontend (src/constants/config.ts) and backend (server/constants/config.js).
* refactor: update import path for IS_PLATFORM constant to use config file
* refactor: replace `messages` with `latestMessage` in WebSocket context and related components
Why?
Because, messages was only being used to access the latest message in the components it's used in.
* refactor: optimize WebSocket connection handling with useCallback and useMemo
* refactor: comment out debug log for render count in AppContent component
* refactor(backend): update environment variable handling and replace VITE_IS_PLATFORM with IS_PLATFORM constant
* refactor: update WebSocket connection effect to depend on token changes for reconnection
---------
Previously, the model parameter was accepted by the /api/agent endpoint
and extracted from requests, but was never passed through to the Claude
SDK or Codex SDK, causing all requests to use default models regardless
of user selection.
Changes:
- Add model parameter to queryClaudeSDK() options in routes/agent.js
- Add model to threadOptions in openai-codex.js
- Remove unused /cost slash command and PRICING constants
- Centralize all model definitions in shared/modelConstants.js
- Update API documentation to dynamically load models from constants
Enhance the robustness of GitHub URL parsing and branch name
generation with better regex patterns and edge case handling.
Changes:
- Update GitHub URL regex to use non-greedy matching and anchored
.git suffix detection for more precise parsing
- Replace string-based .git removal with regex-based end anchor
- Add comprehensive validation for empty branch names with fallback
- Implement proper length calculation accounting for timestamp suffix
- Add final regex validation to ensure branch names meet safety
requirements
- Improve edge case handling for hyphens after truncation
- Add deterministic fallback for invalid branch name patterns
These changes prevent potential parsing errors with malformed URLs
and ensure generated branch names always meet Git naming conventions.
Added createBranch and createPR options to the agent API endpoint, enabling automatic branch creation and pull request generation after successful agent task completion. Branch names are auto-generated from the agent message, and PR titles/descriptions are auto-generated from commit messages. This streamlines CI/CD workflows by eliminating manual Git operations after agent runs.
Implement comprehensive API key management functionality including
generation, validation, and CRUD operations.
Changes:
- Add API key database schema and operations (create, validate, delete,
toggle)
- Generating a commit message will now work properly with claude sdk and cursor cli and return a suggested commit message
- Implement crypto-based key generation with 'ck_' prefix
- Add session ID tracking in claude-sdk.js and cursor-cli.js
- Update database layer with API key validation and last_used tracking
- Support multi-user API key management with user association
This enables secure programmatic access to the agent service