Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New log streaming API #603

Merged
merged 56 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0bbaaa3
refactor(requests): rename humanRoute to title + update request args
Axolotle Dec 4, 2024
0b82f74
feat: add SSE composable + init fn
Axolotle Dec 4, 2024
dbac125
type: add SSE event types
Axolotle Dec 4, 2024
895d792
refactor(requests): rename websocket arg to isAction + add action ope…
Axolotle Dec 4, 2024
3839719
feat: handle 'start' + 'end' SSE events
Axolotle Dec 4, 2024
c057b66
feat: handle 'msg' SSE event
Axolotle Dec 4, 2024
d6d86c3
refactor: replace websocket with sse
Axolotle Dec 4, 2024
ecfdf6d
chore: remove no longer used openWebSocket fn
Axolotle Dec 4, 2024
8dd31a4
feat(sse): add SSEEventDataHistory type
Axolotle Dec 8, 2024
c9f45fd
refactor(sse): separate sse msg handlers depending on msg type
Axolotle Dec 8, 2024
21d28c8
feat(sse): handle 'recent_history' events
Axolotle Dec 8, 2024
32089c0
feat(sse): handle 'heartbeat' events
Axolotle Dec 8, 2024
730d7a1
feat(sse): handle sse reconnection
Axolotle Dec 8, 2024
c03a871
fix(sse): reset timeout on every sse message instead
Axolotle Dec 9, 2024
90f4066
feat(QueryHeader): display date or time depending on today
Axolotle Dec 9, 2024
5f18d00
fix(sse): datestamp * 1000
Axolotle Dec 10, 2024
7f9bc2d
refactor(api): send locale as header
Axolotle Dec 10, 2024
a9343c9
refactor(api): remove asFormData param to api.fetch()
Axolotle Dec 10, 2024
cab1b68
refactor(sse): retreive request title from start or history event
Axolotle Dec 11, 2024
d70b664
refactor: make request title optional
Axolotle Dec 11, 2024
c35a71a
refactor: remove humanKey arg in api
Axolotle Dec 11, 2024
75ebee1
refactor: remove humanKey in api calls
Axolotle Dec 11, 2024
4010c2e
refactor: replace api's websocket param with isAction
Axolotle Dec 11, 2024
07de12d
fix: title ternary wrong parenthesis
Axolotle Dec 11, 2024
c4ffab8
refactor: remove human_routes translations
Axolotle Dec 11, 2024
20e7576
fix: rename header ref-id + update request title on start event
Axolotle Dec 11, 2024
80cdab4
feat: add useAutoToast composable
Axolotle Dec 14, 2024
ba4c780
feat: add sse toast event handling
Axolotle Dec 14, 2024
2c197ec
feat(sse): handle `started_by` & display caller username
Axolotle Dec 14, 2024
37282b5
refactor: remove modal for log share action
Axolotle Dec 14, 2024
4b260eb
feat(sse): try to update the cache from external action
Axolotle Dec 16, 2024
b123db1
feat: add YToast component
Axolotle Dec 16, 2024
ec5b5ee
feat: use YToast component in useAutoToast
Axolotle Dec 16, 2024
bb21fa4
fix: history's last action index
Axolotle Dec 16, 2024
9b784b7
refactor: toast last action's warning message instead of display of M…
Axolotle Dec 16, 2024
0864786
refactor: remove no longer used ModalWarning component
Axolotle Dec 16, 2024
79d7776
fix: websocket arg no longer exists
Axolotle Dec 16, 2024
85b04a4
fix(sse): move conditions to avoid another cache to be updated
Axolotle Dec 16, 2024
fafc6ff
chore: lint
Axolotle Dec 16, 2024
cefad3d
fix(modal): hide-footer -> no-footer
Axolotle Dec 19, 2024
858f124
refactor(sse): use sse event listeners
Axolotle Dec 19, 2024
34055a2
feat(sse): handle heartbeat event with special case current operation…
Axolotle Dec 19, 2024
13ea293
chore: update components.d.ts
Axolotle Dec 19, 2024
8458cae
chore: remove websocket in vite.config.ts
Axolotle Dec 19, 2024
2a5d55b
ts: ApiError is received by calling it so request method should be de…
Axolotle Dec 19, 2024
6f8817c
fix(postinstall): init SSE in postinstall view
Axolotle Jan 17, 2025
f5b4e71
fix(YToast): use html in message
Axolotle Jan 17, 2025
5ac957e
fix(sse): do not open sse if already opened
Axolotle Jan 18, 2025
1c23d5d
fix(history): do not show requests which are simple lock in history
Axolotle Jan 18, 2025
b1bbcd4
sse: 'started by'
alexAubin Jan 18, 2025
94b0ee4
fix(sse): show unsuccessful external action error msg in toast
Axolotle Jan 18, 2025
d46d1fc
refactor(YToast): always cancelable + 30s auto cancelable
Axolotle Jan 19, 2025
7315568
feat(sse): update sse connection with reconnection api
Axolotle Jan 19, 2025
5f16d03
refactor: update reconnection modal
Axolotle Jan 19, 2025
7cf26ab
refactor: update reconnection use in views
Axolotle Jan 19, 2025
2ffddf2
refactor: remove previous reconnection api
Axolotle Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(sse): separate sse msg handlers depending on msg type
  • Loading branch information
Axolotle committed Dec 19, 2024
commit c9f45fdcdebf9984eb9f139f4b559e4155acde31
12 changes: 7 additions & 5 deletions app/src/composables/useSSE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type AnySSEEventData =
| SSEEventDataHistory
| SSEEventDataHeartbeat

function isActionEvent(data: AnySSEEventData): data is AnySSEEventDataAction {
return ['start', 'msg', 'end'].includes(data.type)
}

export const useSSE = createGlobalState(() => {
const sseSource = ref<EventSource | null>(null)
const { startRequest, endRequest, historyList } = useRequests()
Expand All @@ -68,18 +72,16 @@ export const useSSE = createGlobalState(() => {
}

sse.onmessage = (event) => {
const data = JSON.parse(atob(event.data))
onSSEMessage(data)
const data: AnySSEEventData = JSON.parse(atob(event.data))
if (isActionEvent(data)) onActionEvent(data)
}

sse.onerror = (event) => {
console.error('SSE error', event)
}
}

function onSSEMessage(data: AnySSEEventData) {
if (data.type === 'heartbeat') return // FIXME handle heartbeat msg

function onActionEvent(data: AnySSEEventDataAction) {
let request = historyList.value.findLast(
(r: APIRequest) => r.id === data.ref_id,
) as APIRequestAction | undefined
Expand Down