Add files via upload
This commit is contained in:
12 files changed
+4682
No files matched your search
@@ -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.
|
||||
Reference in new issue
Block a user