[OA][Fullstack] - OA Websockets#278
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
||
| return ( | ||
| <div className="flex h-screen w-full flex-col overflow-hidden"> | ||
| {/* onOpenChange is returning nothing as we don't have recovery implemented just yet */} |
There was a problem hiding this comment.
when you say "recovery," do you mean a client disconnects and then reconnects after a brief delay?
There was a problem hiding this comment.
Yes, this is to tee us nicely for handling us having a seperate countdown for clients who have disconnected, and give them a chance to reconnect.
| @@ -0,0 +1,61 @@ | |||
| import { Skeleton } from '@/lib/components/ui/Skeleton'; | |||
There was a problem hiding this comment.
Something to note (I saw this post abt this package that does exact skeleton according to the content - not really needed here but could be something so that skeleton is just a wrapper and we don't have to do this in the future) not prio tho
| <ResizableHandle className="bg-sarge-gray-200 w-px" /> | ||
|
|
||
| <ResizablePanel defaultSize={65} minSize={40}> | ||
| <div className="flex h-full flex-col overflow-hidden bg-[#3a414f]"> |
There was a problem hiding this comment.
are we just doing this hex bc we have nothing in the design system? (idt we have skeleton so would be fine if not)
There was a problem hiding this comment.
This hex is the same color as our monacode text editor theme
There was a problem hiding this comment.
I think eventually we'll make a design token for this then I know olivia has new designs for the editor
| <button | ||
| type="button" | ||
| <Button | ||
| variant="icon" |
|
|
||
| return { | ||
| ...ws, | ||
| isConnected: ws.readyState === ReadyState.OPEN, |
There was a problem hiding this comment.
I think this will show the modal when we start the oa - the is connected starts as false
(I think it will correct itself) but we should show this modal if there has been a connection established and then lost
could add a hasconnected flag that becomes true on the WS reaches open state
There was a problem hiding this comment.
Not too sure if I understand what you're saying here. This shows the Modal if the WS connection is not open. The server will always be open on our end, so if the client disconnects, it goes to a CLOSED state, meaning that isConnected would be false
|
Also I think the timer will still keep counting down when they're disconnected |
|
I think opening multiple tabs could cause issues as well since the map is keyed by the email so if we have tab A connected, then tab B connects which overwrites Tab A's entry??? so then if Tab A disconnects (which removes the entry) then Tab b's socket would be left without a mapping idk if this is intended, but I know I've accidentally opened two tabs during an oa so this would kinda break this instance (not common, but could be something that would happen) |
|
|
||
| const jwt = await new SignJWT({ email }) | ||
| .setProtectedHeader({ alg: 'HS256' }) | ||
| .setExpirationTime('2h') |
There was a problem hiding this comment.
does the jwt regen throughout the oa at all bc couldn't an oa be longer than 2h so this would cut someone off early
There was a problem hiding this comment.
No it doesn't! What's the "max time" you think an OA would be right now. We need some sort of limit just for token lifetimes and WS stuff.
There was a problem hiding this comment.
hmm ig the longest I've taken is 90 minutes so maybe 2 hours is fine for now
There was a problem hiding this comment.
Ok! Could totally be temporary
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| // TODO: add route security |
There was a problem hiding this comment.
Have we made a ticket for this?
There was a problem hiding this comment.
Not yet. Will be written, but not urgent for showcase
| @@ -0,0 +1,5 @@ | |||
| import z from 'zod'; | |||
|
|
|||
| export const TokenSchema = z.object({ | |||
There was a problem hiding this comment.
We should name this to something that signifies it is for the OA only.
assessment outro update outro update intro make prettier [OA][Fullstack] - OA Websockets (#278) * progress * modal + handling skeleton and stateful code editor * prettier * update tokenschema name [OA][Fullstack] - OA Websockets - follow up (#278) window unfocused modal (#279) * window unfocused modal * PR fixes update button
assessment outro update outro update intro make prettier [OA][Fullstack] - OA Websockets (#278) * progress * modal + handling skeleton and stateful code editor * prettier * update tokenschema name [OA][Fullstack] - OA Websockets - follow up (#278) window unfocused modal (#279) * window unfocused modal * PR fixes update button
assessment outro update outro update intro make prettier [OA][Fullstack] - OA Websockets (#278) * progress * modal + handling skeleton and stateful code editor * prettier * update tokenschema name [OA][Fullstack] - OA Websockets - follow up (#278) window unfocused modal (#279) * window unfocused modal * PR fixes update button
[OA][Fullstack] - OA Websockets
Changes
POST /api/tokento generate a JWT that the WS server will verifyuseHeartbeathook that allows the client to make continuous websocket requests to the serverLostConnectionModalcomponent to be displayed when the candidate disconnects. This also displays theAssessmentSkeletoncomponent in the background.isConnectedvalue from theuseHeartbeathook triggers to false and changes the state of the page. This changes back to true when the client and server can establish a connection againNotes
AssessmentOutrocomponent FOR NOW.Screenshots
https://sandboxneu.slack.com/archives/C09E7L2RK16/p1775507945604729?thread_ts=1775507637.130809&cid=C09E7L2RK16
Checklist
Please go through all items before requesting reviewers:
Closes
Closes #273