Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/(dashboard)/settings/_components/github-status-card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { FaGithub } from 'react-icons/fa'
import { MdCheck } from 'react-icons/md'
import Image from 'next/image'
Expand All @@ -14,11 +14,7 @@ export function GitHubStatusCard() {
const [isLoading, setIsLoading] = useState(true)
const [installation, setInstallation] = useState<GitHubInstallation | null>(null)

useEffect(() => {
loadData()
}, [])

const loadData = async () => {
const loadData = useCallback(async () => {
setIsLoading(true)
try {
const installationsResult = await getInstallations()
Expand All @@ -31,7 +27,11 @@ export function GitHubStatusCard() {
} finally {
setIsLoading(false)
}
}
}, [])

useEffect(() => {
loadData()
}, [loadData])

const handleInstallApp = () => {
const appName = env.NEXT_PUBLIC_GITHUB_APP_NAME
Expand Down
56 changes: 28 additions & 28 deletions components/dialog/settings-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { FaGithub } from 'react-icons/fa';
import { MdCode, MdSave, MdStorage, MdTerminal } from 'react-icons/md';
import Image from 'next/image';
Expand Down Expand Up @@ -100,26 +100,7 @@ export default function SettingsDialog({
const [showSystemPromptResetConfirm, setShowSystemPromptResetConfirm] = useState(false);
const [showAnthropicConfirm, setShowAnthropicConfirm] = useState(false);

// Load data when dialog opens
useEffect(() => {
if (open) {
loadSystemPrompt();
if (!isSealos) {
loadKubeconfig();
}
loadAnthropicConfig();
loadGithubStatus();
}
}, [open, isSealos]);

// Set active tab when defaultTab changes
useEffect(() => {
if (open) {
setActiveTab(defaultTab);
}
}, [open, defaultTab]);

const loadSystemPrompt = async () => {
const loadSystemPrompt = useCallback(async () => {
try {
const data = await fetchClient.GET<{ systemPrompt: string | null }>(
'/api/user/config/system-prompt'
Expand All @@ -131,9 +112,9 @@ export default function SettingsDialog({
} finally {
setIsSystemPromptInitialLoading(false);
}
};
}, []);

const loadKubeconfig = async () => {
const loadKubeconfig = useCallback(async () => {
try {
const data = await fetchClient.GET<{ kubeconfig: string; namespace?: string | null }>(
'/api/user/config/kc'
Expand All @@ -149,9 +130,9 @@ export default function SettingsDialog({
} finally {
setIsKubeconfigInitialLoading(false);
}
};
}, []);

const loadAnthropicConfig = async () => {
const loadAnthropicConfig = useCallback(async () => {
try {
const data = await fetchClient.GET<{
apiKey: string | null;
Expand All @@ -168,9 +149,9 @@ export default function SettingsDialog({
} finally {
setIsAnthropicInitialLoading(false);
}
};
}, []);

const loadGithubStatus = async () => {
const loadGithubStatus = useCallback(async () => {
try {
const result = await getInstallations();
if (result.success && result.data.length > 0) {
Expand All @@ -184,7 +165,26 @@ export default function SettingsDialog({
} finally {
setIsGithubInitialLoading(false);
}
};
}, []);

// Load data when dialog opens
useEffect(() => {
if (open) {
loadSystemPrompt();
if (!isSealos) {
loadKubeconfig();
}
loadAnthropicConfig();
loadGithubStatus();
}
}, [open, isSealos, loadSystemPrompt, loadKubeconfig, loadAnthropicConfig, loadGithubStatus]);

// Set active tab when defaultTab changes
useEffect(() => {
if (open) {
setActiveTab(defaultTab);
}
}, [open, defaultTab]);

const handleSaveSystemPrompt = () => {
setShowSystemPromptConfirm(true);
Expand Down
6 changes: 4 additions & 2 deletions components/terminal/xterm-terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

'use client';

import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
import { MdArrowDownward } from 'react-icons/md';
import type { ITerminalOptions, Terminal as ITerminal } from '@xterm/xterm';
import { toast } from 'sonner';
Expand Down Expand Up @@ -140,6 +140,8 @@ export function XtermTerminal({
enableFileUpload = true,
isVisible = true,
}: XtermTerminalProps) {
const reactId = useId();

// =========================================================================
// State & Refs
// =========================================================================
Expand All @@ -159,7 +161,7 @@ export function XtermTerminal({
const [newLineCount, setNewLineCount] = useState(0);

// Terminal session ID for multi-terminal support
const terminalSessionId = useRef(`terminal-${Date.now()}-${Math.random().toString(36).slice(2)}`);
const terminalSessionId = useRef(`terminal-${reactId.replace(/:/g, '')}`);

// =========================================================================
// File Upload Integration
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
"jsonwebtoken": "^9.0.2",
"lucide-react": "^0.545.0",
"nanoid": "^5.1.6",
"next": "16.0.10",
"next": "16.2.6",
"next-auth": "^5.0.0-beta.29",
"next-themes": "^0.4.6",
"pino": "^10.1.0",
"prisma": "^6.17.1",
"radix-ui": "^1.4.3",
"react": "19.2.1",
"react-dom": "19.2.1",
"react": "19.2.6",
"react-dom": "19.2.6",
"react-icons": "^5.5.0",
"sonner": "^2.0.7",
"tailwind-merge": "^3.3.1",
Expand All @@ -73,12 +73,12 @@
"@tailwindcss/postcss": "^4.3.0",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^20",
"@types/react": "19.2.7",
"@types/react": "19.2.15",
"@types/react-dom": "19.2.3",
"@types/ws": "^8.18.1",
"baseline-browser-mapping": "^2.10.0",
"eslint": "^9",
"eslint-config-next": "16.0.7",
"eslint-config-next": "16.2.6",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.7.4",
Expand All @@ -92,7 +92,7 @@
"overrides": {
"whatwg-url": "^13.0.0",
"tr46": "^4.1.1",
"@types/react": "19.2.7",
"@types/react": "19.2.15",
"@types/react-dom": "19.2.3"
}
},
Expand Down
Loading