Gate all disconnect rules on PTW70 product line

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Michael-A-SloanandCursor committed 2026-05-05 15:31:40 -04:00
1 parent f350c5ba7d
commit cc8f3ecf5f
10 files changed
+31 -19

No files matched your search

+2 -2
View File
@@ -7,7 +7,7 @@ Short reference so an AI or new dev can understand and modify this project witho
- **Electron** desktop app (Windows). One window; no browser opened.
- Connects to **localhost:1947** sessions/config pages in a **hidden webview**.
- **On startup:** Loads config page → ensures “Table Rows per Page” = 100 → submits if changed → loads sessions page.
- **When Monitor ON:** Every 60s reloads sessions page; scans table rows; **clicks Disconnect** on rows whose text contains any of the **target keywords**.
- **When Monitor ON:** Every 60s reloads sessions page; scans table rows; **clicks Disconnect** when **Product** contains **PTW70** and **Feature** matches **TARGET_KEYWORDS** (substring) or modules **19**/**9** (exact).
- **UI:** Left = “Logged in” (by user); Right = “Activity log”; bottom = Monitor ON/OFF + Clear. Uses **powerSaveBlocker** so Windows/display don’t sleep while the app runs.
## Tech stack
@@ -30,7 +30,7 @@ Short reference so an AI or new dev can understand and modify this project witho
## Important conventions
- **Keywords:** Edit **inject.js** only — array `TARGET_KEYWORDS`. Row is disconnected if `row.innerText` contains any keyword.
- **Keywords:** Edit **inject.js** — `TARGET_KEYWORDS` (Feature substring) and `TARGET_FEATURE_IDS`. Disconnect only if Product contains `PTW70` and Feature matches (see `matchesPtw70FeatureKeyword` / `matchesFeatureId`).
- **Config check:** In **renderer.js**, `ensureConfigThenSessions()` runs on config.html load; sets `#linesperpage` to 100 and clicks Submit if needed, then navigates webview to sessions.
- **URLs:** Config = `http://localhost:1947/_int_/config.html`, Sessions = `http://localhost:1947/_int_/sessions.html`. Defined in renderer.js.
- **Log/sessions bridge:** Inject script pushes to `__ptw_logQueue` and exposes `__ptw_flushLogs()` / `__ptw_getSessions()`. Renderer polls via `webview.executeJavaScript()` and updates DOM.
+3 -3
View File
@@ -4,7 +4,7 @@ Standalone desktop app that monitors your PTW sessions page and automatically di
## Features
- **Auto-disconnect** — When Monitor is ON, scans the sessions table and clicks Disconnect on rows containing any of the target keywords.
- **Auto-disconnect** — When Monitor is ON, scans the sessions table and clicks Disconnect on **PTW70** product rows whose **Feature** matches the configured list (or modules 19 / 9).
- **Logged in** — Left panel shows who is logged in, grouped by user, with product/feature per session.
- **Activity log** — Right panel shows timestamps and disconnect/refresh events.
- **Config on startup** — On launch, checks `http://localhost:1947/_int_/config.html` and ensures **Table Rows per Page** is set to **100** (and submits if changed).
@@ -13,7 +13,7 @@ Standalone desktop app that monitors your PTW sessions page and automatically di
## Target keywords (disconnect when present)
Matching uses the **Feature** column only (not the whole row). Product text such as `1 PTW70` is not searched for keywords.
Applies only when **Product** contains **`PTW70`** (e.g. `1 PTW70`). Matching uses the **Feature** column only (substring for the list below; exact cell for modules 19 and 9).
- PTW_DATAEXCHANGE
- PTW_ARC_FLASH
@@ -25,7 +25,7 @@ Matching uses the **Feature** column only (not the whole row). Product text such
- PTW_IEC_FAULT
- PTW_IEC61363
**Modules 19 and 9:** Disconnect when **Product** contains `PTW70` (e.g. `1 PTW70`) and **Feature** equals exactly `19` or `9`.
**Modules 19 and 9:** Same **PTW70** product line; **Feature** equals exactly `19` or `9`.
## Requirements
+8 -2
View File
@@ -7,7 +7,7 @@
'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363'
];
/** Exact match on Feature cell only; Product must look like PTW70 (e.g. "1 PTW70") so "9"/"19" do not fire on other lines. */
/** Exact Feature cell match; only evaluated when Product contains PTW70 (same product gate as PTW_* keywords). */
const TARGET_FEATURE_IDS = ['19', '9'];
window.__ptw_logQueue = window.__ptw_logQueue || [];
@@ -54,6 +54,12 @@
return TARGET_KEYWORDS.some(function (k) { return feature.indexOf(k) !== -1; });
}
/** PTW_* strings must appear in Feature; Product must contain PTW70 (e.g. "1 PTW70") for any auto-disconnect. */
function matchesPtw70FeatureKeyword(product, feature) {
if (!isPtw70Product(product)) return false;
return matchesKeywordInFeature(feature);
}
function matchesFeatureId(product, feature) {
if (!isPtw70Product(product)) return false;
return TARGET_FEATURE_IDS.some(function (id) { return feature === id; });
@@ -64,7 +70,7 @@
const rows = document.querySelectorAll('#mydata table.list tr');
rows.forEach(function (row) {
var pf = productFeatureCells(row);
const keywordMatch = matchesKeywordInFeature(pf.feature);
const keywordMatch = matchesPtw70FeatureKeyword(pf.product, pf.feature);
const idMatch = matchesFeatureId(pf.product, pf.feature);
if (keywordMatch || idMatch) {
const disconnectLink = row.querySelector('a.sbutton');