Skip to main content
Glama
bbernstein
by bbernstein
CHANNEL_VALUES_CLEANUP.md3.61 kB
# Channel Values Refactor - Cleanup Summary ## Date: 2025-12-12 ## Overview Removed remaining references to the legacy `channelValues` array format and updated to use the new sparse `channels` format throughout the lacylights-mcp codebase. ## Changes Made ### 1. src/services/ai-lighting.ts **Updated AI prompt generation (lines 247-261)** - Changed the AI prompt to request the new sparse format: `{"offset": 0, "value": 255}` - Updated instructions to emphasize sparse format (only specified channels; explicit zero values allowed) - Old format: `{"fixtureId": "id", "channelValues": [255, 128, 0]}` - New format: `{"fixtureId": "id", "channels": [{"offset": 0, "value": 255}, {"offset": 1, "value": 128}]}` **Backward Compatibility Maintained** - The `validateFixtureValues` method (lines 374-455) still handles: - Legacy `channelValues` array format (converts to sparse) - New `channels` sparse format (preferred) - Very legacy `channelValues` with channelId objects - This ensures the system works even if AI returns old format ### 2. src/services/graphql-client-simple.ts **Updated commented-out QLC import mutation (lines 1842-1856)** - Changed `channelValues` to `channels { offset value }` in the GraphQL query - Note: This code is commented out but updated for consistency ### 3. src/generated/graphql.ts **No changes (intentional)** - This is an auto-generated file from the backend GraphQL schema - Contains `channelValues` type definitions (lines 517, 524) - Will be updated automatically when backend schema changes - Should NOT be manually edited ## Remaining References ### Intentional (Backward Compatibility) The following references remain in `src/services/ai-lighting.ts` for backward compatibility: - Line 424: `if (Array.isArray(fv.channelValues))` - Line 426: `fv.channelValues.forEach(...)` - Line 445: `else if (fv.channelValues && typeof fv.channelValues === "object")` - Line 449-451: `const legacyValues = Array.isArray(fv.channelValues) ? fv.channelValues : [];` These handle AI responses that might still use the old format. ### Auto-Generated (Do Not Edit) - `src/generated/graphql.ts` - Lines 517, 524 ## Verification ### Build Status ✅ TypeScript compilation successful ✅ ESLint passed with no errors ✅ All type checks passed ### Test Status ✅ All 470 tests passing - All test assertions updated to use sparse channel format ### Node.js Version Notes - CI uses Node 20 (standard test commands work) - Node.js 25+ requires `--localstorage-file` flag for localStorage security - Use `npm run test:node25` for local development on Node 25+ ## Migration Notes ### For AI Generation The AI service now prompts for the new sparse format by default, but gracefully handles responses in the old format through automatic conversion in `validateFixtureValues`. ### For GraphQL Client All GraphQL mutations and queries in `graphql-client-simple.ts` now use the `channels: { offset, value }[]` format exclusively (except for the auto-generated types file). ### For Backend Integration When the backend schema is fully updated to remove `channelValues` support: 1. Run `npm run generate` to regenerate `src/generated/graphql.ts` 2. The backward compatibility code in `ai-lighting.ts` can remain as a safety net 3. No other code changes should be needed ## Next Steps 1. ✅ Update AI prompts to use new format (DONE) 2. ✅ Update GraphQL queries to use new format (DONE) 3. ⏳ Wait for backend schema update 4. ⏳ Regenerate TypeScript types from backend schema 5. ⏳ Optional: Remove backward compatibility code after sufficient transition period

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bbernstein/lacylights-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server