Skip to content

[Work Order] OptiSensor Info, editable groups, and overlay preview - #106

Merged
onehoon merged 4 commits into
mainfrom
work-order/optisensor-info-card-layout
Nov 22, 2026
Merged

onehoon merged 4 commits into
mainfrom
work-order/optisensor-info-card-layout

Conversation

@onehoon

@onehoon onehoon commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Work Order — OptiSensor Info, editable sensor groups, and plugin-local overlay preview

Implementation approved — requirements finalized. Implement the scope below on this work-order branch. The PR intentionally remains Draft until implementation and review. Do not merge the empty-commit work order.

Context

Base: main. The current Windows-only OptiScaler plugin is the single-ASI LibreHardwareMonitor HTTP bridge. In src/OptiSensor.Plugin/OptiSensor.cpp, DrawTab(void*) currently renders a Plugin update section (status, separate build line) and may display a separate LibreHardwareMonitor web server unavailable message before the hardware sensor groups. The Libre bridge snapshot in LibreBridge.h exposes hasValidSnapshot and unavailable; after three failed poll attempts the bridge marks the latest snapshot unavailable.

Implementation structure — separate responsibilities from the outset

Include the responsibility split in this implementation PR, not in a later cleanup/refactor PR. The current src/OptiSensor.Plugin/OptiSensor.cpp (~670 lines on main) mixes update-check HTTP and release parsing, registration/startup, the existing sensor polling worker, and UI rendering. The requested group editing, per-sensor order settings, default picks and text composition should not be added to this large file.

A lightweight, concrete source split is recommended; adjust filenames if the resulting responsibility boundaries remain clear:

Module Owned responsibility
OptiSensor.cpp OptiPluginInit, runtime lifetime, SDK compatibility gate, one sensor polling worker, and ownership of the current immutable sensor snapshot / update state. Keep it an entrypoint/coordinator rather than a UI or settings implementation.
LibreBridge.cpp/.h Existing local Libre HTTP/JSON parsing, hardware and stable sensor identity, 3-failure N/A policy. Preserve existing behavior and tests; do not move UI/group-selection code into the bridge.
UpdateChecker.cpp/.h Move existing GitHub release/Build-Run-ID lookup and update status comparison out of OptiSensor.cpp; preserve the current one-time, non-blocking check and no-error-on-network-failure behavior. No new update worker.
PluginTab.cpp/.h All four SDK sections (OptiSensor Info, Overlay Preview, Selected Sensors, Hardware Sensors), InputText, Combo, Button, SameLine, status colors, and the existing Save button. SDK/UI calls only on the draw callback.
OverlayLayout.cpp/.h Small pure/testable selection/group/ordering and final text composition logic: seeded CPU/GPU/VRAM/RAM groups, curated sensor matching, stable group identities, deterministic ordering, space/pipe separators, VRAM used/total and physical RAM used/(used+available) formatting. No WinHTTP, no ImGui, no plugin registration or background worker.

Single authority and minimal plumbing: Continue using one Libre snapshot and one [Plugin.OptiSensor] settings namespace through the existing OptiScaler SDK. The tab owns any transient text-entry buffer; persist only the group names/IDs, assignment, order and selection values required by the work order. Reuse the existing RegisterTab draw callback's userData (or one similarly simple stable context) to pass the existing runtime/API data across compilation units; avoid duplicated mutable global snapshots, a separate selection owner, another worker, wrapper/interface hierarchies, generic managers, background services, custom serialization files or extra synchronization purely for theoretical races. A small number of direct functions/structs is sufficient; do not introduce indirection solely to achieve the suggested filenames.

Build/tests in this PR: Update OptiSensor.Plugin.vcxproj to compile the new translation units (and the current native test project for pure composition tests). Keep the single OptiSensor-loadlate.asi output and current CI/release packaging unchanged. Add focused native tests for curated default selection, stable group names/order, membership changes, the exact CPU | GPU | VRAM | RAM preview (including automatic | separators), the VRAM and physical-RAM pair calculations, missing inputs, and persistence-related order normalization. Continue running current Libre parser and full plugin build tests. Avoid unnecessary tests for unsupported multi-session or pathological scheduling interleavings.

Review success is not just "the UI works": the implementation PR should demonstrate these responsibility boundaries without behavior drift in current sensor collection, update checking, saved checkbox keys or release output.

Requested change — OptiSensor Info

Replace the top section title Plugin update with OptiSensor Info. Keep the card compact:

Connected / current build

OptiSensor Info
Build: 45017262188 (6c099987) — Up to date
Libre HW Monitor: OK

Update available

OptiSensor Info
Build: 45017262188 (6c099987) — Update Available
Libre HW Monitor: OK

Libre web server unavailable

OptiSensor Info
Build: 45017262188 (6c099987) — Up to date
Libre HW Monitor: Not connected
Install/run LibreHardwareMonitor + PawnIO. Enable Web Server (8085).

The build numbers above are illustrative only; display the actual existing kBuildRunId and 8-character kBuildSha as today.

Display and status rules

  1. Build row: Combine build identity and existing update status on one line instead of separate status and build lines. Continue showing Up to date only after a successful check, Update Available in amber for a newer rolling release, Checking for updates... while pending, and Local build when kBuildRunId == 0. If the GitHub request fails, silently omit the update status (leave the build identity visible); never claim Up to date for an unsuccessful check. Keep current release-check logic and build identity intact.
  2. Libre row: Show Libre HW Monitor: OK (green if the SDK supports colored text) when the most recent published bridge snapshot is valid and !unavailable. Show Libre HW Monitor: Not connected with red Not connected text using the SDK's TextColored when available (fall back to plain text only if the running OptiScaler SDK does not expose it), when the bridge has no usable snapshot or marks it unavailable. Prefer a readable, clearly red color rather than amber. Existing retention policy (up to two failed polls keep the previous valid values, third failed poll -> N/A) must remain authoritative: do not introduce a second polling, connection probe, or independent status counter. Optionally use Connecting... before the first response if this avoids a transient false alarm.
  3. Short missing-dependency guidance: Only under Not connected, show one short, muted line: Install/run LibreHardwareMonitor + PawnIO. Enable Web Server (8085). This is user guidance, not an ASI action: PawnIO is needed for certain low-level sensor readings but is not itself required to connect to the HTTP API. Do not install, launch, elevate, or manage Libre/PawnIO in the ASI.
  4. Remove any duplicated LibreHardwareMonitor web server unavailable message from the lower portion of the tab; the top info section is the sole connection-status explanation. Keep the existing Hardware sensors section, groups, sensor selection checkboxes, values, group state, Save button, and saved OptiScaler.ini keys/behavior unchanged.
  5. Use only the existing OptiScaler plugin UI SDK (Section, Text, SameLine, optional TextColored/TextDisabled) in the draw callback. Keep it quick; no new dependencies, direct ImGui calls, network I/O, extra threads, extra state machines, or changes to the backend, endpoint, sample intervals, CI, packaging, or release flows. Preserve Windows-only/Wine guard.

Additional requirement — Selected overlay sensors (plugin-only preparation)

The former Windows OptiSensor desktop app is the behavioral reference. Its source is still in this repository:

  • src/OptiSensor/UI/Views/Pages/SensorsPage.xaml: detected sensors are explicitly selected for overlay use.
  • src/OptiSensor/UI/Views/Pages/OverlayPage.xaml and src/OptiSensor/UI/MainWindowViewModel.cs: a separate Overlay Preview plus selected sensors, with group membership, enabled status, user-facing display name, format and ordering.
  • src/OptiSensor/Overlay/OverlayLineBuilder.cs, OverlayOutputComposer.cs, Models/OverlayGroup.cs and Models/SelectedOverlaySensor.cs: selected/enabled sensors are composed into one plain-text line, values separated by spaces within named groups and groups separated by |. E.g. GPU 44°C 115W 62% | CPU 71°C 38%. The same composition is used for the desktop app's UI preview and publisher.

Scope boundary: no overlay integration at this stage. Build/preview the text inside the ASI plugin only. Do not write shared memory, call into a new OptiScaler API, modify OptiScaler itself, invent a communication protocol, or deliver any text to the overlay. Do not copy or link the Windows app/.NET classes into the ASI.

Plugin tab section order

The tab has four OptiScaler SDK sections: the info card, the final text preview, the reorderable/group-editable selection, and the full sensor catalog. Group creation and editing happen entirely in the in-game OptiScaler plugin tab; the user should never need to edit INI manually.

OptiSensor Info
  Build: <actual build ID> (<SHA>) — Up to date / Update Available
  Libre HW Monitor: OK / Not connected

Overlay Preview
  CPU 55°C 8% 34W | GPU 38°C 23% 15W 0RPM | VRAM 6666MB/12000MB | RAM 12.4GB/32GB
  [Read-only, plugin-local composed text only]

Selected Sensors
  New group: [Group name input] [Add Group]

  Group: [CPU                  ]   (editable display name)
    Core (Tctl/Tdie)          55°C  [Up] [Down] [Group: CPU]
    CPU Total                   8%  [Up] [Down] [Group: CPU]
    Package Power              34W  [Up] [Down] [Group: CPU]

  Group: [GPU                  ]   (editable display name)
    GPU Core Temperature       38°C  [Up] [Down] [Group: GPU]
    GPU Core Load              23%  [Up] [Down] [Group: GPU]
    GPU Package Power          15W  [Up] [Down] [Group: GPU]
    GPU Fan 1                  0RPM  [Up] [Down] [Group: GPU]

  Group: [VRAM                 ]   (editable display name)
    GPU Memory Used          6666MB [Up] [Down] [Group: VRAM]
    GPU Memory Total        12000MB [Up] [Down] [Group: VRAM]

  Group: [RAM                  ]   (editable display name)
    Memory Used             12.4GB  [Up] [Down] [Group: RAM]
    Memory Available        19.6GB  [Up] [Down] [Group: RAM]

  [Additional user-created groups, if any]

Hardware Sensors
  [full hardware groups, all sensor checkboxes and current values]
  Save

Sample readings above are illustrative. Use the actual values reported by Libre. The compact GPU/VRAM preview is inspired by the original Windows OptiSensor overlay editor and line builder; only the plugin-local preview is being prepared here.

Default groups and first-use selections

  1. Seed exactly four editable groups on fresh settings: CPU, GPU, VRAM, and RAM in that order. Their stable internal IDs must not change when the user edits their visible names.
  2. On a fresh/unset SensorVisible_<SHA256> setting, preselect only these detected sensors and assign them to the stated groups:
    • CPU: one representative CPU Temperature (prefer Core (Tctl/Tdie) where present), one CPU Total / overall CPU Load, and one CPU package Power, default order temperature → load → power.
    • GPU: one GPU core Temperature, one GPU core Load, one GPU package/total Power, and one GPU Fan (prefer GPU Fan 1), default order temperature → load → power → fan. GPU fan belongs to GPU, never a separate FAN group.
    • VRAM: the same chosen GPU's GPU Memory Used and GPU Memory Total (Libre sensor type SmallData), default order Used → Total. These are two underlying selected sensors, not a fictitious third-party sensor or a constant. LibreHardwareMonitor 0.9.6 has these named GPU readings for supported adapters. Do not confuse GPU Memory percentage load, GPU Memory Free, D3D Shared Memory, and D3D Dedicated Memory Used with the intended GPU Memory Used/Total pair.
    • RAM (physical only): from Libre Total Memory with hardware root /ram, select Memory Used and Memory Available (both type Data) in that order. Compute the total as Used + Available. Libre does not expose a Memory Total sensor for the Total Memory root. Do not choose Virtual Memory (root /vram, Windows pagefile/virtual memory), any DIMM root, or an individual DIMM temperature. The two physical RAM source readings stay individually selectable.
  3. Only one deterministic candidate per metric; on multiple GPUs, select one GPU consistently and take its temp/load/power/fan/VRAM readings from the same hardware ID. For RAM, use the single physical Total Memory (/ram) root. Omit absent metrics rather than selecting unrelated data. When memory inputs are unavailable, do not invent a total. No CPU/GPU/VRAM/RAM sensor is selected merely because it belongs to a group.
  4. Preserve the existing per-sensor SensorVisible_<SHA256> keys for all explicit saved true/false values. Use GetBool(plugin, key, isFirstUseRecommended) rather than the existing default-true select-all. A saved false must never be re-enabled automatically; a user may uncheck all selections and get an empty preview. This is only an initial default, not a fallback output line.
  5. System/motherboard fans, storage, network, Virtual Memory (/vram), individual DIMMs, other GPUs, etc. default unchecked but remain available in Hardware Sensors for manual selection and grouping.

Overlay Preview — final composed string

  1. Display only one final string, assembled from the currently selected readings, grouped and ordered exactly as displayed in the Selected Sensors editor. Changes to selected checkboxes, group membership, editable group names, and sensor order update the preview on the next draw without any network call.
  2. Normal groups use the group's editable display name, then the current sensor values joined by spaces. Automatically insert exactly | (space, pipe, space) between each nonempty group in its configured order; do not require users to type separators into group names and never append a leading/trailing pipe or a double separator when a group has no selected/available readings. The live preview should look like CPU 55°C 8% 34W | GPU 38°C 23% 15W 0RPM | VRAM 4444MB/23333MB | RAM 12.4GB/32GB (illustrative readings, not constants). Omit empty groups from the preview; with no selected readings display No sensors selected.
  3. VRAM display: when both specifically named GPU Memory Used and GPU Memory Total for the chosen GPU are selected in the default VRAM group, render their live values as a compact usedMB/totalMB pair (e.g. 6666MB/12000MB). Source values normally arrive as Libre-formatted strings (e.g. 6666.0 MB and 12000.0 MB). Apply only minimal, explicit MB formatting/space removal/rounding needed for this composed pair; never append duplicate units or blindly parse arbitrary RawValue as a float. If either is missing/unavailable, represent the missing half as N/A or fall back to displaying only the valid source reading; do not fake a total or use a memory-load percentage. For any other sensors in the VRAM group, retain ordinary space-separated formatting. The virtual pair formatting must not remove the underlying individual readings/checkboxes, which stay separately selectable and reorderable.
  4. Physical RAM format: in the default RAM group, when Memory Used and Memory Available (both from /ram) are selected, render usedGB/(usedGB + availableGB), e.g. RAM 12.4GB/32GB from 12.4 GB used and 19.6 GB available. Parse only those specific Libre-formatted GB values with minimal unit-aware logic; never confuse Windows Virtual Memory /vram with either physical RAM or GPU VRAM. If either input is missing or N/A, do not manufacture the total; show valid values or N/A. Group renames must not affect this behavior.
  5. A named group is an output grouping, not synonymous with a specific hardware node. If the user renames VRAM, the pairing behavior should use its stable internal group ID and specific sensor identities, not compare the mutable displayed name. If the user changes membership/order, reflect that choice rather than silently forcing an obsolete order.
  6. Output is plugin-local only: no shared memory, external app, new OptiScaler API, render overlay injection, or provider communication is part of this PR. Keep the same pure text composing logic available for future integration, without building a publisher now.

Selected Sensors — editable groups and order

  1. Add a compact New group text input with an adjacent Add Group button at the top of Selected Sensors, using the existing plugin SDK InputText and Button. A nonempty trimmed name creates a group at the end of the existing group order. Ignore empty names; avoid duplicate stable IDs. Display a text input for each existing group name so the user can rename CPU, GPU, VRAM or a custom group directly in-game, without manually opening the INI. A rename must immediately update the preview and must not reset a group's membership, sensor order or saved selection.
  2. Every selected sensor appears once in its assigned output group. Each group contains vertically stacked rows, each with readable sensor name/current formatted value and Up/Down buttons to its right. Buttons move that sensor exactly one place within its current group; first Up / last Down are disabled or inert. Use unique ## button IDs keyed by stable sensor identity.
  3. For newly added custom groups to be useful, allow moving a selected sensor between existing groups using a simple SDK Combo on its row (CPU/GPU/VRAM/RAM/custom group options). This moves the selected sensor to the end of the target group. Group membership updates the preview immediately. No drag-and-drop, separate group editing screen, arbitrary user-entered sensor type or new state authority.
  4. Checkboxes in the bottom Hardware Sensors list remain the single selection authority (SensorVisible_<SHA256> via OptiScaler settings). Checking an additional sensor inserts it in the corresponding built-in default group when clearly classifiable (CPU→CPU; GPU non-VRAM incl. GPU fan→GPU; GPU Memory Used/Total→VRAM; physical /ram Memory Used/Available→RAM); otherwise place it in a simple Ungrouped staging area only when needed and let the user assign it to any group via the dropdown. Unchecking removes it from the list/preview. The full Hardware Sensors list remains intact, including SSD and network.
  5. Keep independent group name, group membership, and per-group sensor order in the existing [Plugin.OptiSensor] settings via SDK GetString/SetString and GetInt/SetInt (e.g. group count/index→stable group ID/name, and SensorGroup_<same hash> + SensorOrder_<same hash>). Internal IDs stay stable across group name changes, polls and restarts. Existing checkbox/group expansion keys must not be renamed. Save via the existing Save button and standard OptiScaler INI save; do not add a second config file or settings manager. A newly selected sensor appends to its group if it has no stored order; avoid repeatedly reordering on value refresh.
  6. Group order is fixed at creation order for this PR: seeded CPU→GPU→VRAM→RAM followed by user-added groups. Up/Down changes sensor order within a group, not group order. Group removal, free-form group ordering, custom per-sensor format/aliases, and format editors are not in scope unless added in a later requirement.
  7. Libre unavailable: keep the existing two-miss retention and third-miss N/A policy; retain the persisted selection, group assignments/names and ordering. Top Info is the only place to show the Libre connection error/hint. Reuse the existing worker, snapshot and SDK draw callback. No new JSON polling, network listener, manager, additional threads or direct ImGui code.

Verification of groups and preview

  • Fresh settings with the required hardware produce exactly four groups in order: CPU (3 recommended readings), GPU (4 recommended readings including the GPU fan), VRAM (2 recommended readings), RAM (2 recommended physical Total Memory readings). The preview is assembled from those readings, not hard-coded constants. No unrelated SSD/network/system fan is auto-selected.
  • Given source values GPU Memory Used=6666.0 MB and GPU Memory Total=12000.0 MB, the default VRAM preview is VRAM 6666MB/12000MB. Given /ram Memory Used=12.4 GB and Memory Available=19.6 GB, the RAM preview is RAM 12.4GB/32GB; no Virtual Memory is selected. If needed values are missing, no fictitious numeric total is produced.
  • Input HOTSPOT and Add Group: a fifth (initially empty) user group appears, can be renamed, and a selected existing sensor can be reassigned to it with Combo. The preview respects the group name and membership. Save/restart restores added group, edited names, assignments and row order.
  • Sensor Up/Down in CPU/GPU/VRAM/RAM/custom groups updates the preview exactly once per click and persists. Two readings sharing Libre SensorId must remain independent using their stable unique setting keys. Group rename does not change IDs or selection keys.
  • Hardware Sensors toggle updates both Selected Sensors and the Overlay Preview. Verify automatically inserted | separators between CPU/GPU/VRAM/RAM and custom groups, with no leading/trailing/doubled separator after an empty group or group reassignment. Group/UI edits never cause polling or affect the standalone Windows OptiSensor app. Reconnection restores current values without losing selections/group order.

Acceptance checks

  • In game with Libre web server returning valid sensor data: exactly one OptiSensor Info card containing the build/status row and Libre HW Monitor: OK; existing sensors remain functional.
  • With Libre not running or web server disabled: Not connected plus the single short setup hint; no duplicate warning below; no crash or blocking. On reconnection, recover to OK using the existing worker.
  • Verify Up to date, amber Update Available, local build, checking and silent network-error presentations without changing the update detection semantics.
  • Keep the existing hardware sensor discovery area and Save behavior intact (except curated defaults and persisted per-sensor ordering); release x64 ASI still compiles and current plugin CI passes.

PR format: The original empty commit carries the English work order in this PR body; no separate work-order document should be added. The implementation may now be committed to this branch. Keep the PR Draft until the code and checks are ready for review.

@onehoon onehoon changed the title [Work Order] OptiSensor Info card layout (draft) [Work Order] OptiSensor plugin Info, Preview, and selected sensor ordering (draft) Nov 22, 2026
@onehoon onehoon changed the title [Work Order] OptiSensor plugin Info, Preview, and selected sensor ordering (draft) [Work Order] OptiSensor Info, editable groups, and overlay-text preview (draft) Nov 22, 2026
@onehoon onehoon changed the title [Work Order] OptiSensor Info, editable groups, and overlay-text preview (draft) [Work Order] OptiSensor Info, editable groups, and overlay preview Nov 22, 2026

@onehoon onehoon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Please address the two concrete default-selection defects in the inline comments before merging. The responsibility split is appropriate; no extra abstraction is requested.

Comment thread src/OptiSensor.Plugin/OverlayLayout.cpp Resolved
Comment thread src/OptiSensor.Plugin/OverlayLayout.cpp Resolved

@onehoon onehoon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed the updated implementation and confirmed that the prior Intel classification and hybrid-default-selection comments are addressed. Three remaining user-visible functional issues are noted inline, each with a concrete code example. Please address them before merge.

Comment thread src/OptiSensor.Plugin/OverlayLayout.cpp Resolved
Comment thread src/OptiSensor.Plugin/OverlayLayout.cpp Resolved
Comment thread src/OptiSensor.Plugin/OverlayLayout.cpp Resolved
@onehoon
onehoon marked this pull request as ready for review November 22, 2026 13:03
@onehoon
onehoon merged commit 9981ca4 into main Nov 22, 2026
2 checks passed
@onehoon
onehoon deleted the work-order/optisensor-info-card-layout branch November 22, 2026 13:04
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.

1 participant