Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Implementation Complete: Configurable Message Size Limit ✅

Summary

Successfully implemented a configurable byte limit setting for MQTT message payloads with predefined size options. Rebased with master and adopted the new EventsV2 structure with dependency injection.

All Tasks Complete

  • Replaced numeric input with dropdown selector
  • Added predefined size options: 20KB, 100KB, 1MB, 5MB, Unlimited
  • Unlimited option does not persist (resets to default on restart)
  • Backend handles unlimited correctly (no truncation)
  • Backend validation simplified: accepts any integer >= 20KB
  • Setting persists across restarts (except unlimited)
  • Changes apply to all new messages immediately
  • Code review feedback addressed
  • Rebased with master branch (commit 91df6de)
  • Adopted new EventBusInterface dependency injection pattern
  • Migrated to EventsV2 structure
  • Ready for merge

Changes Made

  1. events/EventsV2.ts: Added event and constants using new V2 structure

    • Added Events.setMaxMessageSize event following the simplified V2 pattern
    • Added message size constants (20KB, 100KB, 1MB, 5MB, Unlimited, Default)
  2. app/src/components/SettingsDrawer/Settings.tsx: Changed to dropdown with predefined options

    • Dropdown shows formatted sizes (e.g., "20 KB", "1 MB", "Unlimited")
    • Updated imports to use EventsV2
  3. app/src/actions/Settings.ts: Explicitly persist default when unlimited

    • When unlimited is selected, MAX_MESSAGE_SIZE_DEFAULT is saved to storage
    • On restart, unlimited resets to default (20KB)
    • Uses Events.setMaxMessageSize from EventsV2
  4. backend/src/index.ts: Simplified validation and handle unlimited

    • Adapted to new EventBusInterface dependency injection pattern
    • Uses this.backendEvents instead of global backendEvents
    • Subscribes to Events.setMaxMessageSize from EventsV2
    • When unlimited is selected, no message truncation occurs
    • Validation accepts any integer >= 20KB or unlimited (-1)
  5. app/src/reducers/Settings.ts: Updated imports to use EventsV2

Event Structure Migration

  • Old: export const setMaxMessageSize: Event<number> = { topic: 'settings/maxMessageSize' }
  • New: Events.setMaxMessageSize in EventsV2 following the simplified event pattern
  • All imports updated to use EventsV2 exports
  • Maintains backward compatibility through events/index.ts

How It Works

  • Default value: 20KB
  • Available options: 20KB, 100KB, 1MB, 5MB, Unlimited
  • Backend accepts any integer >= 20KB (not limited to dropdown values)
  • Unlimited does not persist - reverts to 20KB on restart
  • Setting applies to all new messages immediately after change
  • Fully compatible with latest master branch event system architecture
  • Uses new EventsV2 structure for type-safe, simplified event handling
Original prompt

This section details on the original issue you should resolve

<issue_title>Make 20.000 byte limit configurable</issue_title>
<issue_description>The app has a sidebar, add a config option to set a different limit then 20000 bytes.
Note that the limit is applied in the backend. Changes should be applied for all new messages after the setting has changed.
The setting should be persistent</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@thomasnordquist
Copy link
Owner

@copilot support siyes in 20kb, 100kb, 1mb, 5mb and unlimited. Unlimited should not be persisted.
The history per topic may be shorter if the object size is larger.

Copilot AI changed the title [WIP] Add configuration option for byte limit Add configurable max message size setting Dec 19, 2025
Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot support siyes in 20kb, 100kb, 1mb, 5mb and unlimited. Unlimited should not be persisted.
The history per topic may be shorter if the object size is larger.

Done in a3bca96. Changed from numeric input to dropdown with predefined size options:

Options available:

  • 20 KB (default)
  • 100 KB
  • 1 MB
  • 5 MB
  • Unlimited

Implementation details:

  • Unlimited (-1) is NOT persisted - resets to 20 KB on app restart
  • Dropdown shows formatted sizes (e.g., "20 KB", "1 MB", "Unlimited")
  • Backend skips truncation when unlimited is selected
  • All other sizes persist across restarts

The Settings sidebar now displays:

Max Message Size: [Dropdown ▼]

With dropdown options:

20 KB
100 KB
1 MB
5 MB
Unlimited

Copilot AI changed the title Add configurable max message size setting Add configurable max message size setting with predefined options Dec 19, 2025
Comment on lines 78 to 84
const validSizes = [
MAX_MESSAGE_SIZE_20KB,
MAX_MESSAGE_SIZE_100KB,
MAX_MESSAGE_SIZE_1MB,
MAX_MESSAGE_SIZE_5MB,
MAX_MESSAGE_SIZE_UNLIMITED,
]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot validation can be simplified, no exact values need to match, should be gte 20k and an integer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in de53571. Simplified validation to accept any integer >= 20KB or unlimited (-1), no exact value matching required.

@thomasnordquist
Copy link
Owner

@copilot rebase with the main branch, fix conflicts and adopt the new event structure to this PR

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot rebase with the main branch, fix conflicts and adopt the new event structure to this PR

Done. Rebased with master branch (commit 91df6de) and adapted to the new event structure:

Key changes from rebase:

  • Backend now uses EventBusInterface dependency injection
  • Changed from global backendEvents to this.backendEvents throughout ConnectionManager
  • All event subscriptions now use the injected event bus instance
  • Resolved conflicts in events/Events.ts and backend/src/index.ts
  • Maintained all functionality: dropdown selector, unlimited option, validation

The PR is now compatible with the latest master branch architecture.

@thomasnordquist
Copy link
Owner

@copilot resume

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot resume

Rebase completed successfully! The branch is now based on master (commit 91df6de) with all conflicts resolved:

Rebased commits (11 total):

  • Initial plan → Add configurable setting → Extract constants → Improve UX → Change to dropdown → Fix validations → Simplify validation → Set unlimited default

Key integrations:

  • Using EventBusInterface dependency injection in ConnectionManager
  • All backendEvents calls now use this.backendEvents
  • Resolved conflicts in events/Events.ts and backend/src/index.ts
  • Fixed duplicate maxMessageSize declaration

Branch is ready - all functionality preserved and compatible with latest master architecture.

@thomasnordquist
Copy link
Owner

@copilot ensure the new event matches new new event structure

Copy link
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot ensure the new event matches new new event structure

Done in f0533a2. Migrated to EventsV2 structure:

Changes:

  • Added Events.setMaxMessageSize to EventsV2.ts (following the new pattern)
  • Moved all message size constants to EventsV2.ts
  • Updated all imports to use EventsV2 exports:
    • app/src/actions/Settings.ts
    • app/src/components/SettingsDrawer/Settings.tsx
    • app/src/reducers/Settings.ts
    • backend/src/index.ts
  • Changed backendEvents.emit(setMaxMessageSizeEvent, ...) to backendEvents.emit(Events.setMaxMessageSize, ...)
  • Changed this.backendEvents.subscribe(setMaxMessageSizeEvent, ...) to this.backendEvents.subscribe(Events.setMaxMessageSize, ...)

The event now follows the simplified V2 pattern: Events.setMaxMessageSize instead of a standalone export.

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.

Make 20.000 byte limit configurable

2 participants