Skip to content

Conversation

@mr-karan
Copy link
Owner

@mr-karan mr-karan commented Dec 26, 2025

Summary

This release includes a new feature, major refactoring, and tooling improvements.

✨ New Feature

🔧 Major Changes

  • LogChefQL Parser Rewrite - Replaced hand-written tokenizer with grammar-based parser using participle

    • Better error messages with position-aware diagnostics
    • More maintainable and extensible grammar definitions
  • Frontend Tooling Migration - pnpm + Vite → Bun + rolldown-vite

    • Build: ~2.3s (was >55s)
    • Dev server: ~1s (was ~3s)
    • Install: ~8s (was ~25s)
  • Frontend State Management - Refactored stores and composables

    • Centralized URL state synchronization
    • Single source of truth for context state

🐛 Fixes

  • Context propagation throughout backend (contextcheck compliance)
  • Reduced cyclomatic complexity in high-complexity functions
  • CI workflows updated for Bun ecosystem

mr-karan and others added 17 commits December 23, 2025 20:43
Replace pnpm with Bun and Vite with rolldown-vite for significantly
faster frontend tooling:

- Build: ~2.3s (was >55s)
- Dev server: ~1s (was ~3s)
- Install: ~8s (was ~25s)

Changes:
- Switch package manager from pnpm to Bun
- Replace vite with rolldown-vite for build/dev
- Keep standard vite for vitest (SSR compatibility)
- Update CI workflow to use Bun
- Update Justfile commands
Closes #5

This enables teams to share collection URLs and update the underlying
queries in the future without resharing the URLs - the same link
continues to work with updated content.

Features added:
- Bookmark toggle (is_bookmarked field) - bookmarked queries sort to top
- Shareable URLs: /logs/collection/{teamId}/{sourceId}/{collectionId}
- CollectionRedirect component for URL handling
- Star icon in dropdown and collections view
- Copy link functionality with toast notification
- "Update Current Query" in Explorer to save modified queries back
- Query name links now use shareable URL format

Backend changes:
- Migration adding is_bookmarked column
- Toggle bookmark API endpoint (PATCH)
- Updated query ordering (bookmarked first)

Frontend changes:
- Added patch method to apiClient
- Fixed isEditingExistingQuery detection (query_id param)
- Fixed SaveQueryModal to use content from initialData in edit mode
- Added @update handler in SavedQueriesView
- Updated getQueryUrl to return shareable collection URLs

Prompts: "implement issue #5 bookmark favorite queries"
- Upgrade all frontend dependencies (bun update)
- Upgrade all Go dependencies (go get -u)
- Migrate golangci-lint config from v1 to v2 format
- Add bookmark feature to CHANGELOG with contributor credit
- Remove .vite build artifacts from tracking
- Apply go fmt formatting changes
- Replace hand-written tokenizer/parser with formal grammar definitions
- Add detect.go for query type detection (LogChefQL vs SQL)
- Add grammar.go with token types and parsing rules
- Improve error messages with position-aware reporting
- Expand test coverage for edge cases

The new grammar-based parser is more maintainable and provides
better error diagnostics for malformed queries.
- Add ctx parameter to NewOIDCProvider, AddSource, checkSource,
  GetHealth, CreateTemporaryClient
- Update all call sites to pass context
- Add nolint:contextcheck for legitimate background goroutines
  (health checks, token cleanup)

Fixes contextcheck linter warnings about non-inherited contexts.
Extract focused helper functions from high-complexity methods:
- ExtractFirstNumeric: findFirstValue, convertToFloat64, deref helpers
- parseEngineParams: findMatchingParen, splitEngineParams, stripQuotes
- GetFieldDistinctValues: normalizeFieldValuesParams, extractFieldValues
- GetHistogramData: windowToIntervalFunc, buildHistogramQuery, parseHistogramResults
- UpdateAlert: applyAlertUpdates, applyQueryTypeUpdate, applyThresholdUpdates
- UpdateUser: applyUserUpdates, applyRoleUpdate, applyStatusUpdate
- handleGenerateAISQL: validateAIConfig, getSourceSchemaForAI, callAIToGenerateSQL

Reduces gocyclo scores from 21-36 down to <15 for all functions.
- Remove unused exported functions from sqlite layer
- Remove unused middleware and handler code
- Simplify metrics initialization and registration
- Clean up alerts manager and server handlers
- Remove redundant type conversions and nil checks
- Fix minor linting issues (gocritic, unused params)

No functional changes - pure cleanup for maintainability.
State Management:
- Consolidate explore store with cleaner state transitions
- Add useHistogramState and useUrlState composables
- Remove deprecated useExploreUrlSync (replaced by useUrlState)
- Simplify context store initialization

URL Handling:
- Centralize URL state synchronization
- Fix route sync edge cases

Stores:
- Cleaner base store patterns
- Improved teams store with better loading states
- Simplified saved queries management

Components:
- SaveQueryModal improvements
- Better histogram visualization state
- Cleaner alert views
Added alecthomas/participle/v2 parser generator library
used by the new grammar-based LogChefQL parser.
- Remove duplicate teamId/sourceId state from teamsStore and exploreStore
- contextStore is now the single source of truth for team/source context
- teamsStore.currentTeamId and exploreStore.sourceId are now computed from contextStore
- Remove sync watchers that copied state between stores

Bug fixes:
- Fix logout flow: clear contextStore and skip contextGuard for public routes
- Fix 'Loading Explorer...' stuck: continue initialization after URL update
- Fix URL spam while typing: only sync query content on execution, not keystroke

Files refactored:
- stores/teams.ts: currentTeamId -> computed from contextStore
- stores/explore.ts: sourceId -> computed from contextStore
- stores/alertHistory.ts: read teamId/sourceId from contextStore
- router/index.ts: only run contextGuard for authenticated routes
- composables/useUrlState.ts: remove live query sync, fix init flow
- alerts.ts: Remove lastLoaded duplicate state, add watcher to clear
  alerts when context changes
- savedQueries.ts: Remove selectedTeamId from state, read from
  contextStore, add watcher to clear queries on context change
- Remove dead code: useRouteSync.ts (not imported anywhere)

This ensures all stores properly react to context changes and don't
hold stale data when team/source switches.
…release workflow

- Update QueryService tests to use async translateLogchefQLToSQLAsync with mocked API
- Remove deprecated sync method tests to reduce dead code
- Replace pnpm with Bun in release.yml for frontend build consistency
- Create exploreHistogram.ts store for histogram state and API calls
- Create exploreAI.ts store for AI SQL generation
- Refactor explore.ts to delegate to new stores via composition
- Remove unused useHistogramState.ts composable (duplicate of store)
- Remove dead fetchHistogramData from HistogramService
- Clean up unused variables and imports

Reduces explore.ts complexity while maintaining same public API.
- Remove unused prepareQueryParams function from explore.ts
- Remove dead validateSQLWithDetails wrapper (called non-existent import)
- Remove dead analyzeQuery wrapper (called non-existent import)
- Remove dead generateDefaultSQLTemplate method
- Remove dead validateSQL method
- Clean up unused imports from QueryService.ts

These methods were either never called externally or called
functions that weren't imported, making them dead code.
Remove unused exports and files that are no longer referenced:
- api/logchefql.ts: createDebouncedValidator, clearTranslationCache
- api/types.ts: isErrorResponse, isAPIListResponse, isPaginatedResponse
- lib/utils.ts: registerSeverityField
- composables/useConnectionValidation.ts (entire file)
- composables/useFormHandling.ts (entire file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants