@adminforth/agent 1.18.0 → 1.18.1

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/build.log CHANGED
@@ -15,6 +15,7 @@ custom/package.json
15
15
  custom/pnpm-lock.yaml
16
16
  custom/tsconfig.json
17
17
  custom/types.ts
18
+ custom/utils.ts
18
19
  custom/composables/
19
20
  custom/composables/useAgentStore.ts
20
21
  custom/composables/useAgentTransitions.ts
@@ -31,5 +32,5 @@ custom/skills/fetch_data/SKILL.md
31
32
  custom/skills/mutate_data/
32
33
  custom/skills/mutate_data/SKILL.md
33
34
 
34
- sent 185,196 bytes received 432 bytes 371,256.00 bytes/sec
35
- total size is 183,434 speedup is 0.99
35
+ sent 186,137 bytes received 455 bytes 373,184.00 bytes/sec
36
+ total size is 184,285 speedup is 0.99
@@ -23,7 +23,7 @@
23
23
  class="fixed bg-lightNavbar dark:bg-darkNavbar h-screen top-0 right-0 border-x border-b border-gray-200 dark:border-gray-700
24
24
  flex flex z-40"
25
25
  :class="[agentStore.isChatOpen ? 'translate-x-0' : 'translate-x-full', !agentStore.isTeleportedToBody ? 'shadow-2xl' : '']"
26
- :style="{ width: agentStore.chatWidth + 'px' }"
26
+ :style="{ width: agentStore.chatWidth + 'rem' }"
27
27
  >
28
28
  <div
29
29
  v-if="!coreStore.isMobile"
@@ -103,7 +103,7 @@
103
103
  <div
104
104
  class="w-full mb-2 flex items-center justify-center px-2 bg-transparent relative translate-x-[-50%] left-1/2"
105
105
  :style="{
106
- maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
106
+ maxWidth: agentStore.isFullScreen ? remToPx(agentStore.MAX_WIDTH)+'px' : '100%',
107
107
  transition: `transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out`
108
108
  }"
109
109
  >
@@ -185,6 +185,7 @@ import { useAgentStore } from './composables/useAgentStore';
185
185
  import { useAgentTransitions } from './composables/useAgentTransitions';
186
186
  import { Button } from '@/afcl';
187
187
  import { useCoreStore } from '@/stores/core';
188
+ import { remToPx, pxToRem } from './utils';
188
189
 
189
190
  const props = defineProps<{
190
191
  meta: {
@@ -209,7 +210,7 @@ let startWidth = 0
209
210
 
210
211
  const startResize = (e: MouseEvent) => {
211
212
  startX = e.clientX
212
- startWidth = agentStore.chatWidth
213
+ startWidth = remToPx(agentStore.chatWidth)
213
214
 
214
215
  document.body.style.userSelect = 'none'
215
216
  document.body.style.cursor = 'ew-resize'
@@ -220,7 +221,7 @@ const startResize = (e: MouseEvent) => {
220
221
 
221
222
  const onResize = (e: MouseEvent) => {
222
223
  const dx = startX - e.clientX
223
- agentStore.setChatWidth(Math.min(Math.max(startWidth + dx, agentStore.MIN_WIDTH), agentStore.MAX_WIDTH))
224
+ agentStore.setChatWidth(Math.min(Math.max(startWidth + dx, remToPx(agentStore.MIN_WIDTH)), remToPx(agentStore.MAX_WIDTH)))
224
225
  agentTransitions.setChatSurfaceTransition(true);
225
226
  }
226
227
 
@@ -246,7 +247,9 @@ onMounted(async () => {
246
247
  agentStore.setAvailableModes(props.meta.modes, props.meta.defaultModeName);
247
248
  agentStore.regisrerTextInput(textInput.value);
248
249
  textInput.value?.focus();
249
- agentStore.setIsTeleportedToBody(props.meta.stickByDefault);
250
+ const isTeleportedToBodyFromLocalStorage = agentStore.getLocalStorageItem('isTeleportedToBody') === 'true';
251
+
252
+ agentStore.setIsTeleportedToBody(isTeleportedToBodyFromLocalStorage || props.meta.stickByDefault);
250
253
  await agentStore.fetchSessionsList();
251
254
  });
252
255
 
@@ -24,7 +24,7 @@
24
24
  :threshold="10"
25
25
  behavior="smooth"
26
26
  :style="{
27
- maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
27
+ maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'rem' : '100%',
28
28
  transition: `
29
29
  max-width ${agentTransitions.TRANSITION_DURATION}ms ease-in-out,
30
30
  transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out
@@ -8,6 +8,7 @@ import { DefaultChatTransport } from 'ai';
8
8
  import { useCoreStore } from '@/stores/core';
9
9
  import { useAgentTransitions } from './useAgentTransitions';
10
10
  import { useWindowSize } from '@vueuse/core';
11
+ import { remToPx, pxToRem } from '../utils';
11
12
 
12
13
  type AgentMode = {
13
14
  name: string;
@@ -19,9 +20,9 @@ const PLACEHOLDER_DELETING_DELAY_MS = 35;
19
20
  const PLACEHOLDER_HOLD_DELAY_MS = 3000;
20
21
 
21
22
  export const useAgentStore = defineStore('agent', () => {
22
- const DEFAULT_CHAT_WIDTH = 600;
23
- const MAX_WIDTH = 800;
24
- const MIN_WIDTH = 382; //w-96
23
+ const DEFAULT_CHAT_WIDTH = 30;
24
+ const MAX_WIDTH = 60;
25
+ const MIN_WIDTH = 25
25
26
  const agentTransitions = useAgentTransitions();
26
27
 
27
28
  const activeSessionId = ref<string | null>(null);
@@ -71,6 +72,9 @@ export const useAgentStore = defineStore('agent', () => {
71
72
  })
72
73
  watch(chatWidth, (newVal: number) => {
73
74
  setLocalStorageItem('chatWidth', newVal.toString());
75
+ if (!isFullScreen.value) {
76
+ setLocalStorageItem('chatWidthBeforeFullScreen', newVal.toString());
77
+ }
74
78
  })
75
79
  watch(activeSessionId, (newVal: string | null) => {
76
80
  if (newVal) {
@@ -90,14 +94,14 @@ export const useAgentStore = defineStore('agent', () => {
90
94
  onMounted(() => {
91
95
  const chatWidthBeforeFullScreen = parseInt(getLocalStorageItem('chatWidthBeforeFullScreen') || '0', 10);
92
96
  if (chatWidthBeforeFullScreen) {
93
- chatWidth.value = chatWidthBeforeFullScreen;
97
+ setChatWidth(remToPx(chatWidthBeforeFullScreen));
94
98
  } else {
95
99
  const savedChatWidth = parseInt(getLocalStorageItem('chatWidth') || '0', 10);
96
100
  if (savedChatWidth) {
97
101
  if (savedChatWidth > MAX_WIDTH || savedChatWidth < MIN_WIDTH) {
98
- chatWidth.value = DEFAULT_CHAT_WIDTH;
102
+ setChatWidth(remToPx(DEFAULT_CHAT_WIDTH));
99
103
  } else {
100
- chatWidth.value = savedChatWidth;
104
+ setChatWidth(remToPx(savedChatWidth));
101
105
  }
102
106
  }
103
107
  }
@@ -110,7 +114,7 @@ export const useAgentStore = defineStore('agent', () => {
110
114
  isChatOpen.value = getLocalStorageItem('isChatOpen') === 'true';
111
115
  }
112
116
  if (coreStore.isMobile) {
113
- chatWidth.value = window.innerWidth;
117
+ setChatWidth(window.innerWidth);
114
118
  }
115
119
  appRoot.value = document.getElementById('app');
116
120
  header.value = document.getElementById('af-header-nav');
@@ -135,23 +139,24 @@ export const useAgentStore = defineStore('agent', () => {
135
139
  const isTeleportedBeforeFullScreen = getLocalStorageItem('isTeleportedToBodyBeforeFullScreen') === 'true';
136
140
  agentTransitions.setAppRootTransition(true);
137
141
  setIsTeleportedToBody(isTeleportedBeforeFullScreen);
138
- setChatWidth(lastChatWidth, false);
142
+ setChatWidth(remToPx(lastChatWidth), false);
139
143
  setTimeout(() => agentTransitions.setAppRootTransition(false), agentTransitions.TRANSITION_DURATION);
140
144
  }
141
145
  }
142
146
 
147
+ //takes on input width in pixels, converts to rem and sets chat width
143
148
  function setChatWidth(width: number, blockTransition = true) {
144
149
  if (blockTransition) {
145
150
  agentTransitions.setAppRootTransition(true);
146
151
  }
147
- chatWidth.value = width;
152
+ chatWidth.value = pxToRem(width);
148
153
 
149
154
  }
150
155
  watch([isTeleportedToBody, isChatOpen, chatWidth], ([newIsTeleportedToBody, newIsChatOpen, newChatWidth]: [boolean, boolean, number]) => {
151
156
  if (appRoot.value && header.value) {
152
157
  if (newIsTeleportedToBody && newIsChatOpen) {
153
- appRoot.value.style.paddingRight = `${chatWidth.value}px`;
154
- header.value.style.paddingRight = `${chatWidth.value}px`;
158
+ appRoot.value.style.paddingRight = `${remToPx(chatWidth.value)}px`;
159
+ header.value.style.paddingRight = `${remToPx(chatWidth.value)}px`;
155
160
  } else {
156
161
  appRoot.value.style.paddingRight = '';
157
162
  header.value.style.paddingRight = '';
@@ -572,5 +577,6 @@ export const useAgentStore = defineStore('agent', () => {
572
577
  DEFAULT_CHAT_WIDTH,
573
578
  MAX_WIDTH,
574
579
  MIN_WIDTH,
580
+ getLocalStorageItem
575
581
  }
576
582
  })
@@ -0,0 +1,9 @@
1
+ export function remToPx(rem: number): number {
2
+ const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
3
+ return rem * rootFontSize;
4
+ }
5
+
6
+ export function pxToRem(px: number): number {
7
+ const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
8
+ return px / rootFontSize;
9
+ }
@@ -23,7 +23,7 @@
23
23
  class="fixed bg-lightNavbar dark:bg-darkNavbar h-screen top-0 right-0 border-x border-b border-gray-200 dark:border-gray-700
24
24
  flex flex z-40"
25
25
  :class="[agentStore.isChatOpen ? 'translate-x-0' : 'translate-x-full', !agentStore.isTeleportedToBody ? 'shadow-2xl' : '']"
26
- :style="{ width: agentStore.chatWidth + 'px' }"
26
+ :style="{ width: agentStore.chatWidth + 'rem' }"
27
27
  >
28
28
  <div
29
29
  v-if="!coreStore.isMobile"
@@ -103,7 +103,7 @@
103
103
  <div
104
104
  class="w-full mb-2 flex items-center justify-center px-2 bg-transparent relative translate-x-[-50%] left-1/2"
105
105
  :style="{
106
- maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
106
+ maxWidth: agentStore.isFullScreen ? remToPx(agentStore.MAX_WIDTH)+'px' : '100%',
107
107
  transition: `transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out`
108
108
  }"
109
109
  >
@@ -185,6 +185,7 @@ import { useAgentStore } from './composables/useAgentStore';
185
185
  import { useAgentTransitions } from './composables/useAgentTransitions';
186
186
  import { Button } from '@/afcl';
187
187
  import { useCoreStore } from '@/stores/core';
188
+ import { remToPx, pxToRem } from './utils';
188
189
 
189
190
  const props = defineProps<{
190
191
  meta: {
@@ -209,7 +210,7 @@ let startWidth = 0
209
210
 
210
211
  const startResize = (e: MouseEvent) => {
211
212
  startX = e.clientX
212
- startWidth = agentStore.chatWidth
213
+ startWidth = remToPx(agentStore.chatWidth)
213
214
 
214
215
  document.body.style.userSelect = 'none'
215
216
  document.body.style.cursor = 'ew-resize'
@@ -220,7 +221,7 @@ const startResize = (e: MouseEvent) => {
220
221
 
221
222
  const onResize = (e: MouseEvent) => {
222
223
  const dx = startX - e.clientX
223
- agentStore.setChatWidth(Math.min(Math.max(startWidth + dx, agentStore.MIN_WIDTH), agentStore.MAX_WIDTH))
224
+ agentStore.setChatWidth(Math.min(Math.max(startWidth + dx, remToPx(agentStore.MIN_WIDTH)), remToPx(agentStore.MAX_WIDTH)))
224
225
  agentTransitions.setChatSurfaceTransition(true);
225
226
  }
226
227
 
@@ -246,7 +247,9 @@ onMounted(async () => {
246
247
  agentStore.setAvailableModes(props.meta.modes, props.meta.defaultModeName);
247
248
  agentStore.regisrerTextInput(textInput.value);
248
249
  textInput.value?.focus();
249
- agentStore.setIsTeleportedToBody(props.meta.stickByDefault);
250
+ const isTeleportedToBodyFromLocalStorage = agentStore.getLocalStorageItem('isTeleportedToBody') === 'true';
251
+
252
+ agentStore.setIsTeleportedToBody(isTeleportedToBodyFromLocalStorage || props.meta.stickByDefault);
250
253
  await agentStore.fetchSessionsList();
251
254
  });
252
255
 
@@ -24,7 +24,7 @@
24
24
  :threshold="10"
25
25
  behavior="smooth"
26
26
  :style="{
27
- maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'px' : '100%',
27
+ maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'rem' : '100%',
28
28
  transition: `
29
29
  max-width ${agentTransitions.TRANSITION_DURATION}ms ease-in-out,
30
30
  transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out
@@ -8,6 +8,7 @@ import { DefaultChatTransport } from 'ai';
8
8
  import { useCoreStore } from '@/stores/core';
9
9
  import { useAgentTransitions } from './useAgentTransitions';
10
10
  import { useWindowSize } from '@vueuse/core';
11
+ import { remToPx, pxToRem } from '../utils';
11
12
 
12
13
  type AgentMode = {
13
14
  name: string;
@@ -19,9 +20,9 @@ const PLACEHOLDER_DELETING_DELAY_MS = 35;
19
20
  const PLACEHOLDER_HOLD_DELAY_MS = 3000;
20
21
 
21
22
  export const useAgentStore = defineStore('agent', () => {
22
- const DEFAULT_CHAT_WIDTH = 600;
23
- const MAX_WIDTH = 800;
24
- const MIN_WIDTH = 382; //w-96
23
+ const DEFAULT_CHAT_WIDTH = 30;
24
+ const MAX_WIDTH = 60;
25
+ const MIN_WIDTH = 25
25
26
  const agentTransitions = useAgentTransitions();
26
27
 
27
28
  const activeSessionId = ref<string | null>(null);
@@ -71,6 +72,9 @@ export const useAgentStore = defineStore('agent', () => {
71
72
  })
72
73
  watch(chatWidth, (newVal: number) => {
73
74
  setLocalStorageItem('chatWidth', newVal.toString());
75
+ if (!isFullScreen.value) {
76
+ setLocalStorageItem('chatWidthBeforeFullScreen', newVal.toString());
77
+ }
74
78
  })
75
79
  watch(activeSessionId, (newVal: string | null) => {
76
80
  if (newVal) {
@@ -90,14 +94,14 @@ export const useAgentStore = defineStore('agent', () => {
90
94
  onMounted(() => {
91
95
  const chatWidthBeforeFullScreen = parseInt(getLocalStorageItem('chatWidthBeforeFullScreen') || '0', 10);
92
96
  if (chatWidthBeforeFullScreen) {
93
- chatWidth.value = chatWidthBeforeFullScreen;
97
+ setChatWidth(remToPx(chatWidthBeforeFullScreen));
94
98
  } else {
95
99
  const savedChatWidth = parseInt(getLocalStorageItem('chatWidth') || '0', 10);
96
100
  if (savedChatWidth) {
97
101
  if (savedChatWidth > MAX_WIDTH || savedChatWidth < MIN_WIDTH) {
98
- chatWidth.value = DEFAULT_CHAT_WIDTH;
102
+ setChatWidth(remToPx(DEFAULT_CHAT_WIDTH));
99
103
  } else {
100
- chatWidth.value = savedChatWidth;
104
+ setChatWidth(remToPx(savedChatWidth));
101
105
  }
102
106
  }
103
107
  }
@@ -110,7 +114,7 @@ export const useAgentStore = defineStore('agent', () => {
110
114
  isChatOpen.value = getLocalStorageItem('isChatOpen') === 'true';
111
115
  }
112
116
  if (coreStore.isMobile) {
113
- chatWidth.value = window.innerWidth;
117
+ setChatWidth(window.innerWidth);
114
118
  }
115
119
  appRoot.value = document.getElementById('app');
116
120
  header.value = document.getElementById('af-header-nav');
@@ -135,23 +139,24 @@ export const useAgentStore = defineStore('agent', () => {
135
139
  const isTeleportedBeforeFullScreen = getLocalStorageItem('isTeleportedToBodyBeforeFullScreen') === 'true';
136
140
  agentTransitions.setAppRootTransition(true);
137
141
  setIsTeleportedToBody(isTeleportedBeforeFullScreen);
138
- setChatWidth(lastChatWidth, false);
142
+ setChatWidth(remToPx(lastChatWidth), false);
139
143
  setTimeout(() => agentTransitions.setAppRootTransition(false), agentTransitions.TRANSITION_DURATION);
140
144
  }
141
145
  }
142
146
 
147
+ //takes on input width in pixels, converts to rem and sets chat width
143
148
  function setChatWidth(width: number, blockTransition = true) {
144
149
  if (blockTransition) {
145
150
  agentTransitions.setAppRootTransition(true);
146
151
  }
147
- chatWidth.value = width;
152
+ chatWidth.value = pxToRem(width);
148
153
 
149
154
  }
150
155
  watch([isTeleportedToBody, isChatOpen, chatWidth], ([newIsTeleportedToBody, newIsChatOpen, newChatWidth]: [boolean, boolean, number]) => {
151
156
  if (appRoot.value && header.value) {
152
157
  if (newIsTeleportedToBody && newIsChatOpen) {
153
- appRoot.value.style.paddingRight = `${chatWidth.value}px`;
154
- header.value.style.paddingRight = `${chatWidth.value}px`;
158
+ appRoot.value.style.paddingRight = `${remToPx(chatWidth.value)}px`;
159
+ header.value.style.paddingRight = `${remToPx(chatWidth.value)}px`;
155
160
  } else {
156
161
  appRoot.value.style.paddingRight = '';
157
162
  header.value.style.paddingRight = '';
@@ -572,5 +577,6 @@ export const useAgentStore = defineStore('agent', () => {
572
577
  DEFAULT_CHAT_WIDTH,
573
578
  MAX_WIDTH,
574
579
  MIN_WIDTH,
580
+ getLocalStorageItem
575
581
  }
576
582
  })
@@ -0,0 +1,9 @@
1
+ export function remToPx(rem: number): number {
2
+ const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
3
+ return rem * rootFontSize;
4
+ }
5
+
6
+ export function pxToRem(px: number): number {
7
+ const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
8
+ return px / rootFontSize;
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "1.18.0",
3
+ "version": "1.18.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",