@budibase/frontend-core 3.31.2 → 3.31.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "3.31.2",
3
+ "version": "3.31.4",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -24,5 +24,5 @@
24
24
  "devDependencies": {
25
25
  "vitest": "^3.2.4"
26
26
  },
27
- "gitHead": "e43a157f7b7baa20d67d05b35fd94b2b205acb2b"
27
+ "gitHead": "7d5a486a8c245870743408abb7d03a33e19c8679"
28
28
  }
@@ -23,14 +23,19 @@ export interface ChatAppEndpoints {
23
23
  ) => Promise<AsyncIterable<UIMessage<AgentMessageMetadata>>>
24
24
  deleteChatConversation: (
25
25
  chatConversationId: string,
26
- chatAppId: string
26
+ chatAppId: string,
27
+ agentId?: string
27
28
  ) => Promise<void>
28
29
  fetchChatConversation: (
29
30
  chatAppId: string,
30
- chatConversationId: string
31
+ chatConversationId: string,
32
+ agentId?: string
31
33
  ) => Promise<ChatConversation>
32
34
  fetchChatAppAgents: (chatAppId: string) => Promise<FetchChatAppAgentsResponse>
33
- fetchChatHistory: (chatAppId: string) => Promise<FetchAgentHistoryResponse>
35
+ fetchChatHistory: (
36
+ chatAppId: string,
37
+ agentId?: string
38
+ ) => Promise<FetchAgentHistoryResponse>
34
39
  fetchChatApp: (workspaceId?: string) => Promise<ChatApp | null>
35
40
  setChatAppAgent: (chatAppId: string, agentId: string) => Promise<ChatAppAgent>
36
41
  createChatConversation: (
@@ -53,6 +58,15 @@ const throwOnErrorChunk = () =>
53
58
  },
54
59
  })
55
60
 
61
+ const withAgentIdQuery = (url: string, agentId?: string) => {
62
+ if (!agentId) {
63
+ return url
64
+ }
65
+
66
+ const query = new URLSearchParams({ agentId })
67
+ return `${url}?${query.toString()}`
68
+ }
69
+
56
70
  export const buildChatAppEndpoints = (
57
71
  API: BaseAPIClient
58
72
  ): ChatAppEndpoints => ({
@@ -102,19 +116,27 @@ export const buildChatAppEndpoints = (
102
116
 
103
117
  deleteChatConversation: async (
104
118
  chatConversationId: string,
105
- chatAppId: string
119
+ chatAppId: string,
120
+ agentId?: string
106
121
  ) => {
107
122
  return await API.delete({
108
- url: `/api/chatapps/${chatAppId}/conversations/${chatConversationId}`,
123
+ url: withAgentIdQuery(
124
+ `/api/chatapps/${chatAppId}/conversations/${chatConversationId}`,
125
+ agentId
126
+ ),
109
127
  })
110
128
  },
111
129
 
112
130
  fetchChatConversation: async (
113
131
  chatAppId: string,
114
- chatConversationId: string
132
+ chatConversationId: string,
133
+ agentId?: string
115
134
  ) => {
116
135
  return await API.get({
117
- url: `/api/chatapps/${chatAppId}/conversations/${chatConversationId}`,
136
+ url: withAgentIdQuery(
137
+ `/api/chatapps/${chatAppId}/conversations/${chatConversationId}`,
138
+ agentId
139
+ ),
118
140
  })
119
141
  },
120
142
 
@@ -124,9 +146,12 @@ export const buildChatAppEndpoints = (
124
146
  })
125
147
  },
126
148
 
127
- fetchChatHistory: async (chatAppId: string) => {
149
+ fetchChatHistory: async (chatAppId: string, agentId?: string) => {
128
150
  return await API.get({
129
- url: `/api/chatapps/${chatAppId}/conversations`,
151
+ url: withAgentIdQuery(
152
+ `/api/chatapps/${chatAppId}/conversations`,
153
+ agentId
154
+ ),
130
155
  })
131
156
  },
132
157
 
package/src/api/groups.ts CHANGED
@@ -39,6 +39,7 @@ type GetGroupUsersRequest = {
39
39
  id: string
40
40
  bookmark?: string
41
41
  emailSearch?: string
42
+ pageSize?: number
42
43
  }
43
44
 
44
45
  export const buildGroupsEndpoints = (API: BaseAPIClient): GroupEndpoints => {
@@ -101,13 +102,16 @@ export const buildGroupsEndpoints = (API: BaseAPIClient): GroupEndpoints => {
101
102
  /**
102
103
  * Gets a group users by the group id
103
104
  */
104
- getGroupUsers: async ({ id, bookmark, emailSearch }) => {
105
+ getGroupUsers: async ({ id, bookmark, emailSearch, pageSize }) => {
105
106
  let url = `/api/global/groups/${id}/users?`
106
107
  if (bookmark) {
107
108
  url += `bookmark=${bookmark}&`
108
109
  }
109
110
  if (emailSearch) {
110
- url += `emailSearch=${emailSearch}`
111
+ url += `emailSearch=${emailSearch}&`
112
+ }
113
+ if (pageSize != null) {
114
+ url += `pageSize=${pageSize}`
111
115
  }
112
116
  return await API.get({
113
117
  url,
@@ -4,6 +4,13 @@
4
4
  import type { ChatConversation, DraftChatConversation } from "@budibase/types"
5
5
  import Chatbox from "./index.svelte"
6
6
 
7
+ type AgentAvailability =
8
+ | "no_selection"
9
+ | "deleted"
10
+ | "offline"
11
+ | "disabled"
12
+ | "ready"
13
+
7
14
  type ChatConversationLike = ChatConversation | DraftChatConversation
8
15
 
9
16
  type EnabledAgentListItem = {
@@ -17,11 +24,11 @@
17
24
  export let selectedAgentName: string = ""
18
25
  export let enabledAgentList: EnabledAgentListItem[] = []
19
26
  export let conversationStarters: { prompt: string }[] = []
20
- export let isAgentKnown: boolean = true
21
- export let isAgentLive: boolean = true
27
+ export let agentAvailability: AgentAvailability = "ready"
22
28
 
23
29
  export let chat: ChatConversationLike
24
30
  export let loading: boolean = false
31
+ export let suppressAgentPicker: boolean = false
25
32
  export let deletingChat: boolean = false
26
33
  export let workspaceId: string
27
34
  export let initialPrompt: string = ""
@@ -59,40 +66,22 @@
59
66
  $: visibleAgentList = enabledAgentList.slice(0, 3)
60
67
  $: hasEnabledAgents = enabledAgentList.length > 0
61
68
 
62
- const getAgentStatus = (
63
- agentId: string | null,
64
- agents: EnabledAgentListItem[],
65
- agentKnown: boolean,
66
- agentLive: boolean
67
- ): {
68
- isAgentEnabled: boolean
69
- readOnlyReason: "disabled" | "deleted" | "offline" | undefined
70
- } => {
71
- if (!agentId) {
72
- return { isAgentEnabled: false, readOnlyReason: undefined }
73
- }
74
-
75
- if (!agentKnown) {
76
- return { isAgentEnabled: false, readOnlyReason: "deleted" }
77
- }
78
-
79
- if (!agentLive) {
80
- return { isAgentEnabled: false, readOnlyReason: "offline" }
81
- }
82
-
83
- const isAgentEnabled = agents.some(agent => agent.agentId === agentId)
84
- return {
85
- isAgentEnabled,
86
- readOnlyReason: isAgentEnabled ? undefined : "disabled",
69
+ const getReadOnlyReason = (
70
+ availability: AgentAvailability
71
+ ): "disabled" | "deleted" | "offline" | undefined => {
72
+ switch (availability) {
73
+ case "deleted":
74
+ return "deleted"
75
+ case "offline":
76
+ return "offline"
77
+ case "disabled":
78
+ return "disabled"
79
+ default:
80
+ return undefined
87
81
  }
88
82
  }
89
83
 
90
- $: ({ readOnlyReason } = getAgentStatus(
91
- selectedAgentId,
92
- enabledAgentList,
93
- isAgentKnown,
94
- isAgentLive
95
- ))
84
+ $: readOnlyReason = getReadOnlyReason(agentAvailability)
96
85
 
97
86
  const deleteChat = () => {
98
87
  dispatch("deleteChat")
@@ -136,7 +125,7 @@
136
125
  <div class="chat-header">
137
126
  <div class="chat-header-agent">
138
127
  <Body size="S">
139
- {selectedAgentName || "Unknown agent"}
128
+ {selectedAgentName || (loading ? "" : "Unknown agent")}
140
129
  </Body>
141
130
  </div>
142
131
 
@@ -169,7 +158,7 @@
169
158
  {readOnlyReason}
170
159
  onchatsaved={event => dispatch("chatSaved", event.detail)}
171
160
  />
172
- {:else}
161
+ {:else if !suppressAgentPicker}
173
162
  <div class="chat-empty">
174
163
  <div class="chat-empty-greeting">
175
164
  <Body size="XL" weight="600" serif>
@@ -18,6 +18,7 @@
18
18
  export let enabledAgentList: EnabledAgentListItem[] = []
19
19
  export let conversationHistory: ConversationListItem[] = []
20
20
  export let selectedConversationId: string | undefined
21
+ export let hideAgents = false
21
22
 
22
23
  $: defaultAgent =
23
24
  enabledAgentList.find(agent => agent.isDefault) || enabledAgentList[0]
@@ -52,26 +53,28 @@
52
53
  </div>
53
54
  {/if}
54
55
 
55
- <div class="list-section">
56
- <div class="list-title">Agents</div>
57
- {#if enabledAgentList.length}
58
- {#each enabledAgentList as agent (agent.agentId)}
59
- <button
60
- class="list-item list-item-button"
61
- on:click={() => selectAgent(agent.agentId)}
62
- >
63
- <span class="list-item-icon">
64
- <Icon name={agent.icon || "robot"} size="S" />
65
- </span>
66
- {agent.name}
67
- </button>
68
- {/each}
69
- {:else}
70
- <Body size="XS" color="var(--spectrum-global-color-gray-500)">
71
- No agents
72
- </Body>
73
- {/if}
74
- </div>
56
+ {#if !hideAgents}
57
+ <div class="list-section">
58
+ <div class="list-title">Agents</div>
59
+ {#if enabledAgentList.length}
60
+ {#each enabledAgentList as agent (agent.agentId)}
61
+ <button
62
+ class="list-item list-item-button"
63
+ on:click={() => selectAgent(agent.agentId)}
64
+ >
65
+ <span class="list-item-icon">
66
+ <Icon name={agent.icon || "robot"} size="S" />
67
+ </span>
68
+ {agent.name}
69
+ </button>
70
+ {/each}
71
+ {:else}
72
+ <Body size="XS" color="var(--spectrum-global-color-gray-500)">
73
+ No agents
74
+ </Body>
75
+ {/if}
76
+ </div>
77
+ {/if}
75
78
 
76
79
  <div class="list-section">
77
80
  <div class="list-title">Recent Chats</div>
@@ -191,7 +191,10 @@
191
191
  onFinish: async () => {
192
192
  if (persistConversation && !chat._id && chat.chatAppId) {
193
193
  try {
194
- const history = await API.fetchChatHistory(chat.chatAppId)
194
+ const history = await API.fetchChatHistory(
195
+ chat.chatAppId,
196
+ chat.agentId
197
+ )
195
198
  const msgs = chatInstance.messages
196
199
  const lastMessageId = msgs[msgs.length - 1]?.id
197
200
  const savedConversation =
@@ -41,6 +41,7 @@ export default class GroupUserFetch extends BaseDataFetch<
41
41
  }
42
42
 
43
43
  async getData() {
44
+ const { limit } = this.options
44
45
  const { query, cursor } = get(this.store)
45
46
 
46
47
  try {
@@ -48,6 +49,7 @@ export default class GroupUserFetch extends BaseDataFetch<
48
49
  id: query.groupId,
49
50
  emailSearch: query.emailSearch,
50
51
  bookmark: cursor ?? undefined,
52
+ pageSize: limit,
51
53
  })
52
54
 
53
55
  return {