8 Commits

Author SHA1 Message Date
simos
18d0874142 feat: auto-populate git config from system 2025-11-17 18:05:49 +01:00
simos
33e70c4b55 feat: load git config during onboarding 2025-11-17 16:17:05 +01:00
simos
98c8b14b4f fix: cleanup settings 2025-11-17 16:16:49 +01:00
simos
544c72434a fix: initial commit error 2025-11-17 15:54:08 +01:00
simos
b892985700 small fix 2025-11-17 15:30:22 +01:00
simos
8c629a1a05 feat: onboarding page & adding git settings 2025-11-17 15:26:46 +01:00
simos
2df8c8e786 fix:identify claude login status 2025-11-17 14:20:10 +01:00
simos
f91f9f702d fix: settings api calls that would fail. 2025-11-17 13:58:58 +01:00
20 changed files with 1292 additions and 382 deletions

View File

@@ -55,12 +55,40 @@ if (process.env.DATABASE_PATH) {
console.log(c.dim('═'.repeat(60))); console.log(c.dim('═'.repeat(60)));
console.log(''); console.log('');
const runMigrations = () => {
try {
const tableInfo = db.prepare("PRAGMA table_info(users)").all();
const columnNames = tableInfo.map(col => col.name);
if (!columnNames.includes('git_name')) {
console.log('Running migration: Adding git_name column');
db.exec('ALTER TABLE users ADD COLUMN git_name TEXT');
}
if (!columnNames.includes('git_email')) {
console.log('Running migration: Adding git_email column');
db.exec('ALTER TABLE users ADD COLUMN git_email TEXT');
}
if (!columnNames.includes('has_completed_onboarding')) {
console.log('Running migration: Adding has_completed_onboarding column');
db.exec('ALTER TABLE users ADD COLUMN has_completed_onboarding BOOLEAN DEFAULT 0');
}
console.log('Database migrations completed successfully');
} catch (error) {
console.error('Error running migrations:', error.message);
throw error;
}
};
// Initialize database with schema // Initialize database with schema
const initializeDatabase = async () => { const initializeDatabase = async () => {
try { try {
const initSQL = fs.readFileSync(INIT_SQL_PATH, 'utf8'); const initSQL = fs.readFileSync(INIT_SQL_PATH, 'utf8');
db.exec(initSQL); db.exec(initSQL);
console.log('Database initialized successfully'); console.log('Database initialized successfully');
runMigrations();
} catch (error) { } catch (error) {
console.error('Error initializing database:', error.message); console.error('Error initializing database:', error.message);
throw error; throw error;
@@ -126,6 +154,42 @@ const userDb = {
} catch (err) { } catch (err) {
throw err; throw err;
} }
},
updateGitConfig: (userId, gitName, gitEmail) => {
try {
const stmt = db.prepare('UPDATE users SET git_name = ?, git_email = ? WHERE id = ?');
stmt.run(gitName, gitEmail, userId);
} catch (err) {
throw err;
}
},
getGitConfig: (userId) => {
try {
const row = db.prepare('SELECT git_name, git_email FROM users WHERE id = ?').get(userId);
return row;
} catch (err) {
throw err;
}
},
completeOnboarding: (userId) => {
try {
const stmt = db.prepare('UPDATE users SET has_completed_onboarding = 1 WHERE id = ?');
stmt.run(userId);
} catch (err) {
throw err;
}
},
hasCompletedOnboarding: (userId) => {
try {
const row = db.prepare('SELECT has_completed_onboarding FROM users WHERE id = ?').get(userId);
return row?.has_completed_onboarding === 1;
} catch (err) {
throw err;
}
} }
}; };

View File

@@ -8,7 +8,10 @@ CREATE TABLE IF NOT EXISTS users (
password_hash TEXT NOT NULL, password_hash TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP, created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
last_login DATETIME, last_login DATETIME,
is_active BOOLEAN DEFAULT 1 is_active BOOLEAN DEFAULT 1,
git_name TEXT,
git_email TEXT,
has_completed_onboarding BOOLEAN DEFAULT 0
); );
-- Indexes for performance -- Indexes for performance

View File

@@ -71,6 +71,7 @@ import settingsRoutes from './routes/settings.js';
import agentRoutes from './routes/agent.js'; import agentRoutes from './routes/agent.js';
import projectsRoutes from './routes/projects.js'; import projectsRoutes from './routes/projects.js';
import cliAuthRoutes from './routes/cli-auth.js'; import cliAuthRoutes from './routes/cli-auth.js';
import userRoutes from './routes/user.js';
import { initializeDatabase } from './database/db.js'; import { initializeDatabase } from './database/db.js';
import { validateApiKey, authenticateToken, authenticateWebSocket } from './middleware/auth.js'; import { validateApiKey, authenticateToken, authenticateWebSocket } from './middleware/auth.js';
@@ -254,6 +255,9 @@ app.use('/api/settings', authenticateToken, settingsRoutes);
// CLI Authentication API Routes (protected) // CLI Authentication API Routes (protected)
app.use('/api/cli', authenticateToken, cliAuthRoutes); app.use('/api/cli', authenticateToken, cliAuthRoutes);
// User API Routes (protected)
app.use('/api/user', authenticateToken, userRoutes);
// Agent API Routes (uses API key authentication) // Agent API Routes (uses API key authentication)
app.use('/api/agent', agentRoutes); app.use('/api/agent', agentRoutes);

View File

@@ -60,8 +60,9 @@ async function checkClaudeCredentials() {
const content = await fs.readFile(credPath, 'utf8'); const content = await fs.readFile(credPath, 'utf8');
const creds = JSON.parse(content); const creds = JSON.parse(content);
if (creds.accessToken) { const oauth = creds.claudeAiOauth;
const isExpired = creds.expiresAt && Date.now() >= creds.expiresAt; if (oauth && oauth.accessToken) {
const isExpired = oauth.expiresAt && Date.now() >= oauth.expiresAt;
if (!isExpired) { if (!isExpired) {
return { return {

View File

@@ -91,8 +91,21 @@ router.get('/status', async (req, res) => {
// Validate git repository // Validate git repository
await validateGitRepository(projectPath); await validateGitRepository(projectPath);
// Get current branch // Get current branch - handle case where there are no commits yet
const { stdout: branch } = await execAsync('git rev-parse --abbrev-ref HEAD', { cwd: projectPath }); let branch = 'main';
let hasCommits = true;
try {
const { stdout: branchOutput } = await execAsync('git rev-parse --abbrev-ref HEAD', { cwd: projectPath });
branch = branchOutput.trim();
} catch (error) {
// No HEAD exists - repository has no commits yet
if (error.message.includes('unknown revision') || error.message.includes('ambiguous argument')) {
hasCommits = false;
branch = 'main';
} else {
throw error;
}
}
// Get git status // Get git status
const { stdout: statusOutput } = await execAsync('git status --porcelain', { cwd: projectPath }); const { stdout: statusOutput } = await execAsync('git status --porcelain', { cwd: projectPath });
@@ -120,7 +133,8 @@ router.get('/status', async (req, res) => {
}); });
res.json({ res.json({
branch: branch.trim(), branch,
hasCommits,
modified, modified,
added, added,
deleted, deleted,
@@ -264,6 +278,50 @@ router.get('/file-with-diff', async (req, res) => {
} }
}); });
// Create initial commit
router.post('/initial-commit', async (req, res) => {
const { project } = req.body;
if (!project) {
return res.status(400).json({ error: 'Project name is required' });
}
try {
const projectPath = await getActualProjectPath(project);
// Validate git repository
await validateGitRepository(projectPath);
// Check if there are already commits
try {
await execAsync('git rev-parse HEAD', { cwd: projectPath });
return res.status(400).json({ error: 'Repository already has commits. Use regular commit instead.' });
} catch (error) {
// No HEAD - this is good, we can create initial commit
}
// Add all files
await execAsync('git add .', { cwd: projectPath });
// Create initial commit
const { stdout } = await execAsync('git commit -m "Initial commit"', { cwd: projectPath });
res.json({ success: true, output: stdout, message: 'Initial commit created successfully' });
} catch (error) {
console.error('Git initial commit error:', error);
// Handle the case where there's nothing to commit
if (error.message.includes('nothing to commit')) {
return res.status(400).json({
error: 'Nothing to commit',
details: 'No files found in the repository. Add some files first.'
});
}
res.status(500).json({ error: error.message });
}
});
// Commit changes // Commit changes
router.post('/commit', async (req, res) => { router.post('/commit', async (req, res) => {
const { project, message, files } = req.body; const { project, message, files } = req.body;

View File

@@ -528,7 +528,8 @@ router.get('/next/:projectName', async (req, res) => {
console.warn('Failed to execute task-master CLI:', cliError.message); console.warn('Failed to execute task-master CLI:', cliError.message);
// Fallback to loading tasks and finding next one locally // Fallback to loading tasks and finding next one locally
const tasksResponse = await fetch(`${req.protocol}://${req.get('host')}/api/taskmaster/tasks/${encodeURIComponent(projectName)}`, { // Use localhost to bypass proxy for internal server-to-server calls
const tasksResponse = await fetch(`http://localhost:${process.env.PORT || 3001}/api/taskmaster/tasks/${encodeURIComponent(projectName)}`, {
headers: { headers: {
'Authorization': req.headers.authorization 'Authorization': req.headers.authorization
} }

106
server/routes/user.js Normal file
View File

@@ -0,0 +1,106 @@
import express from 'express';
import { userDb } from '../database/db.js';
import { authenticateToken } from '../middleware/auth.js';
import { getSystemGitConfig } from '../utils/gitConfig.js';
import { exec } from 'child_process';
import { promisify } from 'util';
const execAsync = promisify(exec);
const router = express.Router();
router.get('/git-config', authenticateToken, async (req, res) => {
try {
const userId = req.user.id;
let gitConfig = userDb.getGitConfig(userId);
// If database is empty, try to get from system git config
if (!gitConfig || (!gitConfig.git_name && !gitConfig.git_email)) {
const systemConfig = await getSystemGitConfig();
// If system has values, save them to database for this user
if (systemConfig.git_name || systemConfig.git_email) {
userDb.updateGitConfig(userId, systemConfig.git_name, systemConfig.git_email);
gitConfig = systemConfig;
console.log(`Auto-populated git config from system for user ${userId}: ${systemConfig.git_name} <${systemConfig.git_email}>`);
}
}
res.json({
success: true,
gitName: gitConfig?.git_name || null,
gitEmail: gitConfig?.git_email || null
});
} catch (error) {
console.error('Error getting git config:', error);
res.status(500).json({ error: 'Failed to get git configuration' });
}
});
// Apply git config globally via git config --global
router.post('/git-config', authenticateToken, async (req, res) => {
try {
const userId = req.user.id;
const { gitName, gitEmail } = req.body;
if (!gitName || !gitEmail) {
return res.status(400).json({ error: 'Git name and email are required' });
}
// Validate email format
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(gitEmail)) {
return res.status(400).json({ error: 'Invalid email format' });
}
userDb.updateGitConfig(userId, gitName, gitEmail);
try {
await execAsync(`git config --global user.name "${gitName.replace(/"/g, '\\"')}"`);
await execAsync(`git config --global user.email "${gitEmail.replace(/"/g, '\\"')}"`);
console.log(`Applied git config globally: ${gitName} <${gitEmail}>`);
} catch (gitError) {
console.error('Error applying git config:', gitError);
}
res.json({
success: true,
gitName,
gitEmail
});
} catch (error) {
console.error('Error updating git config:', error);
res.status(500).json({ error: 'Failed to update git configuration' });
}
});
router.post('/complete-onboarding', authenticateToken, async (req, res) => {
try {
const userId = req.user.id;
userDb.completeOnboarding(userId);
res.json({
success: true,
message: 'Onboarding completed successfully'
});
} catch (error) {
console.error('Error completing onboarding:', error);
res.status(500).json({ error: 'Failed to complete onboarding' });
}
});
router.get('/onboarding-status', authenticateToken, async (req, res) => {
try {
const userId = req.user.id;
const hasCompleted = userDb.hasCompletedOnboarding(userId);
res.json({
success: true,
hasCompletedOnboarding: hasCompleted
});
} catch (error) {
console.error('Error checking onboarding status:', error);
res.status(500).json({ error: 'Failed to check onboarding status' });
}
});
export default router;

24
server/utils/gitConfig.js Normal file
View File

@@ -0,0 +1,24 @@
import { exec } from 'child_process';
import { promisify } from 'util';
const execAsync = promisify(exec);
/**
* Read git configuration from system's global git config
* @returns {Promise<{git_name: string|null, git_email: string|null}>}
*/
export async function getSystemGitConfig() {
try {
const [nameResult, emailResult] = await Promise.all([
execAsync('git config --global user.name').catch(() => ({ stdout: '' })),
execAsync('git config --global user.email').catch(() => ({ stdout: '' }))
]);
return {
git_name: nameResult.stdout.trim() || null,
git_email: emailResult.stdout.trim() || null
};
} catch (error) {
return { git_name: null, git_email: null };
}
}

View File

@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import { Button } from './ui/button'; import { Button } from './ui/button';
import { Input } from './ui/input'; import { Input } from './ui/input';
import { Key, Plus, Trash2, Eye, EyeOff, Copy, Check, Github } from 'lucide-react'; import { Key, Plus, Trash2, Eye, EyeOff, Copy, Check, Github } from 'lucide-react';
import { authenticatedFetch } from '../utils/api';
function ApiKeysSettings() { function ApiKeysSettings() {
const [apiKeys, setApiKeys] = useState([]); const [apiKeys, setApiKeys] = useState([]);
@@ -23,19 +24,14 @@ function ApiKeysSettings() {
const fetchData = async () => { const fetchData = async () => {
try { try {
setLoading(true); setLoading(true);
const token = localStorage.getItem('auth-token');
// Fetch API keys // Fetch API keys
const apiKeysRes = await fetch('/api/settings/api-keys', { const apiKeysRes = await authenticatedFetch('/api/settings/api-keys');
headers: { 'Authorization': `Bearer ${token}` }
});
const apiKeysData = await apiKeysRes.json(); const apiKeysData = await apiKeysRes.json();
setApiKeys(apiKeysData.apiKeys || []); setApiKeys(apiKeysData.apiKeys || []);
// Fetch GitHub tokens // Fetch GitHub tokens
const githubRes = await fetch('/api/settings/credentials?type=github_token', { const githubRes = await authenticatedFetch('/api/settings/credentials?type=github_token');
headers: { 'Authorization': `Bearer ${token}` }
});
const githubData = await githubRes.json(); const githubData = await githubRes.json();
setGithubTokens(githubData.credentials || []); setGithubTokens(githubData.credentials || []);
} catch (error) { } catch (error) {
@@ -49,13 +45,8 @@ function ApiKeysSettings() {
if (!newKeyName.trim()) return; if (!newKeyName.trim()) return;
try { try {
const token = localStorage.getItem('auth-token'); const res = await authenticatedFetch('/api/settings/api-keys', {
const res = await fetch('/api/settings/api-keys', {
method: 'POST', method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ keyName: newKeyName }) body: JSON.stringify({ keyName: newKeyName })
}); });
@@ -75,10 +66,8 @@ function ApiKeysSettings() {
if (!confirm('Are you sure you want to delete this API key?')) return; if (!confirm('Are you sure you want to delete this API key?')) return;
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/api-keys/${keyId}`, {
await fetch(`/api/settings/api-keys/${keyId}`, { method: 'DELETE'
method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` }
}); });
fetchData(); fetchData();
} catch (error) { } catch (error) {
@@ -88,13 +77,8 @@ function ApiKeysSettings() {
const toggleApiKey = async (keyId, isActive) => { const toggleApiKey = async (keyId, isActive) => {
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/api-keys/${keyId}/toggle`, {
await fetch(`/api/settings/api-keys/${keyId}/toggle`, {
method: 'PATCH', method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ isActive: !isActive }) body: JSON.stringify({ isActive: !isActive })
}); });
fetchData(); fetchData();
@@ -107,13 +91,8 @@ function ApiKeysSettings() {
if (!newTokenName.trim() || !newGithubToken.trim()) return; if (!newTokenName.trim() || !newGithubToken.trim()) return;
try { try {
const token = localStorage.getItem('auth-token'); const res = await authenticatedFetch('/api/settings/credentials', {
const res = await fetch('/api/settings/credentials', {
method: 'POST', method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body: JSON.stringify({
credentialName: newTokenName, credentialName: newTokenName,
credentialType: 'github_token', credentialType: 'github_token',
@@ -137,10 +116,8 @@ function ApiKeysSettings() {
if (!confirm('Are you sure you want to delete this GitHub token?')) return; if (!confirm('Are you sure you want to delete this GitHub token?')) return;
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/credentials/${tokenId}`, {
await fetch(`/api/settings/credentials/${tokenId}`, { method: 'DELETE'
method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` }
}); });
fetchData(); fetchData();
} catch (error) { } catch (error) {
@@ -150,13 +127,8 @@ function ApiKeysSettings() {
const toggleGithubToken = async (tokenId, isActive) => { const toggleGithubToken = async (tokenId, isActive) => {
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/credentials/${tokenId}/toggle`, {
await fetch(`/api/settings/credentials/${tokenId}/toggle`, {
method: 'PATCH', method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ isActive: !isActive }) body: JSON.stringify({ isActive: !isActive })
}); });
fetchData(); fetchData();

View File

@@ -1728,11 +1728,7 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess
// Load Cursor default model from config // Load Cursor default model from config
useEffect(() => { useEffect(() => {
if (provider === 'cursor') { if (provider === 'cursor') {
fetch('/api/cursor/config', { authenticatedFetch('/api/cursor/config')
headers: {
'Authorization': `Bearer ${localStorage.getItem('auth-token')}`
}
})
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
if (data.success && data.config?.model?.modelId) { if (data.success && data.config?.model?.modelId) {
@@ -3752,15 +3748,9 @@ function ChatInterface({ selectedProject, selectedSession, ws, sendMessage, mess
}); });
try { try {
const token = safeLocalStorage.getItem('auth-token'); const response = await authenticatedFetch(`/api/projects/${selectedProject.name}/upload-images`, {
const headers = {};
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
const response = await fetch(`/api/projects/${selectedProject.name}/upload-images`, {
method: 'POST', method: 'POST',
headers: headers, headers: {}, // Let browser set Content-Type for FormData
body: formData body: formData
}); });

View File

@@ -4,6 +4,7 @@ import { Input } from './ui/input';
import { Key, Plus, Trash2, Eye, EyeOff, Copy, Check, Github, ExternalLink } from 'lucide-react'; import { Key, Plus, Trash2, Eye, EyeOff, Copy, Check, Github, ExternalLink } from 'lucide-react';
import { useVersionCheck } from '../hooks/useVersionCheck'; import { useVersionCheck } from '../hooks/useVersionCheck';
import { version } from '../../package.json'; import { version } from '../../package.json';
import { authenticatedFetch } from '../utils/api';
function CredentialsSettings() { function CredentialsSettings() {
const [apiKeys, setApiKeys] = useState([]); const [apiKeys, setApiKeys] = useState([]);
@@ -29,19 +30,14 @@ function CredentialsSettings() {
const fetchData = async () => { const fetchData = async () => {
try { try {
setLoading(true); setLoading(true);
const token = localStorage.getItem('auth-token');
// Fetch API keys // Fetch API keys
const apiKeysRes = await fetch('/api/settings/api-keys', { const apiKeysRes = await authenticatedFetch('/api/settings/api-keys');
headers: { 'Authorization': `Bearer ${token}` }
});
const apiKeysData = await apiKeysRes.json(); const apiKeysData = await apiKeysRes.json();
setApiKeys(apiKeysData.apiKeys || []); setApiKeys(apiKeysData.apiKeys || []);
// Fetch GitHub credentials only // Fetch GitHub credentials only
const credentialsRes = await fetch('/api/settings/credentials?type=github_token', { const credentialsRes = await authenticatedFetch('/api/settings/credentials?type=github_token');
headers: { 'Authorization': `Bearer ${token}` }
});
const credentialsData = await credentialsRes.json(); const credentialsData = await credentialsRes.json();
setGithubCredentials(credentialsData.credentials || []); setGithubCredentials(credentialsData.credentials || []);
} catch (error) { } catch (error) {
@@ -55,13 +51,8 @@ function CredentialsSettings() {
if (!newKeyName.trim()) return; if (!newKeyName.trim()) return;
try { try {
const token = localStorage.getItem('auth-token'); const res = await authenticatedFetch('/api/settings/api-keys', {
const res = await fetch('/api/settings/api-keys', {
method: 'POST', method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ keyName: newKeyName }) body: JSON.stringify({ keyName: newKeyName })
}); });
@@ -81,10 +72,8 @@ function CredentialsSettings() {
if (!confirm('Are you sure you want to delete this API key?')) return; if (!confirm('Are you sure you want to delete this API key?')) return;
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/api-keys/${keyId}`, {
await fetch(`/api/settings/api-keys/${keyId}`, { method: 'DELETE'
method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` }
}); });
fetchData(); fetchData();
} catch (error) { } catch (error) {
@@ -94,13 +83,8 @@ function CredentialsSettings() {
const toggleApiKey = async (keyId, isActive) => { const toggleApiKey = async (keyId, isActive) => {
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/api-keys/${keyId}/toggle`, {
await fetch(`/api/settings/api-keys/${keyId}/toggle`, {
method: 'PATCH', method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ isActive: !isActive }) body: JSON.stringify({ isActive: !isActive })
}); });
fetchData(); fetchData();
@@ -113,13 +97,8 @@ function CredentialsSettings() {
if (!newGithubName.trim() || !newGithubToken.trim()) return; if (!newGithubName.trim() || !newGithubToken.trim()) return;
try { try {
const token = localStorage.getItem('auth-token'); const res = await authenticatedFetch('/api/settings/credentials', {
const res = await fetch('/api/settings/credentials', {
method: 'POST', method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body: JSON.stringify({
credentialName: newGithubName, credentialName: newGithubName,
credentialType: 'github_token', credentialType: 'github_token',
@@ -145,10 +124,8 @@ function CredentialsSettings() {
if (!confirm('Are you sure you want to delete this GitHub token?')) return; if (!confirm('Are you sure you want to delete this GitHub token?')) return;
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/credentials/${credentialId}`, {
await fetch(`/api/settings/credentials/${credentialId}`, { method: 'DELETE'
method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` }
}); });
fetchData(); fetchData();
} catch (error) { } catch (error) {
@@ -158,13 +135,8 @@ function CredentialsSettings() {
const toggleGithubCredential = async (credentialId, isActive) => { const toggleGithubCredential = async (credentialId, isActive) => {
try { try {
const token = localStorage.getItem('auth-token'); await authenticatedFetch(`/api/settings/credentials/${credentialId}/toggle`, {
await fetch(`/api/settings/credentials/${credentialId}/toggle`, {
method: 'PATCH', method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ isActive: !isActive }) body: JSON.stringify({ isActive: !isActive })
}); });
fetchData(); fetchData();

View File

@@ -32,6 +32,7 @@ function GitPanel({ selectedProject, isMobile, onFileOpen }) {
const [isPublishing, setIsPublishing] = useState(false); const [isPublishing, setIsPublishing] = useState(false);
const [isCommitAreaCollapsed, setIsCommitAreaCollapsed] = useState(isMobile); // Collapsed by default on mobile const [isCommitAreaCollapsed, setIsCommitAreaCollapsed] = useState(isMobile); // Collapsed by default on mobile
const [confirmAction, setConfirmAction] = useState(null); // { type: 'discard|commit|pull|push', file?: string, message?: string } const [confirmAction, setConfirmAction] = useState(null); // { type: 'discard|commit|pull|push', file?: string, message?: string }
const [isCreatingInitialCommit, setIsCreatingInitialCommit] = useState(false);
const textareaRef = useRef(null); const textareaRef = useRef(null);
const dropdownRef = useRef(null); const dropdownRef = useRef(null);
@@ -577,6 +578,32 @@ function GitPanel({ selectedProject, isMobile, onFileOpen }) {
} }
}; };
const createInitialCommit = async () => {
setIsCreatingInitialCommit(true);
try {
const response = await authenticatedFetch('/api/git/initial-commit', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project: selectedProject.name
})
});
const data = await response.json();
if (data.success) {
fetchGitStatus();
fetchRemoteStatus();
} else {
console.error('Initial commit failed:', data.error);
alert(data.error || 'Failed to create initial commit');
}
} catch (error) {
console.error('Error creating initial commit:', error);
alert('Failed to create initial commit');
} finally {
setIsCreatingInitialCommit(false);
}
};
const getStatusLabel = (status) => { const getStatusLabel = (status) => {
switch (status) { switch (status) {
@@ -1161,6 +1188,31 @@ function GitPanel({ selectedProject, isMobile, onFileOpen }) {
<div className="flex items-center justify-center h-32"> <div className="flex items-center justify-center h-32">
<RefreshCw className="w-6 h-6 animate-spin text-gray-400" /> <RefreshCw className="w-6 h-6 animate-spin text-gray-400" />
</div> </div>
) : gitStatus?.hasCommits === false ? (
<div className="flex flex-col items-center justify-center p-8 text-center">
<GitBranch className="w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500" />
<h3 className="text-lg font-medium mb-2 text-gray-900 dark:text-white">No commits yet</h3>
<p className="text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md">
This repository doesn't have any commits yet. Create your first commit to start tracking changes.
</p>
<button
onClick={createInitialCommit}
disabled={isCreatingInitialCommit}
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
>
{isCreatingInitialCommit ? (
<>
<RefreshCw className="w-4 h-4 animate-spin" />
<span>Creating Initial Commit...</span>
</>
) : (
<>
<GitCommit className="w-4 h-4" />
<span>Create Initial Commit</span>
</>
)}
</button>
</div>
) : !gitStatus || (!gitStatus.modified?.length && !gitStatus.added?.length && !gitStatus.deleted?.length && !gitStatus.untracked?.length) ? ( ) : !gitStatus || (!gitStatus.modified?.length && !gitStatus.added?.length && !gitStatus.deleted?.length && !gitStatus.untracked?.length) ? (
<div className="flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400"> <div className="flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400">
<GitCommit className="w-12 h-12 mb-2 opacity-50" /> <GitCommit className="w-12 h-12 mb-2 opacity-50" />

View File

@@ -0,0 +1,129 @@
import { useState, useEffect } from 'react';
import { Button } from './ui/button';
import { Input } from './ui/input';
import { GitBranch, Check } from 'lucide-react';
import { authenticatedFetch } from '../utils/api';
function GitSettings() {
const [gitName, setGitName] = useState('');
const [gitEmail, setGitEmail] = useState('');
const [gitConfigLoading, setGitConfigLoading] = useState(false);
const [gitConfigSaving, setGitConfigSaving] = useState(false);
const [saveStatus, setSaveStatus] = useState(null);
useEffect(() => {
loadGitConfig();
}, []);
const loadGitConfig = async () => {
try {
setGitConfigLoading(true);
const response = await authenticatedFetch('/api/user/git-config');
if (response.ok) {
const data = await response.json();
setGitName(data.gitName || '');
setGitEmail(data.gitEmail || '');
}
} catch (error) {
console.error('Error loading git config:', error);
} finally {
setGitConfigLoading(false);
}
};
const saveGitConfig = async () => {
try {
setGitConfigSaving(true);
const response = await authenticatedFetch('/api/user/git-config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ gitName, gitEmail })
});
if (response.ok) {
setSaveStatus('success');
setTimeout(() => setSaveStatus(null), 3000);
} else {
const data = await response.json();
setSaveStatus('error');
console.error('Failed to save git config:', data.error);
}
} catch (error) {
console.error('Error saving git config:', error);
setSaveStatus('error');
} finally {
setGitConfigSaving(false);
}
};
return (
<div className="space-y-8">
<div>
<div className="flex items-center gap-2 mb-4">
<GitBranch className="h-5 w-5" />
<h3 className="text-lg font-semibold">Git Configuration</h3>
</div>
<p className="text-sm text-muted-foreground mb-4">
Configure your git identity for commits. These settings will be applied globally via <code className="bg-muted px-2 py-0.5 rounded text-xs">git config --global</code>
</p>
<div className="p-4 border rounded-lg bg-card space-y-3">
<div>
<label htmlFor="settings-git-name" className="block text-sm font-medium text-foreground mb-2">
Git Name
</label>
<Input
id="settings-git-name"
type="text"
value={gitName}
onChange={(e) => setGitName(e.target.value)}
placeholder="John Doe"
disabled={gitConfigLoading}
className="w-full"
/>
<p className="mt-1 text-xs text-muted-foreground">
Your name for git commits
</p>
</div>
<div>
<label htmlFor="settings-git-email" className="block text-sm font-medium text-foreground mb-2">
Git Email
</label>
<Input
id="settings-git-email"
type="email"
value={gitEmail}
onChange={(e) => setGitEmail(e.target.value)}
placeholder="john@example.com"
disabled={gitConfigLoading}
className="w-full"
/>
<p className="mt-1 text-xs text-muted-foreground">
Your email for git commits
</p>
</div>
<div className="flex items-center gap-2">
<Button
onClick={saveGitConfig}
disabled={gitConfigSaving || !gitName || !gitEmail}
>
{gitConfigSaving ? 'Saving...' : 'Save Configuration'}
</Button>
{saveStatus === 'success' && (
<div className="text-sm text-green-600 dark:text-green-400 flex items-center gap-2">
<Check className="w-4 h-4" />
Saved successfully
</div>
)}
</div>
</div>
</div>
</div>
);
}
export default GitSettings;

View File

@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button } from './ui/button'; import { Button } from './ui/button';
import { X } from 'lucide-react'; import { X } from 'lucide-react';
import { authenticatedFetch } from '../utils/api';
function ImageViewer({ file, onClose }) { function ImageViewer({ file, onClose }) {
const imagePath = `/api/projects/${file.projectName}/files/content?path=${encodeURIComponent(file.path)}`; const imagePath = `/api/projects/${file.projectName}/files/content?path=${encodeURIComponent(file.path)}`;
@@ -18,16 +19,7 @@ function ImageViewer({ file, onClose }) {
setError(null); setError(null);
setImageUrl(null); setImageUrl(null);
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch(imagePath, {
if (!token) {
setError('Missing authentication token');
return;
}
const response = await fetch(imagePath, {
headers: {
'Authorization': `Bearer ${token}`
},
signal: controller.signal signal: controller.signal
}); });

View File

@@ -0,0 +1,589 @@
import React, { useState, useEffect } from 'react';
import { ChevronRight, ChevronLeft, Check, GitBranch, User, Mail, LogIn, ExternalLink, Loader2 } from 'lucide-react';
import ClaudeLogo from './ClaudeLogo';
import CursorLogo from './CursorLogo';
import LoginModal from './LoginModal';
import { authenticatedFetch } from '../utils/api';
import { useAuth } from '../contexts/AuthContext';
const Onboarding = ({ onComplete }) => {
const [currentStep, setCurrentStep] = useState(0);
const [gitName, setGitName] = useState('');
const [gitEmail, setGitEmail] = useState('');
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState('');
// CLI authentication states
const [showLoginModal, setShowLoginModal] = useState(false);
const [loginProvider, setLoginProvider] = useState('');
const [selectedProject, setSelectedProject] = useState({ name: 'default', fullPath: '' });
const [claudeAuthStatus, setClaudeAuthStatus] = useState({
authenticated: false,
email: null,
loading: true,
error: null
});
const [cursorAuthStatus, setCursorAuthStatus] = useState({
authenticated: false,
email: null,
loading: true,
error: null
});
const { user } = useAuth();
// Load existing git config on mount
useEffect(() => {
loadGitConfig();
}, []);
// Check authentication status on mount and when modal closes
useEffect(() => {
checkClaudeAuthStatus();
checkCursorAuthStatus();
}, []);
const loadGitConfig = async () => {
try {
const response = await authenticatedFetch('/api/user/git-config');
if (response.ok) {
const data = await response.json();
if (data.gitName) setGitName(data.gitName);
if (data.gitEmail) setGitEmail(data.gitEmail);
}
} catch (error) {
console.error('Error loading git config:', error);
// Silently fail - user can still enter config manually
}
};
// Auto-check authentication status periodically when on CLI steps
useEffect(() => {
if (currentStep === 1 || currentStep === 2) {
const interval = setInterval(() => {
if (currentStep === 1) {
checkClaudeAuthStatus();
} else if (currentStep === 2) {
checkCursorAuthStatus();
}
}, 3000); // Check every 3 seconds
return () => clearInterval(interval);
}
}, [currentStep]);
const checkClaudeAuthStatus = async () => {
try {
const response = await authenticatedFetch('/api/cli/claude/status');
if (response.ok) {
const data = await response.json();
setClaudeAuthStatus({
authenticated: data.authenticated,
email: data.email,
loading: false,
error: data.error || null
});
} else {
setClaudeAuthStatus({
authenticated: false,
email: null,
loading: false,
error: 'Failed to check authentication status'
});
}
} catch (error) {
console.error('Error checking Claude auth status:', error);
setClaudeAuthStatus({
authenticated: false,
email: null,
loading: false,
error: error.message
});
}
};
const checkCursorAuthStatus = async () => {
try {
const response = await authenticatedFetch('/api/cli/cursor/status');
if (response.ok) {
const data = await response.json();
setCursorAuthStatus({
authenticated: data.authenticated,
email: data.email,
loading: false,
error: data.error || null
});
} else {
setCursorAuthStatus({
authenticated: false,
email: null,
loading: false,
error: 'Failed to check authentication status'
});
}
} catch (error) {
console.error('Error checking Cursor auth status:', error);
setCursorAuthStatus({
authenticated: false,
email: null,
loading: false,
error: error.message
});
}
};
const handleClaudeLogin = () => {
setLoginProvider('claude');
setShowLoginModal(true);
};
const handleCursorLogin = () => {
setLoginProvider('cursor');
setShowLoginModal(true);
};
const handleLoginComplete = (exitCode) => {
if (exitCode === 0) {
if (loginProvider === 'claude') {
checkClaudeAuthStatus();
} else if (loginProvider === 'cursor') {
checkCursorAuthStatus();
}
}
};
const handleNextStep = async () => {
setError('');
// Step 0: Git config validation and submission
if (currentStep === 0) {
if (!gitName.trim() || !gitEmail.trim()) {
setError('Both git name and email are required');
return;
}
// Validate email format
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(gitEmail)) {
setError('Please enter a valid email address');
return;
}
setIsSubmitting(true);
try {
// Save git config to backend (which will also apply git config --global)
const response = await authenticatedFetch('/api/user/git-config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ gitName, gitEmail })
});
if (!response.ok) {
const data = await response.json();
throw new Error(data.error || 'Failed to save git configuration');
}
setCurrentStep(currentStep + 1);
} catch (err) {
setError(err.message);
} finally {
setIsSubmitting(false);
}
return;
}
// Other steps: just move forward
setCurrentStep(currentStep + 1);
};
const handlePrevStep = () => {
setError('');
setCurrentStep(currentStep - 1);
};
const handleFinish = async () => {
setIsSubmitting(true);
setError('');
try {
// Mark onboarding as complete
const response = await authenticatedFetch('/api/user/complete-onboarding', {
method: 'POST'
});
if (!response.ok) {
const data = await response.json();
throw new Error(data.error || 'Failed to complete onboarding');
}
// Call the onComplete callback
if (onComplete) {
onComplete();
}
} catch (err) {
setError(err.message);
} finally {
setIsSubmitting(false);
}
};
const steps = [
{
title: 'Git Configuration',
description: 'Set up your git identity for commits',
icon: GitBranch,
required: true
},
{
title: 'Claude Code CLI',
description: 'Connect your Claude Code account',
icon: () => <ClaudeLogo size={24} />,
required: false
},
{
title: 'Cursor CLI',
description: 'Connect your Cursor account',
icon: () => <CursorLogo size={24} />,
required: false
}
];
const renderStepContent = () => {
switch (currentStep) {
case 0:
return (
<div className="space-y-6">
<div className="text-center mb-8">
<div className="w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center mx-auto mb-4">
<GitBranch className="w-8 h-8 text-blue-600 dark:text-blue-400" />
</div>
<h2 className="text-2xl font-bold text-foreground mb-2">Git Configuration</h2>
<p className="text-muted-foreground">
Configure your git identity to ensure proper attribution for your commits
</p>
</div>
<div className="space-y-4">
<div>
<label htmlFor="gitName" className="flex items-center gap-2 text-sm font-medium text-foreground mb-2">
<User className="w-4 h-4" />
Git Name <span className="text-red-500">*</span>
</label>
<input
type="text"
id="gitName"
value={gitName}
onChange={(e) => setGitName(e.target.value)}
className="w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="John Doe"
required
disabled={isSubmitting}
/>
<p className="mt-1 text-xs text-muted-foreground">
This will be used as: git config --global user.name
</p>
</div>
<div>
<label htmlFor="gitEmail" className="flex items-center gap-2 text-sm font-medium text-foreground mb-2">
<Mail className="w-4 h-4" />
Git Email <span className="text-red-500">*</span>
</label>
<input
type="email"
id="gitEmail"
value={gitEmail}
onChange={(e) => setGitEmail(e.target.value)}
className="w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="john@example.com"
required
disabled={isSubmitting}
/>
<p className="mt-1 text-xs text-muted-foreground">
This will be used as: git config --global user.email
</p>
</div>
</div>
</div>
);
case 1:
return (
<div className="space-y-6">
<div className="text-center mb-8">
<div className="w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center mx-auto mb-4">
<ClaudeLogo size={32} />
</div>
<h2 className="text-2xl font-bold text-foreground mb-2">Claude Code CLI</h2>
<p className="text-muted-foreground">
Connect your Claude account to enable AI-powered coding features
</p>
</div>
{/* Auth Status Card */}
<div className="border border-border rounded-lg p-6 bg-card">
<div className="flex items-center justify-between mb-4">
<div className="flex items-center gap-3">
<div className={`w-3 h-3 rounded-full ${
claudeAuthStatus.loading ? 'bg-gray-400 animate-pulse' :
claudeAuthStatus.authenticated ? 'bg-green-500' : 'bg-gray-300'
}`} />
<span className="font-medium text-foreground">
{claudeAuthStatus.loading ? 'Checking...' :
claudeAuthStatus.authenticated ? 'Connected' : 'Not Connected'}
</span>
</div>
{claudeAuthStatus.authenticated && (
<Check className="w-5 h-5 text-green-500" />
)}
</div>
{claudeAuthStatus.authenticated && claudeAuthStatus.email && (
<p className="text-sm text-muted-foreground mb-4">
Signed in as: <span className="text-foreground font-medium">{claudeAuthStatus.email}</span>
</p>
)}
{!claudeAuthStatus.authenticated && (
<>
<p className="text-sm text-muted-foreground mb-4">
Click the button below to authenticate with Claude Code CLI. A terminal will open with authentication instructions.
</p>
<button
onClick={handleClaudeLogin}
className="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors duration-200 flex items-center justify-center gap-2"
>
<LogIn className="w-5 h-5" />
Login to Claude Code
</button>
<p className="text-xs text-muted-foreground mt-3 text-center">
Or manually run: <code className="bg-muted px-2 py-1 rounded">claude auth login</code>
</p>
</>
)}
{claudeAuthStatus.error && !claudeAuthStatus.authenticated && (
<div className="mt-4 p-3 bg-yellow-100 dark:bg-yellow-900/20 border border-yellow-300 dark:border-yellow-800 rounded-lg">
<p className="text-sm text-yellow-700 dark:text-yellow-400">{claudeAuthStatus.error}</p>
</div>
)}
</div>
<div className="text-center text-sm text-muted-foreground">
<p>This step is optional. You can skip and configure it later in Settings.</p>
</div>
</div>
);
case 2:
return (
<div className="space-y-6">
<div className="text-center mb-8">
<div className="w-16 h-16 bg-purple-100 dark:bg-purple-900/30 rounded-full flex items-center justify-center mx-auto mb-4">
<CursorLogo size={32} />
</div>
<h2 className="text-2xl font-bold text-foreground mb-2">Cursor CLI</h2>
<p className="text-muted-foreground">
Connect your Cursor account to enable AI-powered features
</p>
</div>
{/* Auth Status Card */}
<div className="border border-border rounded-lg p-6 bg-card">
<div className="flex items-center justify-between mb-4">
<div className="flex items-center gap-3">
<div className={`w-3 h-3 rounded-full ${
cursorAuthStatus.loading ? 'bg-gray-400 animate-pulse' :
cursorAuthStatus.authenticated ? 'bg-green-500' : 'bg-gray-300'
}`} />
<span className="font-medium text-foreground">
{cursorAuthStatus.loading ? 'Checking...' :
cursorAuthStatus.authenticated ? 'Connected' : 'Not Connected'}
</span>
</div>
{cursorAuthStatus.authenticated && (
<Check className="w-5 h-5 text-green-500" />
)}
</div>
{cursorAuthStatus.authenticated && cursorAuthStatus.email && (
<p className="text-sm text-muted-foreground mb-4">
Signed in as: <span className="text-foreground font-medium">{cursorAuthStatus.email}</span>
</p>
)}
{!cursorAuthStatus.authenticated && (
<>
<p className="text-sm text-muted-foreground mb-4">
Click the button below to authenticate with Cursor CLI. A terminal will open with authentication instructions.
</p>
<button
onClick={handleCursorLogin}
className="w-full bg-purple-600 hover:bg-purple-700 text-white font-medium py-3 px-4 rounded-lg transition-colors duration-200 flex items-center justify-center gap-2"
>
<LogIn className="w-5 h-5" />
Login to Cursor
</button>
<p className="text-xs text-muted-foreground mt-3 text-center">
Or manually run: <code className="bg-muted px-2 py-1 rounded">cursor auth login</code>
</p>
</>
)}
{cursorAuthStatus.error && !cursorAuthStatus.authenticated && (
<div className="mt-4 p-3 bg-yellow-100 dark:bg-yellow-900/20 border border-yellow-300 dark:border-yellow-800 rounded-lg">
<p className="text-sm text-yellow-700 dark:text-yellow-400">{cursorAuthStatus.error}</p>
</div>
)}
</div>
<div className="text-center text-sm text-muted-foreground">
<p>This step is optional. You can skip and configure it later in Settings.</p>
</div>
</div>
);
default:
return null;
}
};
const isStepValid = () => {
switch (currentStep) {
case 0:
return gitName.trim() && gitEmail.trim() && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(gitEmail);
case 1:
case 2:
return true; // CLI steps are optional
default:
return false;
}
};
return (
<>
<div className="min-h-screen bg-background flex items-center justify-center p-4">
<div className="w-full max-w-2xl">
{/* Progress Steps */}
<div className="mb-8">
<div className="flex items-center justify-between">
{steps.map((step, index) => (
<React.Fragment key={index}>
<div className="flex flex-col items-center flex-1">
<div className={`w-12 h-12 rounded-full flex items-center justify-center border-2 transition-colors duration-200 ${
index < currentStep ? 'bg-green-500 border-green-500 text-white' :
index === currentStep ? 'bg-blue-600 border-blue-600 text-white' :
'bg-background border-border text-muted-foreground'
}`}>
{index < currentStep ? (
<Check className="w-6 h-6" />
) : typeof step.icon === 'function' ? (
<step.icon />
) : (
<step.icon className="w-6 h-6" />
)}
</div>
<div className="mt-2 text-center">
<p className={`text-sm font-medium ${
index === currentStep ? 'text-foreground' : 'text-muted-foreground'
}`}>
{step.title}
</p>
{step.required && (
<span className="text-xs text-red-500">Required</span>
)}
</div>
</div>
{index < steps.length - 1 && (
<div className={`flex-1 h-0.5 mx-2 transition-colors duration-200 ${
index < currentStep ? 'bg-green-500' : 'bg-border'
}`} />
)}
</React.Fragment>
))}
</div>
</div>
{/* Main Card */}
<div className="bg-card rounded-lg shadow-lg border border-border p-8">
{renderStepContent()}
{/* Error Message */}
{error && (
<div className="mt-6 p-4 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-lg">
<p className="text-sm text-red-700 dark:text-red-400">{error}</p>
</div>
)}
{/* Navigation Buttons */}
<div className="flex items-center justify-between mt-8 pt-6 border-t border-border">
<button
onClick={handlePrevStep}
disabled={currentStep === 0 || isSubmitting}
className="flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200"
>
<ChevronLeft className="w-4 h-4" />
Previous
</button>
<div className="flex items-center gap-3">
{currentStep < steps.length - 1 ? (
<button
onClick={handleNextStep}
disabled={!isStepValid() || isSubmitting}
className="flex items-center gap-2 px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200"
>
{isSubmitting ? (
<>
<Loader2 className="w-4 h-4 animate-spin" />
Saving...
</>
) : (
<>
Next
<ChevronRight className="w-4 h-4" />
</>
)}
</button>
) : (
<button
onClick={handleFinish}
disabled={isSubmitting}
className="flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 disabled:bg-green-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200"
>
{isSubmitting ? (
<>
<Loader2 className="w-4 h-4 animate-spin" />
Completing...
</>
) : (
<>
<Check className="w-4 h-4" />
Complete Setup
</>
)}
</button>
)}
</div>
</div>
</div>
</div>
</div>
{/* Login Modal */}
{showLoginModal && (
<LoginModal
isOpen={showLoginModal}
onClose={() => setShowLoginModal(false)}
provider={loginProvider}
project={selectedProject}
onLoginComplete={handleLoginComplete}
/>
)}
</>
);
};
export default Onboarding;

View File

@@ -2,6 +2,7 @@ import React from 'react';
import { useAuth } from '../contexts/AuthContext'; import { useAuth } from '../contexts/AuthContext';
import SetupForm from './SetupForm'; import SetupForm from './SetupForm';
import LoginForm from './LoginForm'; import LoginForm from './LoginForm';
import Onboarding from './Onboarding';
import { MessageSquare } from 'lucide-react'; import { MessageSquare } from 'lucide-react';
const LoadingScreen = () => ( const LoadingScreen = () => (
@@ -24,14 +25,20 @@ const LoadingScreen = () => (
); );
const ProtectedRoute = ({ children }) => { const ProtectedRoute = ({ children }) => {
const { user, isLoading, needsSetup } = useAuth(); const { user, isLoading, needsSetup, hasCompletedOnboarding, refreshOnboardingStatus } = useAuth();
// Platform mode: skip all auth UI and directly render children
if (import.meta.env.VITE_IS_PLATFORM === 'true') { if (import.meta.env.VITE_IS_PLATFORM === 'true') {
if (isLoading) {
return <LoadingScreen />;
}
if (!hasCompletedOnboarding) {
return <Onboarding onComplete={refreshOnboardingStatus} />;
}
return children; return children;
} }
// Normal OSS mode: standard auth flow
if (isLoading) { if (isLoading) {
return <LoadingScreen />; return <LoadingScreen />;
} }
@@ -44,6 +51,10 @@ const ProtectedRoute = ({ children }) => {
return <LoginForm />; return <LoginForm />;
} }
if (!hasCompletedOnboarding) {
return <Onboarding onComplete={refreshOnboardingStatus} />;
}
return children; return children;
}; };

View File

@@ -2,24 +2,18 @@ import { useState, useEffect } from 'react';
import { Button } from './ui/button'; import { Button } from './ui/button';
import { Input } from './ui/input'; import { Input } from './ui/input';
import { Badge } from './ui/badge'; import { Badge } from './ui/badge';
import { X, Plus, Settings as SettingsIcon, Shield, AlertTriangle, Moon, Sun, Server, Edit3, Trash2, Globe, Terminal, Zap, FolderOpen, LogIn, Key } from 'lucide-react'; import { X, Plus, Settings as SettingsIcon, Shield, AlertTriangle, Moon, Sun, Server, Edit3, Trash2, Globe, Terminal, Zap, FolderOpen, LogIn, Key, GitBranch, Check } from 'lucide-react';
import { useTheme } from '../contexts/ThemeContext'; import { useTheme } from '../contexts/ThemeContext';
import { useTasksSettings } from '../contexts/TasksSettingsContext';
import ClaudeLogo from './ClaudeLogo'; import ClaudeLogo from './ClaudeLogo';
import CursorLogo from './CursorLogo'; import CursorLogo from './CursorLogo';
import CredentialsSettings from './CredentialsSettings'; import CredentialsSettings from './CredentialsSettings';
import GitSettings from './GitSettings';
import TasksSettings from './TasksSettings';
import LoginModal from './LoginModal'; import LoginModal from './LoginModal';
import { authenticatedFetch } from '../utils/api';
function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) { function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const { isDarkMode, toggleDarkMode } = useTheme(); const { isDarkMode, toggleDarkMode } = useTheme();
const {
tasksEnabled,
setTasksEnabled,
isTaskMasterInstalled,
isTaskMasterReady,
installationStatus,
isCheckingInstallation
} = useTasksSettings();
const [allowedTools, setAllowedTools] = useState([]); const [allowedTools, setAllowedTools] = useState([]);
const [disallowedTools, setDisallowedTools] = useState([]); const [disallowedTools, setDisallowedTools] = useState([]);
const [newAllowedTool, setNewAllowedTool] = useState(''); const [newAllowedTool, setNewAllowedTool] = useState('');
@@ -135,13 +129,7 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
// Fetch Cursor MCP servers // Fetch Cursor MCP servers
const fetchCursorMcpServers = async () => { const fetchCursorMcpServers = async () => {
try { try {
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch('/api/cursor/mcp');
const response = await fetch('/api/cursor/mcp', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
@@ -157,15 +145,8 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
// MCP API functions // MCP API functions
const fetchMcpServers = async () => { const fetchMcpServers = async () => {
try { try {
const token = localStorage.getItem('auth-token');
// Try to read directly from config files for complete details // Try to read directly from config files for complete details
const configResponse = await fetch('/api/mcp/config/read', { const configResponse = await authenticatedFetch('/api/mcp/config/read');
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (configResponse.ok) { if (configResponse.ok) {
const configData = await configResponse.json(); const configData = await configResponse.json();
@@ -176,12 +157,7 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
} }
// Fallback to Claude CLI // Fallback to Claude CLI
const cliResponse = await fetch('/api/mcp/cli/list', { const cliResponse = await authenticatedFetch('/api/mcp/cli/list');
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (cliResponse.ok) { if (cliResponse.ok) {
const cliData = await cliResponse.json(); const cliData = await cliResponse.json();
@@ -209,12 +185,7 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
} }
// Final fallback to direct config reading // Final fallback to direct config reading
const response = await fetch('/api/mcp/servers?scope=user', { const response = await authenticatedFetch('/api/mcp/servers?scope=user');
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
@@ -229,20 +200,14 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const saveMcpServer = async (serverData) => { const saveMcpServer = async (serverData) => {
try { try {
const token = localStorage.getItem('auth-token');
if (editingMcpServer) { if (editingMcpServer) {
// For editing, remove old server and add new one // For editing, remove old server and add new one
await deleteMcpServer(editingMcpServer.id, 'user'); await deleteMcpServer(editingMcpServer.id, 'user');
} }
// Use Claude CLI to add the server // Use Claude CLI to add the server
const response = await fetch('/api/mcp/cli/add', { const response = await authenticatedFetch('/api/mcp/cli/add', {
method: 'POST', method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body: JSON.stringify({
name: serverData.name, name: serverData.name,
type: serverData.type, type: serverData.type,
@@ -276,15 +241,9 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const deleteMcpServer = async (serverId, scope = 'user') => { const deleteMcpServer = async (serverId, scope = 'user') => {
try { try {
const token = localStorage.getItem('auth-token');
// Use Claude CLI to remove the server with proper scope // Use Claude CLI to remove the server with proper scope
const response = await fetch(`/api/mcp/cli/remove/${serverId}?scope=${scope}`, { const response = await authenticatedFetch(`/api/mcp/cli/remove/${serverId}?scope=${scope}`, {
method: 'DELETE', method: 'DELETE'
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
}); });
if (response.ok) { if (response.ok) {
@@ -307,13 +266,8 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const testMcpServer = async (serverId, scope = 'user') => { const testMcpServer = async (serverId, scope = 'user') => {
try { try {
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch(`/api/mcp/servers/${serverId}/test?scope=${scope}`, {
const response = await fetch(`/api/mcp/servers/${serverId}/test?scope=${scope}`, { method: 'POST'
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
}); });
if (response.ok) { if (response.ok) {
@@ -332,13 +286,8 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const discoverMcpTools = async (serverId, scope = 'user') => { const discoverMcpTools = async (serverId, scope = 'user') => {
try { try {
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch(`/api/mcp/servers/${serverId}/tools?scope=${scope}`, {
const response = await fetch(`/api/mcp/servers/${serverId}/tools?scope=${scope}`, { method: 'POST'
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
}); });
if (response.ok) { if (response.ok) {
@@ -431,7 +380,6 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
await fetchCursorMcpServers(); await fetchCursorMcpServers();
} catch (error) { } catch (error) {
console.error('Error loading tool settings:', error); console.error('Error loading tool settings:', error);
// Set defaults on error
setAllowedTools([]); setAllowedTools([]);
setDisallowedTools([]); setDisallowedTools([]);
setSkipPermissions(false); setSkipPermissions(false);
@@ -441,13 +389,7 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const checkClaudeAuthStatus = async () => { const checkClaudeAuthStatus = async () => {
try { try {
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch('/api/cli/claude/status');
const response = await fetch('/api/cli/claude/status', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
@@ -478,13 +420,7 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
const checkCursorAuthStatus = async () => { const checkCursorAuthStatus = async () => {
try { try {
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch('/api/cli/cursor/status');
const response = await fetch('/api/cli/cursor/status', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
@@ -647,13 +583,8 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
try { try {
if (mcpFormData.importMode === 'json') { if (mcpFormData.importMode === 'json') {
// Use JSON import endpoint // Use JSON import endpoint
const token = localStorage.getItem('auth-token'); const response = await authenticatedFetch('/api/mcp/cli/add-json', {
const response = await fetch('/api/mcp/cli/add-json', {
method: 'POST', method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body: JSON.stringify({
name: mcpFormData.name, name: mcpFormData.name,
jsonConfig: mcpFormData.jsonInput, jsonConfig: mcpFormData.jsonInput,
@@ -805,14 +736,15 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
Appearance Appearance
</button> </button>
<button <button
onClick={() => setActiveTab('tasks')} onClick={() => setActiveTab('git')}
className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${
activeTab === 'tasks' activeTab === 'git'
? 'border-blue-600 text-blue-600 dark:text-blue-400' ? 'border-blue-600 text-blue-600 dark:text-blue-400'
: 'border-transparent text-muted-foreground hover:text-foreground' : 'border-transparent text-muted-foreground hover:text-foreground'
}`} }`}
> >
Tasks <GitBranch className="w-4 h-4 inline mr-2" />
Git
</button> </button>
<button <button
onClick={() => setActiveTab('api')} onClick={() => setActiveTab('api')}
@@ -825,6 +757,16 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
<Key className="w-4 h-4 inline mr-2" /> <Key className="w-4 h-4 inline mr-2" />
API & Tokens API & Tokens
</button> </button>
<button
onClick={() => setActiveTab('tasks')}
className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${
activeTab === 'tasks'
? 'border-blue-600 text-blue-600 dark:text-blue-400'
: 'border-transparent text-muted-foreground hover:text-foreground'
}`}
>
Tasks
</button>
</div> </div>
</div> </div>
@@ -1052,6 +994,9 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
</div> </div>
)} )}
{/* Git Tab */}
{activeTab === 'git' && <GitSettings />}
{/* Tools Tab */} {/* Tools Tab */}
{activeTab === 'tools' && ( {activeTab === 'tools' && (
<div className="space-y-6 md:space-y-8"> <div className="space-y-6 md:space-y-8">
@@ -2143,154 +2088,7 @@ function Settings({ isOpen, onClose, projects = [], initialTab = 'tools' }) {
{/* Tasks Tab */} {/* Tasks Tab */}
{activeTab === 'tasks' && ( {activeTab === 'tasks' && (
<div className="space-y-6 md:space-y-8"> <div className="space-y-6 md:space-y-8">
{/* Installation Status Check */} <TasksSettings />
{isCheckingInstallation ? (
<div className="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4">
<div className="flex items-center gap-3">
<div className="animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"></div>
<span className="text-sm text-muted-foreground">Checking TaskMaster installation...</span>
</div>
</div>
) : (
<>
{/* TaskMaster Not Installed Warning */}
{!isTaskMasterInstalled && (
<div className="bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4">
<div className="flex items-start gap-3">
<div className="w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
<svg className="w-4 h-4 text-orange-600 dark:text-orange-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
</svg>
</div>
<div className="flex-1">
<div className="font-medium text-orange-900 dark:text-orange-100 mb-2">
TaskMaster AI CLI Not Installed
</div>
<div className="text-sm text-orange-800 dark:text-orange-200 space-y-3">
<p>TaskMaster CLI is required to use task management features. Install it to get started:</p>
<div className="bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm">
<code>npm install -g task-master-ai</code>
<a
href="https://github.com/eyaltoledano/claude-task-master"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium"
>
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z" clipRule="evenodd" />
</svg>
View on GitHub
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</a>
</div>
<div className="space-y-2">
<p className="font-medium">After installation:</p>
<ol className="list-decimal list-inside space-y-1 text-xs">
<li>Restart this application</li>
<li>TaskMaster features will automatically become available</li>
<li>Use <code className="bg-orange-100 dark:bg-orange-800 px-1 rounded">task-master init</code> in your project directory</li>
</ol>
</div>
</div>
</div>
</div>
</div>
)}
{/* TaskMaster Settings */}
<div className="space-y-4">
<div className="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4">
<div className="flex items-center justify-between">
<div>
<div className="font-medium text-foreground">
Enable TaskMaster Integration
</div>
<div className="text-sm text-muted-foreground mt-1">
Show TaskMaster tasks, banners, and sidebar indicators across the interface
</div>
{!isTaskMasterInstalled && (
<div className="text-xs text-orange-600 dark:text-orange-400 mt-1">
TaskMaster CLI must be installed first
</div>
)}
</div>
<label className="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
checked={tasksEnabled}
onChange={(e) => setTasksEnabled(e.target.checked)}
disabled={!isTaskMasterInstalled}
className="sr-only peer"
/>
<div className={`w-11 h-6 ${!isTaskMasterInstalled ? 'bg-gray-300 dark:bg-gray-600' : 'bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800'} rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600`}></div>
</label>
</div>
</div>
{/* TaskMaster Information */}
<div className="bg-blue-50 dark:bg-blue-950/50 border border-blue-200 dark:border-blue-800 rounded-lg p-4">
<div className="flex items-start gap-3">
<div className="w-8 h-8 bg-blue-100 dark:bg-blue-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
<Zap className="w-4 h-4 text-blue-600 dark:text-blue-400" />
</div>
<div>
<div className="font-medium text-blue-900 dark:text-blue-100 mb-2">
🎯 About TaskMaster AI
</div>
<div className="text-sm text-blue-800 dark:text-blue-200 space-y-2">
<p><strong>AI-Powered Task Management:</strong> Break complex projects into manageable subtasks with AI assistance</p>
<p><strong>PRD:</strong> Generate structured tasks from Product Requirements Documents</p>
<p><strong>Dependency Tracking:</strong> Understand task relationships and execution order</p>
<p><strong>Progress Visualization:</strong> Kanban boards, and detailed task views</p>
</div>
</div>
{/* GitHub Link and Resources */}
<div className="mt-4 pt-4 border-t border-blue-200 dark:border-blue-700">
<div className="flex items-start gap-3">
<div className="w-6 h-6 bg-blue-100 dark:bg-blue-800 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
<svg className="w-3 h-3 text-blue-600 dark:text-blue-400" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z" clipRule="evenodd" />
</svg>
</div>
<div className="flex-1">
<div className="font-medium text-blue-900 dark:text-blue-100 mb-2">
📚 Learn More & Tutorial
</div>
<div className="text-sm text-blue-800 dark:text-blue-200 space-y-2">
<p>TaskMaster AI (aka <strong>claude-task-master</strong> ) is an advanced AI-powered task management system built for developers.</p>
<div className="flex flex-col gap-2">
<a
href="https://github.com/eyaltoledano/claude-task-master"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium"
>
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z" clipRule="evenodd" />
</svg>
View on GitHub
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</a>
<p className="text-xs text-blue-700 dark:text-blue-300">
Find documentation, setup guides, and examples for advanced TaskMaster workflows
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</>
)}
</div> </div>
)} )}

View File

@@ -0,0 +1,107 @@
import { Zap } from 'lucide-react';
import { useTasksSettings } from '../contexts/TasksSettingsContext';
function TasksSettings() {
const {
tasksEnabled,
setTasksEnabled,
isTaskMasterInstalled,
isCheckingInstallation
} = useTasksSettings();
return (
<div className="space-y-8">
{/* Installation Status Check */}
{isCheckingInstallation ? (
<div className="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4">
<div className="flex items-center gap-3">
<div className="animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"></div>
<span className="text-sm text-muted-foreground">Checking TaskMaster installation...</span>
</div>
</div>
) : (
<>
{/* TaskMaster Not Installed Warning */}
{!isTaskMasterInstalled && (
<div className="bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4">
<div className="flex items-start gap-3">
<div className="w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5">
<svg className="w-4 h-4 text-orange-600 dark:text-orange-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" />
</svg>
</div>
<div className="flex-1">
<div className="font-medium text-orange-900 dark:text-orange-100 mb-2">
TaskMaster AI CLI Not Installed
</div>
<div className="text-sm text-orange-800 dark:text-orange-200 space-y-3">
<p>TaskMaster CLI is required to use task management features. Install it to get started:</p>
<div className="bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm">
<code>npm install -g task-master-ai</code>
</div>
<div>
<a
href="https://github.com/eyaltoledano/claude-task-master"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm"
>
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z" clipRule="evenodd" />
</svg>
View on GitHub
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</a>
</div>
<div className="space-y-2">
<p className="font-medium">After installation:</p>
<ol className="list-decimal list-inside space-y-1 text-xs">
<li>Restart this application</li>
<li>TaskMaster features will automatically become available</li>
<li>Use <code className="bg-orange-100 dark:bg-orange-800 px-1 rounded">task-master init</code> in your project directory</li>
</ol>
</div>
</div>
</div>
</div>
</div>
)}
{/* TaskMaster Settings */}
{isTaskMasterInstalled && (
<div className="space-y-4">
<div className="bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4">
<div className="flex items-center justify-between">
<div>
<div className="font-medium text-foreground">
Enable TaskMaster Integration
</div>
<div className="text-sm text-muted-foreground mt-1">
Show TaskMaster tasks, banners, and sidebar indicators across the interface
</div>
</div>
<label className="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
checked={tasksEnabled}
onChange={(e) => setTasksEnabled(e.target.checked)}
className="sr-only peer"
/>
<div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
</label>
</div>
</div>
</div>
)}
</>
)}
</div>
);
}
export default TasksSettings;

View File

@@ -9,6 +9,8 @@ const AuthContext = createContext({
logout: () => {}, logout: () => {},
isLoading: true, isLoading: true,
needsSetup: false, needsSetup: false,
hasCompletedOnboarding: true,
refreshOnboardingStatus: () => {},
error: null error: null
}); });
@@ -25,22 +27,38 @@ export const AuthProvider = ({ children }) => {
const [token, setToken] = useState(localStorage.getItem('auth-token')); const [token, setToken] = useState(localStorage.getItem('auth-token'));
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [needsSetup, setNeedsSetup] = useState(false); const [needsSetup, setNeedsSetup] = useState(false);
const [hasCompletedOnboarding, setHasCompletedOnboarding] = useState(true);
const [error, setError] = useState(null); const [error, setError] = useState(null);
// Check authentication status on mount
useEffect(() => { useEffect(() => {
// Platform mode: skip all auth checks, set dummy user
if (import.meta.env.VITE_IS_PLATFORM === 'true') { if (import.meta.env.VITE_IS_PLATFORM === 'true') {
setUser({ username: 'platform-user' }); setUser({ username: 'platform-user' });
setNeedsSetup(false); setNeedsSetup(false);
checkOnboardingStatus();
setIsLoading(false); setIsLoading(false);
return; return;
} }
// Normal OSS mode: check auth status
checkAuthStatus(); checkAuthStatus();
}, []); }, []);
const checkOnboardingStatus = async () => {
try {
const response = await api.user.onboardingStatus();
if (response.ok) {
const data = await response.json();
setHasCompletedOnboarding(data.hasCompletedOnboarding);
}
} catch (error) {
console.error('Error checking onboarding status:', error);
setHasCompletedOnboarding(true);
}
};
const refreshOnboardingStatus = async () => {
await checkOnboardingStatus();
};
const checkAuthStatus = async () => { const checkAuthStatus = async () => {
try { try {
setIsLoading(true); setIsLoading(true);
@@ -65,6 +83,7 @@ export const AuthProvider = ({ children }) => {
const userData = await userResponse.json(); const userData = await userResponse.json();
setUser(userData.user); setUser(userData.user);
setNeedsSetup(false); setNeedsSetup(false);
await checkOnboardingStatus();
} else { } else {
// Token is invalid // Token is invalid
localStorage.removeItem('auth-token'); localStorage.removeItem('auth-token');
@@ -156,6 +175,8 @@ export const AuthProvider = ({ children }) => {
logout, logout,
isLoading, isLoading,
needsSetup, needsSetup,
hasCompletedOnboarding,
refreshOnboardingStatus,
error error
}; };

View File

@@ -1,12 +1,13 @@
// Utility function for authenticated API calls // Utility function for authenticated API calls
export const authenticatedFetch = (url, options = {}) => { export const authenticatedFetch = (url, options = {}) => {
const isPlatform = import.meta.env.VITE_IS_PLATFORM === 'true';
const token = localStorage.getItem('auth-token'); const token = localStorage.getItem('auth-token');
const defaultHeaders = { const defaultHeaders = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}; };
if (token) { if (!isPlatform && token) {
defaultHeaders['Authorization'] = `Bearer ${token}`; defaultHeaders['Authorization'] = `Bearer ${token}`;
} }
@@ -141,6 +142,21 @@ export const api = {
return authenticatedFetch(`/api/browse-filesystem?${params}`); return authenticatedFetch(`/api/browse-filesystem?${params}`);
}, },
// User endpoints
user: {
gitConfig: () => authenticatedFetch('/api/user/git-config'),
updateGitConfig: (gitName, gitEmail) =>
authenticatedFetch('/api/user/git-config', {
method: 'POST',
body: JSON.stringify({ gitName, gitEmail }),
}),
onboardingStatus: () => authenticatedFetch('/api/user/onboarding-status'),
completeOnboarding: () =>
authenticatedFetch('/api/user/complete-onboarding', {
method: 'POST',
}),
},
// Generic GET method for any endpoint // Generic GET method for any endpoint
get: (endpoint) => authenticatedFetch(`/api${endpoint}`), get: (endpoint) => authenticatedFetch(`/api${endpoint}`),
}; };