mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-02 10:35:37 +08:00
refactor(projects): rename getProjects with getProjectsWithSessions
This commit is contained in:
@@ -27,7 +27,7 @@ import { promises as fsPromises } from 'fs';
|
|||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import pty from 'node-pty';
|
import pty from 'node-pty';
|
||||||
import mime from 'mime-types';
|
import mime from 'mime-types';
|
||||||
import { getProjects } from '@/modules/projects';
|
import { getProjectsWithSessions } from '@/modules/projects';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getSessionsById,
|
getSessionsById,
|
||||||
@@ -142,7 +142,7 @@ async function setupProjectsWatcher() {
|
|||||||
clearProjectDirectoryCache();
|
clearProjectDirectoryCache();
|
||||||
|
|
||||||
// Get updated projects list
|
// Get updated projects list
|
||||||
const updatedProjects = await getProjects(broadcastProgress);
|
const updatedProjects = await getProjectsWithSessions(broadcastProgress);
|
||||||
|
|
||||||
// Notify all connected clients about the project changes
|
// Notify all connected clients about the project changes
|
||||||
const updateMessage = JSON.stringify({
|
const updateMessage = JSON.stringify({
|
||||||
@@ -431,7 +431,7 @@ app.post('/api/system/update', authenticateToken, async (req, res) => {
|
|||||||
|
|
||||||
app.get('/api/projects', authenticateToken, async (req, res) => {
|
app.get('/api/projects', authenticateToken, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const projects = await getProjects(broadcastProgress);
|
const projects = await getProjectsWithSessions(broadcastProgress);
|
||||||
res.json(projects);
|
res.json(projects);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
@@ -2375,7 +2375,7 @@ async function startServer() {
|
|||||||
// Start watching the projects folder for changes
|
// Start watching the projects folder for changes
|
||||||
await setupProjectsWatcher();
|
await setupProjectsWatcher();
|
||||||
|
|
||||||
// await getProjects(); // TODO: REMOVE THIS
|
// await getProjectsWithSessions(); // TODO: REMOVE THIS
|
||||||
// Start server-side plugin processes for enabled plugins
|
// Start server-side plugin processes for enabled plugins
|
||||||
startEnabledPluginServers().catch(err => {
|
startEnabledPluginServers().catch(err => {
|
||||||
console.error('[Plugins] Error during startup:', err.message);
|
console.error('[Plugins] Error during startup:', err.message);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export {
|
export {
|
||||||
createProjectsSnapshot,
|
createProjectsSnapshot,
|
||||||
generateDisplayName,
|
generateDisplayName,
|
||||||
getProjects,
|
getProjectsWithSessions,
|
||||||
writeSnapshot,
|
writeSnapshot,
|
||||||
} from './services/projects.service.js';
|
} from './services/projects.service.js';
|
||||||
@@ -175,7 +175,7 @@ export async function writeSnapshot(projects: ProjectListItem[]): Promise<void>
|
|||||||
/**
|
/**
|
||||||
* Reads all projects from DB and returns provider-bucketed session summaries.
|
* Reads all projects from DB and returns provider-bucketed session summaries.
|
||||||
*/
|
*/
|
||||||
export async function getProjects(progressCallback: ProgressCallback = null): Promise<ProjectListItem[]> {
|
export async function getProjectsWithSessions(progressCallback: ProgressCallback = null): Promise<ProjectListItem[]> {
|
||||||
await sessionSynchronizerService.synchronizeSessions();
|
await sessionSynchronizerService.synchronizeSessions();
|
||||||
|
|
||||||
const projectRows = projectsDb.getProjectPaths() as Array<{
|
const projectRows = projectsDb.getProjectPaths() as Array<{
|
||||||
|
|||||||
@@ -872,7 +872,7 @@ async function renameProject(projectName, newDisplayName) {
|
|||||||
* ID-based wrapper around `renameProject`.
|
* ID-based wrapper around `renameProject`.
|
||||||
*
|
*
|
||||||
* Writes the new display name to the `projects.custom_project_name` column
|
* Writes the new display name to the `projects.custom_project_name` column
|
||||||
* (the source of truth for the DB-driven getProjects() response) and also
|
* (the source of truth for the DB-driven getProjectsWithSessions() response) and also
|
||||||
* keeps the legacy project-config.json in sync for backwards compatibility
|
* keeps the legacy project-config.json in sync for backwards compatibility
|
||||||
* with any code that still reads it.
|
* with any code that still reads it.
|
||||||
*/
|
*/
|
||||||
@@ -883,7 +883,7 @@ async function renameProjectById(projectId, newDisplayName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const trimmed = typeof newDisplayName === 'string' ? newDisplayName.trim() : '';
|
const trimmed = typeof newDisplayName === 'string' ? newDisplayName.trim() : '';
|
||||||
// Persist on the DB row so getProjects() immediately reflects the change.
|
// Persist on the DB row so getProjectsWithSessions() immediately reflects the change.
|
||||||
projectsDb.updateCustomProjectNameById(projectId, trimmed.length > 0 ? trimmed : null);
|
projectsDb.updateCustomProjectNameById(projectId, trimmed.length > 0 ? trimmed : null);
|
||||||
|
|
||||||
// Keep the legacy file-based project config in lockstep so historic readers
|
// Keep the legacy file-based project config in lockstep so historic readers
|
||||||
|
|||||||
Reference in New Issue
Block a user