mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 01:16:15 -08:00
* docs(agents): compact root guidance and preserve task-specific knowledge * fix(agents): parse guidance navigation with Markdown tokens * fix(agents): validate generic literal repository paths * fix(agents): distinguish code symbols and shortcut images * fix(agents): recognize SCSS filename literals * fix(agents): handle fenced imports and encoded paths * fix(agents): parse prose and rendered HTML anchors * fix(agents): validate rendered HTML navigation * fix(agents): use GitHub-compatible heading slugs * fix(agents): require standalone top-level Claude import * fix(agents): exclude HTML-contained guidance imports * fix(agents): handle image fragments and quoted imports * fix(agents): validate visible HTML and image source sets * fix(agents): recognize package scopes and route source work * fix(agents): parse JSONC and constrain package exemptions * fix(agents): decode link entities and allow package subpaths * fix(agents): route source work and check extensionless files * fix(agents): support package versions and source fragments * fix(agents): accept qualified package prose * fix(agents): retain rendered context for Markdown references * fix(agents): validate visible headings and spaced paths * fix(agents): validate media and hyphenated literal paths * fix(agents): decode full HTML entities and media assets * fix(agents): recognize possessive package mentions * fix(agents): validate extensionless imports and version comparators * fix(agents): retain visible backticks and explicit path punctuation * fix(agents): validate image-map navigation targets * fix(agents): count all Markdown line endings in budgets * fix(agents): delimit package prose at Unicode punctuation * fix(agents): normalize punctuation for extensionless imports * fix(agents): preserve filenames across prose punctuation * fix(agents): validate iframe document references * fix(agents): inspect document suffix before URL fragments * fix(agents): unify Markdown suffix and encoded import guards * fix(agents): handle wildcard versions and alternate documents * fix(agents): validate document formats and trim HTML URLs * fix(agents): cover document families and guidance basenames * fix(agents): require files for media references * fix(agents): preserve block boundaries and validate embeds * fix(agents): normalize internal HTML URL whitespace * fix(agents): reject empty media and ignore URL at-signs * fix(agents): validate srcdoc references and empty srcset * fix(agents): honor HTML bases and preserve adjacent imports * fix(agents): convert base file URLs to native paths * fix(agents): preserve imports after bare URL punctuation * fix(agents): exclude opaque URI prose from import scans * fix(agents): keep import tokens outside URI scheme matches * fix(agents): restrict opaque URI exemptions to parsed links * fix(agents): handle opening prose delimiters * fix(agents): scan nested imports and share document suffixes * fix(agents): reject pathless media and direct file URLs * fix(agents): reject file bases and preserve quoted URL boundaries * fix(agents): distinguish URL quotes and cover guidance variants * fix(agents): validate SVG images and conventional guides * fix(agents): handle declared package names handles and SVG use * fix(agents): normalize closing punctuation on federated handles * fix(agents): normalize Unicode punctuation on handles * fix(agents): normalize possessive federated handles * fix(agents): separate parenthetical prose from handles * fix(agents): exclude www autolinks from import scanning * ci: allow manual CodeQL validation of PR branches * fix(agents): reject nonportable Windows drive links
80 lines
4.8 KiB
Markdown
80 lines
4.8 KiB
Markdown
# Electron debugging and tracing
|
|
|
|
Use this procedure for Electron/CDP tasks. Read the available `electron` skill
|
|
when automating the desktop app. These commands assume a bootstrapped worktree.
|
|
|
|
## Start and attach
|
|
|
|
- Start the Electron development app with: `pnpm nx serve electron-backend`
|
|
- Package-script equivalent: `pnpm run serve:backend`
|
|
- Electron is configured to start with: `--remote-debugging-port=9222`
|
|
- Connect Chrome DevTools Protocol tools to: `127.0.0.1:9222`
|
|
- For Electron automation/debugging tasks, use the `electron` skill
|
|
- Do not auto-open DevTools during normal CDP automation. In development, DevTools is opt-in via `ELECTRON_OPEN_DEVTOOLS=1`.
|
|
- If DevTools is open, `agent-browser --cdp 9222 ...` may attach to the DevTools page instead of the IPTVnator window. Symptoms: `tab list` shows `about:blank`, snapshots are empty, and screenshots are black.
|
|
- If that happens, inspect targets with `curl http://127.0.0.1:9222/json/list` and connect directly to the IPTVnator page websocket from the `webSocketDebuggerUrl` field.
|
|
- The app holds a single-instance lock (`acquireSingleInstanceLock` in `apps/electron-backend/src/app/services/single-instance.ts`): a second launch against the same `userData` quits immediately and focuses the running window. To attach a second CDP-enabled instance to the same profile, set `IPTVNATOR_ALLOW_MULTIPLE_INSTANCES=1` — knowing that only one of the two processes will own the renderer's IndexedDB, so settings written by the other are lost. Before focusing, the guard forwards the second launch's argv to `onSecondInstance`, which is how a playlist path handed to an already-running app reaches the open queue.
|
|
|
|
### Trace / Debug Startup
|
|
|
|
- Full startup tracing:
|
|
|
|
```bash
|
|
IPTVNATOR_TRACE_STARTUP=1 pnpm nx serve electron-backend
|
|
```
|
|
|
|
- Narrower trace flags:
|
|
- `IPTVNATOR_TRACE_IPC=1` traces renderer `window.electron.*` bridge calls
|
|
- `IPTVNATOR_TRACE_DB=1` traces DB worker requests and request-scoped DB events
|
|
- `IPTVNATOR_TRACE_SQL=1` traces SQLite statements in the main process and DB worker
|
|
- `IPTVNATOR_TRACE_WINDOW=1` traces BrowserWindow lifecycle and unresponsive events
|
|
- `IPTVNATOR_TRACE_PLAYER=1` traces external-player activity and bounded Embedded MPV runtime-probe stderr
|
|
- `IPTVNATOR_TRACE_RENDERER_CONSOLE=1` mirrors renderer console output into the Electron terminal
|
|
- `IPTVNATOR_PERF_CAPTURE=1` enables development/test-only, redacted M3U and Xtream preload IPC request/completion markers plus count-only M3U acquire/parse/normalize, Xtream main network/JSON-transform/success-response-ready/cancel-dispatch, and renderer store phase capture; renderer wrappers emit only while the benchmark installs its Symbol hook, benchmark tooling sets the flag explicitly, and production launches must leave it unset
|
|
- `IPTVNATOR_PERF_WORKER_PROFILING=1` enables development/test-only, request-scoped worker receive/work/response-post timestamps, thread CPU, event-loop utilization/delay, count-only playlist serialization/SQLite write/read/deserialization plus Xtream category/content/cache-clear/delete/in-source-search phase events, profiling-only worker cancel-receipt acknowledgements, valid-sample-counted isolate peak memory, and the database worker's idle-only one-shot post-GC heap probe; overlapping database requests are explicitly invalidated instead of misattributed, the performance benchmark sets the flag automatically, and production launches must leave it unset
|
|
|
|
- Settings, portal request/response, and trace payloads must use
|
|
`@iptvnator/shared/logging` or the redacting portal logger before reaching
|
|
`console.*`; never log raw credentials while debugging.
|
|
|
|
- If local Nx state gets weird before a rerun:
|
|
|
|
```bash
|
|
pnpm nx reset
|
|
```
|
|
|
|
### agent-browser (global install)
|
|
|
|
```bash
|
|
agent-browser --cdp 9222 tab list
|
|
agent-browser --cdp 9222 tab 1
|
|
agent-browser --cdp 9222 snapshot -i -c -d 4
|
|
agent-browser --cdp 9222 screenshot /tmp/iptvnator-cdp.png
|
|
```
|
|
|
|
### Fallback
|
|
|
|
```bash
|
|
npx --yes agent-browser --cdp 9222 tab list
|
|
```
|
|
|
|
### DevTools Workaround
|
|
|
|
```bash
|
|
ELECTRON_OPEN_DEVTOOLS=1 pnpm nx serve electron-backend
|
|
curl http://127.0.0.1:9222/json/list
|
|
agent-browser connect ws://127.0.0.1:9222/devtools/page/<iptvnator-page-id>
|
|
agent-browser screenshot /tmp/iptvnator-cdp.png
|
|
```
|
|
|
|
## Main-process ownership
|
|
|
|
The entry point is `apps/electron-backend/src/main.ts`; it bootstraps the database,
|
|
registers events and creates the main window. The preload is
|
|
`apps/electron-backend/src/app/api/main.preload.ts`, with handlers under
|
|
`apps/electron-backend/src/app/events/`. The window follows the saved startup mode
|
|
(normal/maximized/fullscreen); `--fullscreen` overrides a single launch. Use
|
|
[workspace shell](../architecture/workspace-shell.md) for window behavior,
|
|
[DB worker](../architecture/sqlite-db-worker.md) for worker ownership and
|
|
[Electron security](../architecture/electron-security.md) for bridge boundaries.
|