心跳问题修复
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# Plugin connection status refresh after login
|
||||
|
||||
## Scope and gate
|
||||
- User reports that normal polling logs are quiet but plugin connection status only becomes connected after refreshing the page. Investigate status/heartbeat lifecycle and repair confirmed frontend defects; preserve quiet successful logs.
|
||||
- Feature mode on main, /Users/andy/IdeaProjects/LWLT-AIBOT, base 9625110f44b0f1c2c6b10cdf58e5845512ff51c7. One worktree. Existing .idea and plugin 0.5.182 ZIP are known and untouched; tracked source clean. Overlap: Clear.
|
||||
- Main-thread only. Own LianSyn-platform/app.js, a focused frontend regression test and this record. No .env reads, live ERP access, task mutations, extension reload, service restart, deployment or external send. No extension source or release changes planned.
|
||||
|
||||
## Findings and plan
|
||||
- Prior quiet-log fixes only gate request-start and successful completion logging; the POST heartbeat handler and browser timers were not changed.
|
||||
- Automatic 30-second background refresh and focus/visibility listeners are registered only inside the initial initializeSession-success branch. Loading while logged out and then submitting the login form performs one ping but never registers the periodic refresh/listeners. A full reload with an existing session does register them.
|
||||
- Reproduce using the actual page bootstrap and login handlers in an isolated fake browser. Make background refresh lifecycle available regardless of initial authentication, keep unauthenticated calls inert and avoid duplicate schedules. Preserve role gates and the 30-second interval. Verify recovery after transient disconnected status without a page reload and all existing checks.
|
||||
|
||||
## User clarification and extended diagnosis
|
||||
- User clarified this also happens while leaving the page open; initial-login scheduling alone is insufficient to explain all symptoms.
|
||||
- Periodic bridge checks share backgroundRefreshInProgress with full task-list synchronization. A pending/continuously coalesced task refresh can prevent all subsequent bridge checks. Bridge PING also uses only a 1.2-second timeout despite awaiting worker wakeup, ERP identity inspection, extension update state and storage reads; a late response is dropped after timeout. Concurrent focus/manual/periodic probes can overwrite newer state.
|
||||
- Verify these cases with fake time and isolated message/API handlers, then decouple bridge liveness from task-list progress, coalesce same-session probes, bound PING wait reasonably and reject stale session responses. BRIDGE_READY should trigger an account-bound fresh check rather than apply its unbound account snapshot. Actual user's browser timing remains unobserved; do not claim a unique runtime cause from source alone.
|
||||
|
||||
## Implementation and verification
|
||||
- Kept the prior quiet-success logging policy and extension 0.5.182 unchanged. Only platform app.js changed at runtime.
|
||||
- Registered the existing 30-second interval and focus/visibility listeners once per page regardless of initial login; no requests while logged out. Moved bridge probing outside the shared task-sync in-progress gate; each account/session has one coalesced in-flight probe. Bounded PING timeout is now 10 seconds instead of 1.2 seconds, allowing worker wakeup/ERP inspection without discarding ordinary slower replies. Real timeouts still show disconnected and recover on later checks.
|
||||
- BRIDGE_READY triggers a fresh check containing the expected ERP account, rather than applying its unbound account snapshot. Late success/failure from an old login cannot overwrite the new session or register its heartbeat. Server execution_ready=false remains a warning; administrator role still never probes or registers a browser worker.
|
||||
- Full app bootstrap and real login/message/timer code run under fake DOM/time/API boundaries. Before-fix failures reproduced missing login scheduling, task-list blocking of heartbeat, two-second valid replies being discarded, overlapping probes and unbound readiness handling. Tests send only fake PING/heartbeat traffic; task dispatch and unrelated rendering are stubbed.
|
||||
- Focused 10/10; control-plane 231/231; legacy 366/366; typecheck/build and git diff --check PASS. Preserved the async pingBridge API expected by the existing authorization regression. Source copy passed repository 10/10. Original repository 8/10 due to pre-existing IDE/OS residue and ignored prior archived logs, untouched. All 2682 copied files SHA-verified; non-example .env files, metadata, logs and generated build output excluded before reads. Final app.js synchronized and verified after the async-interface adjustment.
|
||||
- Main-thread final read-only review PASS: no server logging changes, no extension/package changes, no new business execution path; scheduler remains 30 seconds with one probe per session, role and stale-session gates intact. Actual user browser timing is unobserved, so source reproductions establish failure modes rather than identify a unique live trigger.
|
||||
- Temporary verification: /private/tmp/ltjt-bridge-status-*.log and /private/tmp/ltjt-bridge-status-source-manifest.json. No deployment, service restart, live ERP read/write, extension reload or external send performed. Deploy platform assets, then refresh once to load the fix; future connection recovery should update without reloading.
|
||||
|
||||
## Promotion candidates
|
||||
- Keep worker liveness independent of business-list refresh progress; coalesce concurrent checks, bound response wait and ignore stale session completions. UI readiness announcements require account-bound verification. Canonical promotion deferred to integration.
|
||||
Reference in New Issue
Block a user