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