oh-input: Fix parts of value appended as unit for complex formatted states#4122
oh-input: Fix parts of value appended as unit for complex formatted states#4122
Conversation
Agent-Logs-Url: https://github.com/openhab/openhab-webui/sessions/d09384d7-c688-4af4-9268-80aa8e27240f Co-authored-by: florian-h05 <73423173+florian-h05@users.noreply.github.com>
Agent-Logs-Url: https://github.com/openhab/openhab-webui/sessions/d09384d7-c688-4af4-9268-80aa8e27240f Co-authored-by: florian-h05 <73423173+florian-h05@users.noreply.github.com>
oh-input-card from appending pseudo-units for Number:Time display formats
448b727 to
4352c27
Compare
#5367 Bundle Size — 13.84MiB (~-0.01%).e41c88e(current) vs 6f9bab9 main#5359(baseline) Warning Bundle contains 2 duplicate packages – View duplicate packages Bundle metrics
|
| Current #5367 |
Baseline #5359 |
|
|---|---|---|
1.41MiB |
1.41MiB |
|
0B |
0B |
|
16.18% |
16.18% |
|
697 |
697 |
|
816 |
816 |
|
2818 |
2818 |
|
0 |
0 |
|
0% |
0% |
|
126 |
126 |
|
1 |
1 |
Bundle size by type
1 change
1 improvement
| Current #5367 |
Baseline #5359 |
|
|---|---|---|
11.53MiB (~-0.01%) |
11.53MiB |
|
902.12KiB |
902.12KiB |
|
638.41KiB |
638.41KiB |
|
526.1KiB |
526.1KiB |
|
295.6KiB |
295.6KiB |
|
847B |
847B |
Bundle analysis report Branch copilot/fix-api-400-oh-input-car... Project dashboard
Generated by RelativeCI Documentation Report issue
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
oh-input-card from appending pseudo-units for Number:Time display formats|
@jsjames Can you please review this PR? My approval doesn't "count" as I contributed to that PR and Copilot acted on my behalf. |
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
|
I am still not sure we solve all cases. I didn't test it, but look at the followign examples. This is a valid pattern: This is tricky, but in general text after the last pattern is allowed and would be shown verbatim. And you should assume the unit is always following the value. |
…t, not last token Agent-Logs-Url: https://github.com/openhab/openhab-webui/sessions/7cd78c01-d244-4e21-9102-94a2fed71b67 Co-authored-by: florian-h05 <73423173+florian-h05@users.noreply.github.com>
|
Better now @mherwege? |
Yes. LGTM now. I think there still is one case where it would fail: if there is no unit in the pattern, but some text behind the value. But the only way to avoid that would be to check if the position after the value is |
|
I added one additional test case / fix and had copilot suggest the fix. Also, I had to modify vitest in order to run due to localStorage.getItem. Did this work correctly for you without that? |
84a8b0f to
291fff9
Compare
There was a problem hiding this comment.
I didn't need that and also wonder why this should be needed.
There was a problem hiding this comment.
CI also didn't need it.
There was a problem hiding this comment.
this is the error I get without that code:
(node:98844) Warning: `--localstorage-file` was provided without a valid path
(Use `node --trace-warnings ...` to show where the warning was created)
❯ src/components/widgets/system/oh-input.test.ts (0 test)
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL src/components/widgets/system/oh-input.test.ts [ src/components/widgets/system/oh-input.test.ts ]
TypeError: localStorage.getItem is not a function
❯ getTimelineLayersStateFromStorage node_modules/@vue/devtools-kit/dist/index.js:2272:30
❯ initStateFactory node_modules/@vue/devtools-kit/dist/index.js:2565:26
❯ node_modules/@vue/devtools-kit/dist/index.js:2569:68
❯ src/js/stores/useUserStore.ts:1:1
1| import { defineStore } from 'pinia'
| ^
2| import { ref } from 'vue'
There was a problem hiding this comment.
I was using node@25. Once I backed down to node@24, things work. I'll update.
| expect(value).toBe('20') | ||
| }) | ||
|
|
||
| it('does not strip a unit that only matches mid-string', () => { |
There was a problem hiding this comment.
I don't understand that test case.
How should s be extracted as a unit from 125 ms? In that case, ms should be extracted as unit.
There was a problem hiding this comment.
correct "ms" should be the right unit, but the current logic returns "m"
There was a problem hiding this comment.
Why does the current logic return s as unit when it’s ms?
Display state vs state?!
In that case the issue imo is in the unit extraction and not the value extraction.
There was a problem hiding this comment.
agree - i wasn't following the logic (and relied too much on copilot). I'll revert the change.
e232cc5 to
e41c88e
Compare
|
Please no force pushes!! |
Fixes #4027.