mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-28 23:35:27 +08:00
Fix computer use session error status
This commit is contained in:
@@ -14,13 +14,13 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 22
|
||||||
cache: npm
|
cache: npm
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
cat release/SHASUMS256.txt
|
cat release/SHASUMS256.txt
|
||||||
|
|
||||||
- name: Upload branch build artifacts
|
- name: Upload branch build artifacts
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.artifact.outputs.name }}
|
name: ${{ steps.artifact.outputs.name }}
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ function encryptSecret(secret) {
|
|||||||
function decryptSecret(record) {
|
function decryptSecret(record) {
|
||||||
if (!record?.value) return null;
|
if (!record?.value) return null;
|
||||||
if (!record.encrypted) return record.value;
|
if (!record.encrypted) return record.value;
|
||||||
return safeStorage.decryptString(Buffer.from(record.value, 'base64'));
|
try {
|
||||||
|
return safeStorage.decryptString(Buffer.from(record.value, 'base64'));
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CloudController {
|
export class CloudController {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
|
||||||
import { computerUseService } from '@/modules/computer-use/computer-use.service.js';
|
import { computerUseService } from '@/modules/computer-use/computer-use.service.js';
|
||||||
|
import { AppError } from '@/shared/utils.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -12,12 +13,30 @@ type AuthenticatedRequest = express.Request & {
|
|||||||
|
|
||||||
function requireUser(req: AuthenticatedRequest): { id: string | number } {
|
function requireUser(req: AuthenticatedRequest): { id: string | number } {
|
||||||
const userId = req.user?.id;
|
const userId = req.user?.id;
|
||||||
if (userId === undefined || userId === null) {
|
if (userId === undefined || userId === null || String(userId).trim() === '') {
|
||||||
throw new Error('Authenticated user is required.');
|
throw new AppError('Authenticated user is required.', {
|
||||||
|
code: 'AUTHENTICATED_USER_REQUIRED',
|
||||||
|
statusCode: 401,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return { id: userId };
|
return { id: userId };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getErrorStatusCode(error: unknown, fallbackStatusCode: number): number {
|
||||||
|
if (error instanceof AppError) {
|
||||||
|
return error.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error && typeof error === 'object') {
|
||||||
|
const statusCode = 'statusCode' in error ? error.statusCode : 'status' in error ? error.status : undefined;
|
||||||
|
if (typeof statusCode === 'number' && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599) {
|
||||||
|
return statusCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fallbackStatusCode;
|
||||||
|
}
|
||||||
|
|
||||||
function readParam(value: string | string[] | undefined): string {
|
function readParam(value: string | string[] | undefined): string {
|
||||||
return Array.isArray(value) ? value[0] || '' : value || '';
|
return Array.isArray(value) ? value[0] || '' : value || '';
|
||||||
}
|
}
|
||||||
@@ -92,7 +111,7 @@ router.get('/sessions', async (req: AuthenticatedRequest, res) => {
|
|||||||
try {
|
try {
|
||||||
res.json({ success: true, data: { sessions: await computerUseService.listSessions(requireUser(req)) } });
|
res.json({ success: true, data: { sessions: await computerUseService.listSessions(requireUser(req)) } });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(401).json({
|
res.status(getErrorStatusCode(error, 500)).json({
|
||||||
success: false,
|
success: false,
|
||||||
error: error instanceof Error ? error.message : 'Failed to list Computer Use sessions.',
|
error: error instanceof Error ? error.message : 'Failed to list Computer Use sessions.',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API & Token",
|
"apiTokens": "API & Token",
|
||||||
"tasks": "Aufgaben",
|
"tasks": "Aufgaben",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "Benachrichtigungen",
|
"notifications": "Benachrichtigungen",
|
||||||
"plugins": "Plugins",
|
"plugins": "Plugins",
|
||||||
"about": "Info"
|
"about": "Info"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API & Tokens",
|
"apiTokens": "API & Tokens",
|
||||||
"tasks": "Tâches",
|
"tasks": "Tâches",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "Notifications",
|
"notifications": "Notifications",
|
||||||
"plugins": "Plugins",
|
"plugins": "Plugins",
|
||||||
"about": "À propos"
|
"about": "À propos"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API e Token",
|
"apiTokens": "API e Token",
|
||||||
"tasks": "Attività",
|
"tasks": "Attività",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "Notifiche",
|
"notifications": "Notifiche",
|
||||||
"plugins": "Plugin",
|
"plugins": "Plugin",
|
||||||
"about": "Informazioni"
|
"about": "Informazioni"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API & トークン",
|
"apiTokens": "API & トークン",
|
||||||
"tasks": "タスク",
|
"tasks": "タスク",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "通知",
|
"notifications": "通知",
|
||||||
"plugins": "プラグイン",
|
"plugins": "プラグイン",
|
||||||
"about": "概要"
|
"about": "概要"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API & 토큰",
|
"apiTokens": "API & 토큰",
|
||||||
"tasks": "작업",
|
"tasks": "작업",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "알림",
|
"notifications": "알림",
|
||||||
"plugins": "플러그인",
|
"plugins": "플러그인",
|
||||||
"about": "정보"
|
"about": "정보"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API и токены",
|
"apiTokens": "API и токены",
|
||||||
"tasks": "Задачи",
|
"tasks": "Задачи",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "Уведомления",
|
"notifications": "Уведомления",
|
||||||
"plugins": "Плагины",
|
"plugins": "Плагины",
|
||||||
"about": "О программе"
|
"about": "О программе"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API ve Token'lar",
|
"apiTokens": "API ve Token'lar",
|
||||||
"tasks": "Görevler",
|
"tasks": "Görevler",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "Bildirimler",
|
"notifications": "Bildirimler",
|
||||||
"plugins": "Eklentiler",
|
"plugins": "Eklentiler",
|
||||||
"about": "Hakkında"
|
"about": "Hakkında"
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API 和令牌",
|
"apiTokens": "API 和令牌",
|
||||||
"tasks": "任务",
|
"tasks": "任务",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "通知",
|
"notifications": "通知",
|
||||||
"plugins": "插件",
|
"plugins": "插件",
|
||||||
"about": "关于"
|
"about": "关于"
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
"files": "檔案",
|
"files": "檔案",
|
||||||
"git": "版本控制",
|
"git": "版本控制",
|
||||||
"tasks": "任務",
|
"tasks": "任務",
|
||||||
"browser": "Browser",
|
"browser": "瀏覽器",
|
||||||
"computer": "Computer"
|
"computer": "電腦"
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"loading": "載入中...",
|
"loading": "載入中...",
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"git": "Git",
|
"git": "Git",
|
||||||
"apiTokens": "API 和權杖",
|
"apiTokens": "API 和權杖",
|
||||||
"tasks": "任務",
|
"tasks": "任務",
|
||||||
|
"computer": "Computer Use",
|
||||||
"notifications": "通知",
|
"notifications": "通知",
|
||||||
"plugins": "外掛",
|
"plugins": "外掛",
|
||||||
"about": "關於"
|
"about": "關於"
|
||||||
|
|||||||
Reference in New Issue
Block a user