Skip to content

Commit e95a172

Browse files
committed
add logout error handling
1 parent ba0fe64 commit e95a172

File tree

6 files changed

+46
-223
lines changed

6 files changed

+46
-223
lines changed

components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ declare module 'vue' {
3939
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
4040
ElRow: typeof import('element-plus/es')['ElRow']
4141
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
42+
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
43+
ElSkeletonItem: typeof import('element-plus/es')['ElSkeletonItem']
4244
ElText: typeof import('element-plus/es')['ElText']
4345
ElTooltip: typeof import('element-plus/es')['ElTooltip']
4446
GlossarySearchNav: typeof import('./src/components/GlossarySearchNav.vue')['default']

server/controllers/OpeyController.ts

Lines changed: 0 additions & 212 deletions
This file was deleted.

server/controllers/OpeyIIController.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export class OpeyController {
4646
@Res() response: Response,
4747
): Promise<Response> {
4848

49+
if (!session) {
50+
console.error("Session not found")
51+
return response.status(401).json({ error: 'Session Time Out' })
52+
}
4953
// Check if the consent is in the session, and can be added to the headers
5054
const opeyConfig = session['opeyConfig']
5155
if (!opeyConfig) {

src/components/ChatMessage.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ export default {
158158
background-color: #3e4e70;
159159
}
160160
161+
.assistant .error {
162+
color: red;
163+
font-weight: bold;
164+
align-self: flex-start;
165+
font-size: smaller;
166+
}
167+
161168
.content {
162169
margin-top: -10px;
163170
margin-bottom: -10px;

src/components/ToolCall.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,21 @@ export default {
6767
<div class="tool-message-container" v-bind:class="expanded? 'expanded':''">
6868

6969
<div class="tool-message-header">
70-
<div class="status" v-bind:class="status">
71-
<div v-if="status === 'pending'">
72-
<el-icon class="is-loading" color="#20cbeb"><RefreshRight /></el-icon>
70+
<div class="tool-name">Tool Call: {{ name }}</div>
71+
<div class="right-aligned">
72+
<div class="status" v-bind:class="status">
73+
<div v-if="status === 'pending'">
74+
<el-icon class="is-loading" color="#20cbeb"><RefreshRight /></el-icon>
75+
</div>
76+
<div v-else-if="status === 'success'">
77+
<el-icon color="#00ff18"><Check /></el-icon>
78+
</div>
7379
</div>
74-
<div v-else-if="status === 'success'">
75-
<el-icon color="#00ff18"><Check /></el-icon>
80+
<div class="expand-icon" @click="toggleExpanded">
81+
<el-icon><ArrowDown v-if="!expanded" /><ArrowUp v-else /></el-icon>
7682
</div>
7783
</div>
78-
<div class="tool-name">{{ name }}</div>
79-
<div class="expand-icon" @click="toggleExpanded">
80-
<el-icon><ArrowDown v-if="!expanded" /><ArrowUp v-else /></el-icon>
81-
</div>
84+
8285
</div>
8386

8487

@@ -179,16 +182,26 @@ export default {
179182
overflow: auto;
180183
}
181184
182-
185+
.status {
186+
margin-left: auto;
187+
margin-right: 20px;
188+
}
183189
184190
.expand-icon {
185191
margin-left: auto;
186192
cursor: pointer;
187193
}
188194
195+
.right-aligned {
196+
display: flex;
197+
flex-direction: row;
198+
align-items: center;
199+
}
200+
189201
.tool-message-header {
190202
display: flex;
191203
flex-direction: row;
204+
justify-content: space-between;
192205
align-items: center;
193206
width: 100%;
194207
}

src/stores/chat.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,23 @@ export const useChat = defineStore('chat', {
202202
}
203203

204204
if (response.status !== 200) {
205+
switch (response.status) {
206+
case 401:
207+
throw new Error('Unauthorized. Please log in again.');
208+
}
205209
throw new Error(`Error sending Opey message: ${response.statusText}`);
206210
}
207211

208212
await this._processOpeyStream(stream);
209213
} catch (error) {
210214
console.error('Error sending Opey message:', error);
211215

212-
const errorMessage = "Hmmm, Looks like smething went wrong. Please try again later.";
216+
let errorMessage = "Hmmm, Looks like smething went wrong. Please try again later.";
217+
218+
switch (error) {
219+
case 'Unauthorized. Please log in again.':
220+
errorMessage = 'You are not logged in. Please log in to continue.';
221+
}
213222
// Apply error state to the assistant message
214223
await this.applyErrorToMessage(this.currentAssistantMessage.id, errorMessage);
215224

0 commit comments

Comments
 (0)