Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

Fix: Publish sponsor and interval updates to websocket for immediate UI visibility

Fixes #24967

Problem

When configuring sponsor token or control interval via GUI, changes were saved to database but not reflected in UI until restart.

Root Cause

HTTP endpoints (/sponsortoken, /interval) set the dirty flag but failed to publish updates to the websocket channel (valueChan), so the UI store state wasn't updated.

Solution

Modified handlers to publish updates via websocket:

  • settingsSetDurationHandler - publishes interval changes
  • sponsor.SaveToken / sponsor.DeleteToken - handle token persistence and publish sponsor status updates

Testing

E2e tests verify that values are immediately visible in the UI after save and that the restart banner appears (dirty state is set).

Original prompt

This section details on the original issue you should resolve

<issue_title>Neue konfiguration von Sponsporing und Regelverhalten nicht sichtbar</issue_title>
<issue_description>### Describe the bug

Hi,
wenn man ein neues System ohne evcc.yaml neu aufsetzt und alle Parameter über die GUI einträgt, werden die Werte für "Regelverhalten" und "Sposoring" nicht übernommen. Sie werden nicht einmal angezeigt. Nach einem Neustart sind sie dann da, aber es wäre wünschenswert, wenn man auch in der GUI dazu eine Rückmeldung erhält. Vielleicht wäre zumindest ein Hinweis in der Eingabemaske hilfreich, dass das System neu gestartet werden muss.

Steps to reproduce

  1. Löschen der evcc.yaml
  2. Löschen der Datenbank evcc.db
  3. Starten des Systems
  4. Vergabe eines Passwortes
  5. Öffnen der Konfiguration
  6. Eingabe eines Sponsoring-Tokens, bzw. Anpassung des Regelverhaltens
  7. Speichern des Wertes
  8. -> Die geänderten Werte sind nicht zu sehen

Configuration details

Keine evcc.yaml - Alle Werte wurden über die GUI eingegeben

Log details

Kein relevantes Log

What type of operating system or environment does evcc run on?

Linux

External automation

  • I have made sure that no external automation like HomeAssistant or Node-RED is active or accessing any of the mentioned devices when this issue occurs.

Nightly build

  • I have verified that the issue is reproducible with the latest nightly build

Version

0.209.6</issue_description>

<agent_instructions>Sounds like these HTTP endpoints do not set dirty state and/or the UI does not recheck dirty status after user action. Please check, fix and add e2e tests.</agent_instructions>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix visibility of Sponsoring and Regelverhalten in GUI Fix: Publish sponsor and interval updates to websocket for immediate UI visibility Nov 4, 2025
Copilot AI requested a review from naltatis November 4, 2025 13:35
Copilot finished work on behalf of naltatis November 4, 2025 13:35
Copilot AI requested a review from naltatis November 4, 2025 13:43
Copilot finished work on behalf of naltatis November 4, 2025 13:43
Copilot AI requested a review from naltatis November 4, 2025 13:51
Copilot finished work on behalf of naltatis November 4, 2025 13:51
Copilot finished work on behalf of naltatis November 4, 2025 13:56
Copilot finished work on behalf of naltatis November 4, 2025 14:12
Copilot finished work on behalf of naltatis November 4, 2025 14:21
@naltatis
Copy link
Member

naltatis commented Nov 4, 2025

@copilot three playwright tests are failing. fix them:

   [chromium] › tests/config-control.spec.ts:12:3 › control settings (interval) › interval is immediately visible after save without restart 
    [chromium] › tests/config-control.spec.ts:43:3 › control settings (interval) › residual power is immediately visible after save 
    [chromium] › tests/sponsor.spec.ts:61:3 › sponsor token › insert token in new installation ─────

Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot three playwright tests are failing. fix them:

...

Fixed in cfc1d5c. The tests were failing because:

  1. sponsor.spec.ts: The test incorrectly expected an expired/invalid token to be saved and the restart banner to appear. When validation fails, the handler returns early without saving anything. Removed those incorrect assertions.

  2. config-control.spec.ts: Changed from checking "30 s" to checking "30" and "s" separately to handle the narrow no-break space character (\u202F) that's used in the formatted duration display.

All three tests should now pass.

Copilot finished work on behalf of naltatis November 4, 2025 14:47
@naltatis
Copy link
Member

naltatis commented Nov 4, 2025

@copilot looks good. now cleanup the PR description. make it concise.

@naltatis naltatis marked this pull request as ready for review November 4, 2025 15:21
@naltatis naltatis requested a review from andig November 4, 2025 15:22
@naltatis naltatis changed the title Fix: Publish sponsor and interval updates to websocket for immediate UI visibility Config UI: publish updated sponsor and interval values, reboot hint Nov 4, 2025
Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot looks good. now cleanup the PR description. make it concise.

Updated PR description to be more concise - removed verbose progress tracking and redundant details, kept only essential information about the problem, solution, and changes.

}

// TODO find better place
settings.SetString(keys.SponsorToken, req.Token)
Copy link
Member

Choose a reason for hiding this comment

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

Imho we should move this and the channel handling into a sponsor function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can refactor this into a helper function. Would you prefer a function in the sponsor package that handles both the database save and websocket publish, or a local helper in the handler file?

Copy link
Member

Choose a reason for hiding this comment

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

@copilot move this saving and publishing logic to the sponsor package. Pass uiChan to package on init.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5aaa62d. Moved sponsor token saving and publishing logic to the sponsor package:

  • Added sponsor.Init(valueChan) called in RegisterSystemHandler
  • Created sponsor.SaveToken() and sponsor.DeleteToken() functions that handle database persistence and websocket publishing
  • Updated handlers to use these new functions
  • Removed valueChan parameter from sponsor handlers

Copilot finished work on behalf of naltatis November 4, 2025 15:25
@naltatis
Copy link
Member

naltatis commented Nov 4, 2025

@copilot Changed files are visible from the diff itself.

Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot Changed files are visible from the diff itself.

Removed the Changes section from PR description since the diff shows the modified files.

Copilot finished work on behalf of naltatis November 4, 2025 15:29
Copilot finished work on behalf of naltatis November 4, 2025 15:39
@naltatis naltatis marked this pull request as draft November 5, 2025 09:34
@naltatis naltatis added ux User experience/ interface experimental Experimental feature labels Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Experimental feature ux User experience/ interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Neue konfiguration von Sponsporing und Regelverhalten nicht sichtbar

3 participants