Update disconnect keywords and rebuild distributables.

Add 19 and 9 to auto-disconnect targets and regenerate packaged outputs so the built app reflects the new disconnect criteria.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Michael-A-SloanandCursor committed 2026-05-05 11:25:30 -04:00
1 parent 048ab8b980
commit 6274341ef5
11 files changed
+141 -24

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
# AI DNA — Project overview for AI and maintainers
Short reference so an AI or new dev can understand and modify this project without guessing.
## What this app is
- **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**.
- **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
- **Runtime:** Node.js + Electron (main process + one renderer, no Node in renderer).
- **Front-end:** Vanilla JS + one HTML file + inline CSS. No React/Vue/framework.
- **Build:** electron-builder (NSIS installer + portable exe + win-unpacked). `asar: false`. Optional `afterPack.js` for ffmpeg placement.
## Key files (don’t guess — use these)
| File | Role |
|------|------|
| **main.js** | Electron main: create window, load index.html, enable webview, powerSaveBlocker. |
| **index.html** | Single UI: webview (hidden), two panels (Logged in left, Activity log right), buttons, status. |
| **renderer.js** | Renderer logic: load config first then sessions, inject scripts, poll for logs/sessions, toggle Monitor, 60s reload. |
| **inject.js** | Injected into the **sessions** page (webview). Defines `__ptw_getSessions()`, `__ptw_flushLogs()`, `__ptw_setRunning()`, and the **TARGET_KEYWORDS** + scan/Disconnect logic. Not used on config page. |
| **preload.js** | Minimal; no Node exposed to renderer. |
| **afterPack.js** | Copies ffmpeg.dll to app root if needed for portable build. |
| **package.json** | Scripts: `start`, `dist`, `dist:portable`. Build: win targets, extraFiles for ffmpeg, afterPack. |
## Important conventions
- **Keywords:** Edit **inject.js** only — array `TARGET_KEYWORDS`. Row is disconnected if `row.innerText` contains any keyword.
- **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.
- **Persistence:** Monitor ON/OFF and activity log entries in renderer **localStorage** (keys in renderer.js). No backend.
## Adding a new disconnect keyword
1. Open **inject.js**.
2. Add the string to the **TARGET_KEYWORDS** array.
3. Save; rebuild if distributing exe (`npm run dist`).
## Changing config or startup flow
- Config URL / field / submit: **renderer.js** (`ensureConfigThenSessions` and the injected script string).
- Sessions URL: **renderer.js** (`SESSION_URL`) and **index.html** (webview initial `src` is config; renderer switches to sessions after config check).
## Build and run
- **Run:** `npm install` then `npm start` (or **Start PTW Auto-Disconnect.vbs**).
- **Build:** `npm run dist` → installer + portable exe + win-unpacked. Optional: `npm run dist:portable` to also create the zip.
Keep this file updated when you change architecture, key file roles, or conventions so the “AI DNA” stays accurate.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 PTW Auto-Disconnect contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+54 -14
View File
@@ -1,38 +1,78 @@
# PTW Auto-Disconnect (Standalone GUI)
# PTW Auto-Disconnect
Runs your PTW monitor in a small desktop window **without opening Chrome**. It stays connected to `http://localhost:1947/_int_/sessions.html`, scans for the same keywords, and clicks Disconnect on matching rows. Logs and Monitor ON/OFF state are kept in the GUI.
Standalone desktop app that monitors your PTW sessions page and automatically disconnects sessions matching certain product/feature keywords. Runs in a small window **without opening Chrome**.
## Features
- **Auto-disconnect** — When Monitor is ON, scans the sessions table and clicks Disconnect on rows containing any of the target keywords.
- **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).
- **Stay awake** — While the app is running, prevents Windows from sleeping and the display from turning off.
- **One-click run** — Double-click **Start PTW Auto-Disconnect.vbs** (or the built exe) to run without opening a terminal.
## Target keywords (disconnect when present)
- PTW_DATAEXCHANGE
- PTW_ARC_FLASH
- PTW_DEVEVAL
- PTW_AFAULT
- PTW_DAPPER
- PTW_COOREVAL
- PTW_CAPTOR
- PTW_IEC_FAULT
- PTW_IEC61363
- 19
- 9
## Requirements
- Node.js (LTS recommended)
- The sessions page must be available at `http://localhost:1947/_int_/sessions.html` (start your server first)
- **To run from source:** Node.js (LTS) and `npm install`.
- **Sessions server:** The app expects the sessions page at `http://localhost:1947/_int_/sessions.html` (and config at `http://localhost:1947/_int_/config.html`). Start your server first.
## Run
## Run from source
```bash
npm install
npm start
```
## Build an executable (optional)
Or double-click **Start PTW Auto-Disconnect.vbs** (no terminal window).
## Build executables
```bash
npm run dist
```
- **`dist\PTW Auto-Disconnect Setup 2.1.0.exe`** — Installer (Start Menu, etc.).
- **`dist\win-unpacked\`** — No-install: run **PTW Auto-Disconnect.exe** from this folder (all DLLs stay next to the exe; avoids ffmpeg.dll errors).
Output in **`dist`**:
To build and also create a single zip for the no-install version:
| Output | Description |
|--------|-------------|
| **PTW Auto-Disconnect Setup 2.1.0.exe** | Windows installer |
| **PTW Auto-Disconnect 2.1.0.exe** | Portable single exe (no install) |
| **win-unpacked/** | No-install folder; run **PTW Auto-Disconnect.exe** from inside (avoids ffmpeg path issues on some systems) |
Optional: build and create a zip of the no-install folder:
```bash
npm run dist:portable
```
Then use **`dist\PTW Auto-Disconnect-no-install.zip`**: unzip anywhere and run **PTW Auto-Disconnect.exe** from the extracted folder.
Then use **`dist\PTW Auto-Disconnect-no-install.zip`** — unzip anywhere and run the exe from the extracted folder.
## Behavior
## Running on a new PC
- **Monitor ON/OFF** — Same as your script; when ON, the page is monitored and reloaded every 60 seconds.
- **Clear** — Clears the log display (state is still persisted until you clear).
- The page is loaded in a hidden webview inside the app; only the compact log + buttons window is visible.
- **From source:** Install Node.js, copy the project, run `npm install`, then `npm start` or the VBS launcher.
- **Built exe/installer:** Copy the installer or the **win-unpacked** folder (or the portable exe). No Node.js required.
## Behavior summary
- **Monitor ON/OFF** — Toggle monitoring; when ON, the sessions page is reloaded every 60 seconds and matching rows are disconnected.
- **Clear** — Clears the activity log display (persisted logs are cleared).
- **Config check** — On startup the app loads the config page, sets rows per page to 100 if needed, submits, then opens the sessions page. The activity log shows: *Config: rows per page already 100* or *Config: rows per page set to 100* (or a message if the input was not found).
- The sessions page is loaded in a hidden webview; only the compact GUI (panels + buttons) is visible.
## License
See [LICENSE](LICENSE).
+2 -1
View File
@@ -4,7 +4,8 @@
const TARGET_KEYWORDS = [
'PTW_DATAEXCHANGE', 'PTW_ARC_FLASH', 'PTW_DEVEVAL', 'PTW_AFAULT',
'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363'
'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363',
'19', '9'
];
window.__ptw_logQueue = window.__ptw_logQueue || [];