Commit Graph

42 Commits

Author SHA1 Message Date
Abhinav Raut 5813ac3e73 remove comment 2026-08-21 21:59:40 +05:30
Abhinav Raut 8a881909b8 actually close agent websockets on kick and shutdown
KickUser and CloseAll only wrote a close frame and called Conn.Close,
which fasthttp turns into a no-op on a hijacked conn, so a client that
ignores the frame stayed connected and stayed in the hub. Expire the read
deadline and tear the client down so Serve returns.

The agent app had the same replaced-socket problem as the widget, where a
stale socket's close event cleared the live socket's ping timer and the
server dropped it 60s later. Also check the widget client's closed flag
before refreshing the read deadline, and reset inbox and user id on
re-join.
2026-08-21 21:00:39 +05:30
Abhinav Raut 3393b6e1cb close websockets and bound the http server shutdown 2026-08-21 18:11:44 +05:30
Abhinav Raut ec629ba055 use slices.Delete to remove a websocket client from the hub 2026-08-21 02:49:42 +05:30
Abhinav Raut 6a6a0a818d simplify websocket client and fix handshake error response 2026-08-20 14:46:10 +05:30
Abhinav Raut 1d9c20f343 guard websocket client sends against the channel close
SendMessage checked a separate Closed flag before sending, so a close
between the check and the send panicked on a closed channel. SendError
could also close the channel and then let Listen close it again on exit.
Both sends now go through trySend, which takes the same lock the close
takes, and close is idempotent.

A failed join response in the widget socket returned a nil client, so the
caller skipped cleanup and left the forwarder goroutine blocked forever.
It now removes the client and closes its channel first.
2026-08-20 13:15:31 +05:30
Abhinav Raut a1cae0b896 close and release websocket connections promptly on failure paths
Close the widget conn when a write fails since the library marks it unusable, bail out of Listen through the cleanup path if the initial read deadline cannot be set, and nil the trailing slot in RemoveClient so the removed client is garbage-collected right away.
2026-08-20 12:46:38 +05:30
Abhinav Raut 4fce040d6b reduce websocket per-connection memory and hot-path allocations
Hijacked websocket connections hold their fasthttp ctx until close, and
fasthttp keeps each recycled response buffer at full capacity, so memory
grew with every large response. Cap the pooled body size at 64 KiB and
share a write-buffer pool across both upgraders instead of allocating
8 KiB per connection at upgrade.

On the hot broadcast path, convToBroadcastMap did a marshal-unmarshal
round trip per event just to drop two per-user fields. Replace it with a
broadcastConv struct that shadows those fields via omitempty. Inbound
frames now decode once through json.RawMessage instead of re-marshaling
map[string]any per handler.

Also fix liveness: agent clients had no read deadline, so a peer that
vanished without closing (slept laptop, dropped wifi) blocked Listen
forever. Add ping/pong (25s ping, 60s pong wait), write deadlines on
both agent and widget writers, a 64 KiB read limit, and delete the
empty clients map entry in RemoveClient so user IDs don't leak.
2026-08-20 12:29:14 +05:30
Abhinav Raut 29881f2f82 fix: close ws stale-perm gaps and resub on reconnect
Reject disabled agents in FilterAuthorizedListUUIDs, kick role members on
permission removal or role delete, and re-sub the list and open conv on
ws reconnect using local state. Also plug the app logger into the ws
package so kicks no longer log when no connections exist.
2026-05-28 20:07:19 +05:30
Abhinav Raut a502039e59 perf: WS push for conv list, store/cache cleanups, ad-hoc UI polish
Convs and messages now push the full list-row payload to perm-authorized agents on create/assign/message, so livechat returning customers bubble up instantly without waiting for the timer refresh. Background list refresh bumped 30s ->  60s as a drift safety net.
2026-05-22 20:47:36 +05:30
Abhinav Raut edc82e9e55 refactor: drop Casbin, centralize agent cache invalidation, dedupe pending SLAs 2026-05-21 21:24:42 +05:30
Abhinav Raut 7a8efcde16 fix: widget ping interval, last_active flush, ws ping error, slim new_message payload 2026-05-21 00:13:33 +05:30
Abhinav Raut 43ebed1c3a WS rewrite: per-client subscriptions and perf improvements
Targets broadcasts via per-tab list and open subs (validated at subscribe time)
instead of broadcasting message uuid to all agents. Adds frontend list typing, throttled sound,
and many perf improvements to reduce cpu memory & database queries.
Other fixes: Enforce message-to-conversation binding in handleGetMessage
2026-05-20 23:42:07 +05:30
Abhinav Raut ab05d6abad fix ws client leak when conn dies between ping writes 2026-05-12 11:43:57 +05:30
Abhinav Raut f7cbfb525c Hard widget endpoints
- Gate widget inbox_id on UUID to prevent enumeration.
- Throttle inbound WS frames per connection (typing/page_visit/ping)
- Restrict admin-set URLs to http/https
- Apply closed-conversation reply guard to media upload path (was text-only)
- Reject empty uploads and use io.ReadAll
- Validate inbox config before DB create; drop unused func VerifySignature
2026-04-17 02:41:40 +05:30
Abhinav Raut 882f650401 Stop broadcasting typing indicator between agents 2026-04-13 14:51:37 +05:30
Abhinav Raut d590ace4a9 Fix typing indicator broadcast to exclude the sender by comparing client IDs 2026-04-02 11:48:54 +05:30
Abhinav Raut 71c8ec88c0 Remove unused WS unsubscribe functions 2026-03-30 02:26:15 +05:30
Abhinav Raut 7d8c2d9fa3 Check conversation ownership before broadcasting typing event on conversations 2026-03-30 02:23:07 +05:30
Abhinav Raut 395a4e80df Refactor ws updates to use direct json payloads instead of prop value pattern.
Add real-time agent availability status updates to widget.

Consolidate multiple WS broadcasts into single calls
2026-03-22 19:34:21 +05:30
Abhinav Raut 7958d7e212 Merge branch 'main' into feat/live-chat-channel 2026-01-14 00:33:51 +05:30
Abhinav Raut 4bab16c21a feat: user app notification system with bell icon in the sidebar
- notifications for: mention', 'assignment', 'sla_warning', 'sla_breach'
- new table `user_notifications` and migrations for the same.
2026-01-02 01:46:47 +05:30
Abhinav Raut 4a1e7af2fa do not sending typing ws message to widget clients if it's a private message being typed by agent 2025-10-04 12:32:34 +05:30
Abhinav Raut 8ee81c2d64 feat: Widget dark mode and chat reply expectation message in chat title.
feat: Add HTTP utility functions for trusted origin checks

feat: Implement typing status broadcasting for live chat clients and agents.

feat: Add support for signed URLs in media manager

fix: Update database migration to handle duplicate visitors with same email address.

feat: Add conversation subscription and typing message models for WebSocket communication

feat: Implement conversation subscription management in WebSocket hub this is used for broadcasting typing indicator.

feat: Revamp widget JavaScript to improve mobile responsiveness and show unread messages if any.
2025-07-17 01:06:54 +05:30
Abhinav Raut 5b6a58fba0 wip: intercom like live chat with chat widget
- new vue app for serving live chat widget, created subdirectories inside frontend dir `main` and `widget`
- vite changes for both main app and widget app.
- new backend live chat channel
- apis for live chat widget
2025-06-29 04:59:55 +05:30
Abhinav Raut 67e1230485 feat: agent availability status
New columns in users table to store user availability status.

Websocket pings sets the last active at timestamp, once user stops sending pings (on disconnect) after 5 minutes the user availalbility status changes to offline.

Detects auto away by checking for mouse, keyboard events and sets user status to away.

User can also set their status to away manually from the sidebar.

Migrations for v0.3.0

Minor visual fixes.

Bump version in package.json
2025-02-26 04:34:30 +05:30
Abhinav Raut 0c01b53b09 feat(conversations): add trigram index for searching ref numbers
feat(messages): add trigram index for text content search
- feat: UI animations for conversation and messages list.
- Simplify websocket updates.
2025-01-19 23:10:53 +05:30
Abhinav Raut 0c54abbbad refactor: rename modules and imports to reflect project name 2025-01-11 21:46:29 +05:30
Abhinav Raut caf8e7d34d WIP: MVP with shadcn sidebar
- csat
- SLA
- email notification templates
2025-01-06 02:39:44 +05:30
Abhinav Raut b1975d6484 feat: graceful shutdown
- feat: sets inter as the app font
- feat: update colour theme
- remove unncesary redirects after form is saved
- feat: addsconv  reference number in information accordion
- feat: adds reference number filter to conversation list
- feat: adds title for router components
- chore: remove unused uuid columns from tables
2024-10-22 02:52:36 +05:30
Abhinav Raut 2b25ce32b6 feat: adds nonce check for oidc token exchange
- feat: adds filters support on conversations list
- refactor middlewares.go
- Adds new paginate.go for generating filtered paginated SQL queries this removes sql generation code from the conversations package.
- rename some components
- removes hardcoded `/uploads/`
2024-10-17 04:21:22 +05:30
Abhinav Raut 98df9efd63 feat: adds dropdown to automation form fields
- feat: adds csrf token check
- feat: adds conversation sub and unsub for WS updates.
- Clean up and remove unncessary code
- refactor and simplify auth middlewares
- fix: automation rules
- Update schema.sql
2024-10-14 01:50:08 +05:30
Abhinav Raut fbf631d8ad fix: whitespace being trimmed in canned repsonse
- refactor: conversations store.
- feat: Show conversation subject on top of conversation messages list
- feat: adds shadow to panels
- update: schema.sql adds insert statements for priority / status
- fix: trim canned response content to 100 chars.
- revert: rename team conversations tab to unassigned.
2024-10-11 05:31:12 +05:30
Abhinav Raut e16c627f67 feat: refactor frontend conversations
- remove unused heroicons pkg.
2024-09-30 01:01:06 +05:30
Abhinav Raut 0e84fac099 feat: ACL and ABAC
- Simplify ws package.
2024-09-19 04:17:03 +05:30
Abhinav Raut ead54665fb wip: oidc 2024-07-31 04:02:34 +05:30
Abhinav Raut 3d6d513ba9 more commits. 2024-07-29 04:03:19 +05:30
Abhinav Raut 7ac9a2fe67 refactor entire backend 2024-07-25 02:03:56 +05:30
Abhinav Raut 8b763fb167 refactor. 2024-07-24 03:00:54 +05:30
Abhinav Raut f86077f944 refactor. 2024-07-15 02:55:27 +05:30
Abhinav Raut d7fb9be211 some more commits? 2024-07-01 03:08:45 +05:30
Abhinav Raut 6a27b2fa4b refactor 2024-06-10 03:45:48 +05:30