Commit Graph

42 Commits

Author SHA1 Message Date
Abhinav Raut 1cda45797e share email template variables and add notification greetings
Preserve existing template fields while sharing conversation data across customer emails and agent alerts. Use the system layout for automation alerts and add regression coverage for notification delivery and conversation switching.
2026-10-18 20:47:24 +05:30
Abhinav Raut ced1a8bee5 add per-agent notification preferences and browser push 2026-09-15 12:31:27 +05:30
Abhinav Raut 02906ef5ba clear sla deadlines on policy delete and stop double counting next response 2026-08-21 02:21:06 +05:30
Abhinav Raut 6fa5d66b6b recompute conversation SLA deadline when next response is settled
Marking a next-response SLA event met or breached never updated
conversations.next_sla_deadline_at, so the conversation kept sorting as if
the reply was still due. Reopening a resolved conversation had the same
problem in reverse: the column stays NULL even though its deadlines are
live again.
2026-08-21 02:01:04 +05:30
Abhinav Raut 3a9e66d051 batch the settled sweep deadline recompute and abort re-apply when judging the old sla fails 2026-08-19 22:10:23 +05:30
Abhinav Raut 5dbcebe3ab judge outcomes that already happened before superseding an sla
A team or policy change between evaluation ticks deleted outcomes the tick had not
stamped yet: an incurred breach vanished and a met first reply got re-judged under the
new policy. ApplySLA now evaluates the outgoing SLA first, apply-sla scores and keeps
overdue next-response events, and the deadline recompute reads only the latest SLA's
events. Also adds fetching/fetched logs around both evaluation loop queries.
2026-08-19 21:27:45 +05:30
Abhinav Raut d73151a07e fix sla status labels, notification cleanup, and the deadline overwrite race
Superseded SLAs now get their status from first-response/resolution outcomes, with
next-response events judging only next-response-only policies. Re-applying an SLA no
longer cancels unsent breach escalations, and deadline recomputes now lock the
conversation row so the sweep can't overwrite a fresh deadline with a stale one.
2026-08-19 20:29:13 +05:30
Abhinav Raut 81f1deb122 skip the first-response deadline once the agent has replied
The conversation deadline only ignored the first-response deadline after the tick
stamped first_response_met_at, so a conversation could show an already-satisfied
first-response deadline for up to one 5m tick. Gate it on first_reply_at too, drop
a redundant applied_slas re-join in the sweep, and add tests for both cases.
2026-08-19 18:38:19 +05:30
Abhinav Raut fa86582527 compute next sla deadline as the earliest open obligation including live next-response countdowns 2026-08-19 17:58:11 +05:30
Abhinav Raut 097585a148 keep events with a stamped outcome that the tick has not statused yet 2026-08-19 16:49:22 +05:30
Abhinav Raut 05c6e5902c add comment explaining the closed cte gate 2026-08-19 16:48:01 +05:30
Abhinav Raut ee82b772ec use != instead of <> in sla queries 2026-08-19 16:38:34 +05:30
Abhinav Raut ced045f716 keep applied slas whose next-response events scored instead of cascading the history away 2026-08-19 16:35:01 +05:30
Abhinav Raut e0127ce341 add short comments above each cte in the changed sla queries 2026-08-19 16:17:39 +05:30
Abhinav Raut 06b949a4a6 cover all sla policy metric combinations and clean orphaned events on re-apply 2026-08-19 15:52:15 +05:30
Abhinav Raut db8cb5192f exclude next-response-only slas from the settled sweep so their live deadline is not wiped 2026-08-19 15:14:13 +05:30
Abhinav Raut 52be8821ca chain apply-sla ctes so the insert runs after the old pending row is closed or deleted 2026-08-19 15:02:42 +05:30
Abhinav Raut b10a854df9 make settled sla sweep self healing and repair conversation deadline in the same statement 2026-08-19 14:50:03 +05:30
Abhinav Raut db60ac0450 close settled slas only for rows whose evaluation fully succeeded 2026-08-19 14:34:40 +05:30
Abhinav Raut 4277ff501f fix sla apply atomicity and superseded sla cleanup, read static file bytes once 2026-08-19 14:03:29 +05:30
Abhinav Raut 9708f78c79 reduce memory and cpu use in sla, static asset and api key paths
Profiled the prod alloc with pprof. Three things stood out.

SLA evaluation was refetching about 234k pending rows every 10 minutes and the
count only ever grew. A policy can leave the resolution time blank, which
stores a NULL resolution deadline. The evaluator needs a deadline to compare
against, so it could never set met_at or breached_at, and the row stayed
pending forever. The pending query now skips a metric with no deadline, and a
new set based query closes any pending row whose configured metrics have all
settled. It replaces the old per row status update, so there is one status
writer and the backlog drains itself on the first tick. No migration is needed
because nothing outside the sla package reads that status.

Static assets were copied into fasthttp's pooled per connection response
buffer on every request. That buffer keeps its grown size, so serving the
frontend bundle held about 165MB. SetBodyRaw points at the bytes instead of
copying them.

API key auth ran a full bcrypt compare on every request, which was 62 percent
of cpu samples. API secrets are 64 char random tokens, so bcrypt's work factor
buys nothing there. They are now hashed with sha256 and compared in constant
time. Old bcrypt hashes still verify and get upgraded in place on first use,
so no key needs reissuing. Password login still uses bcrypt.

This also fixes an unrelated bug the work turned up. apply-sla deleted pending
rows by status alone, so re-applying an SLA threw away a first response breach
that was already recorded. It now deletes only rows with nothing recorded and
closes the rest to their terminal status first.
2026-08-19 12:55:52 +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 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 aa9e4cdae2 feat: add conversation status categories and update related logic.
- Introduced a new category field for conversation statuses to classify them as 'open', 'waiting', or 'resolved'. Which allows max assignment limits in team to work with custom statuses as well.
2026-04-21 16:55:09 +05:30
Abhinav Raut 7524ba6c19 Add support for custom attributes to createConversationRequest
More polishes to notif panel
Add `You` for current agent in select combobox.
Remove unncesary checks for existing notifications while marking it as read.
Send oldest SLA notifcation first (update sql query)
2026-04-12 22:54:54 +05:30
Abhinav Raut 064a73ba4b feat: add conversations:read_team_all permission to allow agents to see conversations assigned to their team, regardless of whether an agent is assigned or not.
- Allow all SLAs to be fetched without permission checks.

Ref #203
2025-12-26 19:57:45 +05:30
Abhinav Raut d2e5d85e3a fix: return created/updated objects in POST/PUT responses with masked secrets
All POST/PUT handlers now return actual database objects instead of `true`
2025-06-20 19:35:09 +05:30
Abhinav Raut 3998798e54 refactor: rename SQL query names and struct fields for clarity and consistency 2025-05-27 02:45:43 +05:30
Abhinav Raut b715483260 refactor(conversation): reduce DB I/O by using existing appliedSLAID from conversation
- Passes appliedSLAID directly to SLA logic instead of refetching
- Adds appliedSLAID field to conversation struct (already fetched in get-conversation query)
2025-05-26 03:48:41 +05:30
Abhinav Raut 7426a09478 feat: allow setting metric per SLA notification, so admins can set SLA alert per metric or just set to all if they want a notification to be sent for all metrics
- Make sla time fields (first response, next response, resolution) optional, only 1 field is required.
2025-05-26 03:48:41 +05:30
Abhinav Raut 8ad2f078ac fix sql query 2025-05-26 03:48:41 +05:30
Abhinav Raut 9226063db3 fix: remove queries using conversation.applied_sla_id
as this column is removed
- fix sql query
2025-05-26 03:48:41 +05:30
Abhinav Raut a9fd4fe2b6 fix: uise existing set next sla deadline sql query and remove duplicate query.
- remove previously added `applied_sla_id` column to conversations table as it was causing cyclic dep
2025-05-26 03:48:41 +05:30
Abhinav Raut 7e8c9962c3 Fixes for next response time sla metric 2025-05-26 03:48:41 +05:30
Abhinav Raut 4c766d8ccb wip: next response metric for sla 2025-05-26 03:48:41 +05:30
Abhinav Raut aeef7d4ad7 feat: configurable SLA alerts per SLA. 2025-03-21 23:23:03 +05:30
Abhinav Raut 45541c221a fix: various bugs in SLA calculation
prevents multiple update queries unnecessarily on applied sla table.
clear next sla deadline in conversations properly when there's no deadline to be met.
uses the new status column in the applied sla table to determine if the sla is still active and has to be calculated again.
2025-03-12 02:45:17 +05:30
Abhinav Raut 6993d972ab fix[SLA]: Use conversation created_at time as start time for SLA calculation. This makes sure when SLA is changed for a conversation the elapsed time carries over.
refactor: improve error handling and update comments for clarity
2025-02-02 23:51:50 +05:30
Abhinav Raut 3c71ab35ff Feat: Add SLAs per team
- Feat: Provide the ability to change SLAs for conversations; this will start a new deadline calculation from the time the SLA is set.
2025-01-24 04:34:51 +05:30
Abhinav Raut 50188352a5 fix: Use SyncedEnforcer in casbin, fixes panics.
feat: store user roles in user roles table, drops the roles table on users table.
feat: standardize column names in schema, renames disabled bool to enables.
- vue router fixes to allow components / pages to rerender after creating an object in db.
- minor fixes and refactors.
2025-01-22 03:40:32 +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 caf8e7d34d WIP: MVP with shadcn sidebar
- csat
- SLA
- email notification templates
2025-01-06 02:39:44 +05:30