Skip to content

Migrate front end to Vuejs 3 - #728

Closed
Tim020 wants to merge 3 commits into
devfrom
feature/v3-migration
Closed

Migrate front end to Vuejs 3#728
Tim020 wants to merge 3 commits into
devfrom
feature/v3-migration

Conversation

@Tim020

@Tim020 Tim020 commented Aug 31, 2025

Copy link
Copy Markdown
Contributor

No description provided.

Tim020 and others added 2 commits August 30, 2025 20:11
…chitecture (#726)

* Add Vue 3 migration Phase 1 foundation

- Create client-vue3/ directory with Vue 3.4+ foundation
- Set up Vite 5.4+ build system with TypeScript 5.4+
- Configure Vue Router 4.3+ with /v3/ base path
- Add Pinia 2.1+ state management setup
- Implement ESLint config with Airbnb + Vue 3 + TypeScript
- Add server integration for dual Vue 2/Vue 3 serving
- Include production build assets in server/static-vue3/

Side-by-side migration strategy: Vue 2 at /, Vue 3 at /v3/
Foundation ready for Phase 2: State Management and WebSocket integration

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove build artifacts from git and update server gitignore

- Remove server/static-vue3/ build artifacts from git tracking
- Add static-vue3/ to server/.gitignore for runtime build outputs
- Build artifacts should be generated at runtime, not committed

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix Python code quality issues in Vue 3 migration files

- Apply Black formatting to vue3_controllers.py and app_server.py
- Fix isort import sorting with proper blank line separation
- Remove trailing whitespace and add missing final newline
- Standardize string quotes and line formatting

Resolves GitHub Actions failures for Black, isort, and Pylint checks in PR #726.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Docker and GitHub Actions for dual Vue 2/Vue 3 frontend builds

- Update Dockerfile to build both Vue 2 and Vue 3 frontends
- Modify GitHub Actions build.yml to test and build both frontends
- Update nodelint.yml to lint both Vue 2 and Vue 3 with matrix strategy
- Add proper artifact separation for frontend builds
- Include Vue 3 TypeScript checking and linting in CI
- Remove CLAUDE.md from repository and add to .gitignore

Infrastructure now supports side-by-side Vue 2/Vue 3 development and deployment.
Docker builds both frontends and GitHub Actions validate both codebases.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Update build action to only build

* Optimize Dockerfile with multi-stage builds for parallel frontend building

- Split into separate vue2_build and vue3_build stages for parallel execution
- Add server_prep stage to combine both frontend builds efficiently
- Maintain build caching benefits while enabling concurrent building
- Reduce overall build time through improved parallelization

Vue 3 build now completes in 1.9s vs 55.1s for Vue 2 (parallel execution).
Build architecture optimized for faster CI/CD and development workflows.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Add npmrc file

* Fix Vue 3 routing and static file serving

- Fix Vue 3Controller to properly handle static asset routes
- Prevent JavaScript/CSS files from being served as HTML content
- Add .nvmrc to client-vue3 gitignore for Node version management
- Resolve white page issue caused by incorrect MIME type serving

Vue 3 application now loads correctly at /v3/ with proper asset handling.

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

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
…tegration (#727)

* feat: Vue 3 migration Phase 2 - Complete Pinia stores and WebSocket architecture

Implements comprehensive state management and WebSocket communication layer for Vue 3 with 100% backward compatibility with existing Vue 2 backend API.

## Core Features Implemented

### Pinia Store Architecture
- **WebSocket Store** (`src/stores/websocket.ts`): Complete state management for WebSocket connections
- **Authentication Store** (`src/stores/auth.ts`): User authentication with JWT token persistence
- **Store Integration** (`src/stores/index.ts`): Centralized store exports and configuration

### WebSocket Communication
- **WebSocket Composable** (`src/composables/useWebSocket.ts`): Vue 3 Composition API wrapper
- **Message Handling**: Preserves exact OP/ACTION routing logic from Vue 2 implementation
- **Automatic Reconnection**: Robust error handling and connection recovery
- **Authentication Flow**: JWT token integration with WebSocket authentication

### Testing & Validation
- **Test Interface** (`src/views/WebSocketTest.vue`): Comprehensive WebSocket connection testing
- **Utility Functions** (`src/utils/index.ts`): Core utility functions with TypeScript support

## Technical Implementation

### Compatibility Achievements
- Maintains 100% compatibility with existing backend WebSocket API
- Preserves exact message format: `{OP: string, ACTION?: string, DATA?: unknown}`
- Implements identical authentication flow and token management
- Replicates Vue 2 WebSocket event handling patterns

### TypeScript Integration
- Complete type definitions for WebSocket messages and store states
- Type-safe composable functions and store actions
- Comprehensive interface definitions for all data structures

### Architecture Patterns
- Composition API for reactive state management
- Centralized store pattern with Pinia
- Event-driven WebSocket communication
- Automatic state synchronization

## Migration Progress
- ✅ Phase 1: Foundation setup with side-by-side architecture
- ✅ Phase 2: Pinia stores and WebSocket implementation
- 🚧 Phase 3: Component migration (planned)
- 🚧 Phase 4: Feature parity and testing (planned)

## Files Modified
- `src/main.ts`: Pinia integration and app initialization
- `src/router/index.ts`: Added WebSocket test route
- `src/stores/index.ts`: Store exports and type definitions
- `src/views/HomeView.vue`: Basic component updates

## Files Added
- `src/stores/websocket.ts`: WebSocket state management (192 lines)
- `src/stores/auth.ts`: Authentication store (366 lines)
- `src/composables/useWebSocket.ts`: WebSocket composable (351 lines)
- `src/utils/index.ts`: Utility functions (64 lines)
- `src/views/WebSocketTest.vue`: Testing interface

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

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(auth): Add HTTP interceptor for automatic JWT token injection

Resolves 401 authentication errors in Vue 3 client by implementing
the missing HTTP interceptor functionality that exists in Vue 2.

**Problem:**
Vue 3 login was working, but subsequent API calls were getting 401
"User is not logged in" errors because JWT tokens weren't being
automatically added to HTTP requests.

**Solution:**
- Add HTTP interceptor that automatically injects JWT tokens from
  localStorage into all API requests
- Handle 401 responses with automatic token refresh mechanism
- Add proper Content-Type headers for POST/PUT requests
- Work independently of Pinia store initialization to avoid race conditions

**Key Features:**
- Automatic Authorization header injection for API requests
- Token refresh on 401 with retry of original request
- localStorage integration to avoid Pinia initialization dependencies
- Proper error handling and token cleanup on auth failure
- Only intercepts DigiScript API calls, passes through other requests

This should resolve authentication issues and allow the WebSocket
test interface to work properly after login.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(websocket): resolve connection issues and UI reactivity

Fix WebSocket connectivity problems that were preventing the "Connect
WebSocket" button from working and keeping buttons in disabled state.

Changes made:

1. **WebSocket Composable Reactivity**:
   - Fixed isConnected and isAuthenticated to return computed reactive
     values instead of raw store references
   - Added computed import for proper Vue 3 reactivity
   - Ensures UI properly updates when WebSocket connection state changes

2. **Vite Development Proxy Configuration**:
   - Updated WebSocket proxy path from '/ws' to '/api/v1/ws'
   - Aligns with actual backend WebSocket endpoint
   - Fixes WebSocket connections in development mode

These fixes resolve the core issues where:
- WebSocket connection button was non-functional
- UI components were not reactively updating connection status
- Development proxy was routing to incorrect WebSocket endpoint

Files modified:
- src/composables/useWebSocket.ts (reactivity fix)
- vite.config.ts (proxy configuration fix)

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix all ESLint violations in Vue 3 Migration Phase 2

Resolved 35 ESLint errors across multiple files:

**Configuration fixes:**
- Added eslint-import-resolver-typescript for proper path resolution
- Added DOM globals (RequestInfo, RequestInit, Headers, fetch) to ESLint config
- Enhanced TypeScript path mapping support
- Added DOM reference to env.d.ts

**Code quality fixes:**
- Fixed function hoisting issues in useWebSocket.ts using forward declarations
- Resolved import/export inconsistencies (default vs named exports)
- Fixed max-len violations by breaking long lines appropriately
- Replaced alert() calls with console.log/warn/error for better debugging

**TypeScript fixes:**
- Fixed RequestInfo/RequestInit type recognition
- Resolved module resolution issues for @/utils imports
- Updated import statements to match default export pattern

**Files modified:**
- client-vue3/.eslintrc.cjs: Added TypeScript resolver and DOM globals
- client-vue3/env.d.ts: Added DOM type reference
- client-vue3/package.json: Added eslint-import-resolver-typescript
- client-vue3/src/composables/useWebSocket.ts: Fixed function hoisting
- client-vue3/src/main.ts: Updated import to use default export
- client-vue3/src/utils/httpInterceptor.ts: Fixed types and export pattern
- client-vue3/src/views/HomeView.vue: Fixed line length violations
- client-vue3/src/views/WebSocketTest.vue: Fixed line length and alert usage

All ESLint errors resolved. TypeScript compilation and build successful.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(deps): sync package-lock.json to resolve CI npm install failures

Resolves picomatch version mismatch that was causing CI failures with error:
"npm ci can only install packages when your package.json and package-lock.json are in sync
Invalid: lock file's picomatch@2.3.1 does not satisfy picomatch@4.0.3"

Changes:
- Updated picomatch from 2.3.1 to 4.0.3 in main dependency tree
- Resolved nested dependency conflicts by reorganizing picomatch placement
- Eliminated duplicate picomatch versions in tinyglobby and micromatch subtrees
- Set typescript as devOptional for better dependency resolution

This enables GitHub Actions ESLint workflow to proceed successfully and
unblocks PR #727 Vue 3 Migration Phase 2.

Verified:
- npm ci now completes without errors
- ESLint passes with 0 violations (npm run ci-lint)
- TypeScript compilation succeeds (npm run type-check)

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Update actions

---------

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added github GitHub actions related issue or pull request server Pull requests changing back end code xlarge-diff git client-new labels Aug 31, 2025
@github-actions

Copy link
Copy Markdown

Test Results

26 tests   26 ✅  3s ⏱️
 1 suites   0 💤
 1 files     0 ❌

Results for commit 8f58367.

@Tim020 Tim020 closed this Nov 28, 2025
@Tim020
Tim020 deleted the feature/v3-migration branch November 28, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-new git github GitHub actions related issue or pull request server Pull requests changing back end code xlarge-diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant