Skip to content

fix(ui): first sign-in after a session expiry no longer bounces back to the login screen - #150

Closed
pyramation wants to merge 4 commits into
mainfrom
devin/1790381154-login-twice
Closed

pyramation wants to merge 4 commits into
mainfrom
devin/1790381154-login-twice

Conversation

@pyramation

@pyramation pyramation commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Operators reported: after being kicked to the login screen, the first correct login "doesn't work", the second one does. UI-only; the 30-day session TTL landed separately in #151.

Bounce-back bug. After a session expires, useSocket leaves connection = { state: 'down', cause: 'sessionExpired' }. On login the token changes, and the app.tsx effect

if (token && connection.state === 'down' && connection.cause === 'sessionExpired') sessionEnded();

re-runs with the new token but the old verdict, so it signs the operator straight out again. Fix: ConnectionInfo carries the token the down verdict was reached with (set in use-socket.ts), and the effect only acts when connection.token === token.

Stale diagnosis race (review finding). Each ws.onclose fires an async diagnoseConnection; a slow verdict from a superseded socket could overwrite a newer one (e.g. mask a 4001 sessionExpired). connect() now bumps a generation and the verdict is dropped unless gen === generation.

Deploy: UI-only rebuild, no server restart, no receiver change.

Link to Devin session: https://app.devin.ai/sessions/c4872c2982734093bdee80d04a7d5ceb
Open in Devin Desktop: https://app.devin.ai/desktop/session/c4872c2982734093bdee80d04a7d5ceb?variant=devin
Requested by: @pyramation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@luxor-code-review

luxor-code-review Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)

  • 🟡 Stale diagnoseConnection verdicts clobber newer close states — use-socket.ts:76

This PR threads a token through the UI connection layer so connection state can carry which login it belongs to, and stamps setConnection calls in use-socket.ts with the token captured from the current effect closure, including the down verdicts produced by diagnoseConnection. The effect dependency array now includes connection.token, and a guard prevents a pending probe from an old session from reporting down onto a fresh login while the effect is still mounted.

Files Change
packages/ui/src/lib/connection.ts Adds optional token to the ConnectionInfo state shape
packages/ui/src/lib/use-socket.ts Captures the current connection.token per effect and stamps every setConnection call with it; adds the token to the effect's dependency array
packages/ui/src/app.tsx Consumes the token-tagged connection state and adapts the session-expired handling accordingly

Reviewed commit: b9fb8e9

@devin-ai-integration devin-ai-integration Bot changed the title fix(ui): first sign-in after a session expiry no longer bounces back to the login screen fix(auth): first sign-in after expiry sticks; sessions last 30 days Sep 26, 2026

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a per-login token to the UI's connection state so stale diagnosis verdicts can be distinguished across logins; one medium-severity race remains within a single token's reconnect cycles.

Key findings

  • 🟡 Stale diagnoseConnection verdicts clobber newer close states — use-socket.ts:76

Comment thread packages/ui/src/lib/use-socket.ts Resolved
…n-twice

# Conflicts:
#	packages/settings/src/sessions.ts
@devin-ai-integration devin-ai-integration Bot changed the title fix(auth): first sign-in after expiry sticks; sessions last 30 days fix(ui): first sign-in after a session expiry no longer bounces back to the login screen Sep 26, 2026
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.

1 participant