Skip to content

Auto-restart session on expiry, extend test coverage to 93%, add CI workflow - #11

Merged
chintandesai-cimulate merged 7 commits into
mainfrom
feature/auto-restart-expired-session
Sep 16, 2026
Merged

chintandesai-cimulate merged 7 commits into
mainfrom
feature/auto-restart-expired-session

Conversation

@shilpi1998

@shilpi1998 shilpi1998 commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Auto-restart on session expiry: When the SDK emits SESSION_EXPIRED, the widget silently resets to idle instead of showing an error. Clears the stored session, resets hasUserSentRef to drop the new welcome greeting, and sets status back to idle. The user's next message transparently triggers a fresh handshake via ensureConnected.
  • Clear typing/streaming state on expiry: If session expires mid-response (while agent is typing or streaming), agentTyping and streamingText are now cleared by dispatching SET_ANSWER with empty content before resetting to idle — prevents the composer from staying disabled.
  • Unit test coverage extended from 77% to 93%: Added 132 tests across 9 test files covering SDK modules (client, event-emitter, logger, SSE, errors), provider logic (product-context), and token parsing.
  • CI workflow: Added GitHub Actions workflow (.github/workflows/ci.yml) that runs unit tests with coverage on PRs and pushes to main (Node 20.x).
  • Coverage thresholds: 90% statements/functions/lines, 80% branches — enforced by vitest in CI.

Test plan

  • Let a session expire (or simulate by waiting for token TTL) — widget should reset to idle, no error shown
  • Send a message after expiry — fresh session starts transparently
  • If session expires mid-agent-response, typing indicator and streaming text are cleared, send button re-enables
  • Welcome greeting from the new session is dropped (hasUserSentRef reset)
  • npm test — all 132 tests pass with coverage above thresholds
  • CI check passes on the PR

When the SDK emits SESSION_EXPIRED, silently reset the widget to idle
(clear stored session, reset hasUserSentRef, clear error) so the next
user interaction triggers a fresh handshake via ensureConnected.
Add new test files for event-emitter, logger, errors, and SSE reader.
Extend existing client and tokens tests to cover reconnect paths,
typing events, error edge cases, and JSON extraction branches.
If the session expires while the agent is mid-response, agentTyping or
streamingText could remain set. Since hasUserSentRef is reset to false,
the follow-up typing_stopped/message events that would clear them are
blocked, leaving the composer disabled. Dispatch SET_ANSWER to clear
both before resetting to idle.
@shilpi1998 shilpi1998 changed the title Auto-restart session on expiry instead of showing error Auto-restart session on expiry, extend test coverage to 93%, add CI workflow Sep 16, 2026
@chintandesai-cimulate
chintandesai-cimulate merged commit 7b96a45 into main Sep 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants