chat: rename claude_sessions → general_chat_sessions; drop dead chat_sessions
The default /chat working directory is used by both the Claude and OpenCode harnesses now, so its Claude-specific name was misleading. - Rename the dir + accessors: getClaudeSessionsCwd → getGeneralChatSessionsCwd, ensureClaudeSessionsCwd → ensureGeneralChatSessionsCwd, path segment claude_sessions → general_chat_sessions (data-path on disk + code + UI labels/comments). No history migration — the old Claude transcript slug is orphaned (intentionally). - Remove the vestigial chat_sessions dir (leftover from the retired session store): it only ever held empty claude/archived/ dirs, recreated by a signin hook. Drop that hook (+ its dead imports) and the 4 unused data-path accessors (getUserSessionsDir, getClaudeDir, getSessionDir, getArchivedSessionDir), and delete the dir. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
import { readdirSync, readFileSync, existsSync, statSync, mkdirSync, rmSync, appendFileSync, openSync, readSync, closeSync } from 'node:fs';
|
||||
import {
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
existsSync,
|
||||
statSync,
|
||||
mkdirSync,
|
||||
rmSync,
|
||||
appendFileSync,
|
||||
openSync,
|
||||
readSync,
|
||||
closeSync,
|
||||
} from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { DATA_PATH } from '../../data-path';
|
||||
|
||||
@@ -13,11 +24,11 @@ import { DATA_PATH } from '../../data-path';
|
||||
const claudeHome = (email: string): string => process.env.HOME_DIR ?? join(DATA_PATH, email, 'home');
|
||||
|
||||
/** Dedicated working directory for /chat sessions, so they form their own Claude "project" group. */
|
||||
export const getClaudeSessionsCwd = (email: string): string => join(DATA_PATH, email, 'claude_sessions');
|
||||
export const getGeneralChatSessionsCwd = (email: string): string => join(DATA_PATH, email, 'general_chat_sessions');
|
||||
|
||||
/** Same, but create the directory if it doesn't exist (call before spawning a /chat session). */
|
||||
export const ensureClaudeSessionsCwd = (email: string): string => {
|
||||
const dir = getClaudeSessionsCwd(email);
|
||||
export const ensureGeneralChatSessionsCwd = (email: string): string => {
|
||||
const dir = getGeneralChatSessionsCwd(email);
|
||||
mkdirSync(dir, { recursive: true });
|
||||
return dir;
|
||||
};
|
||||
@@ -44,7 +55,11 @@ function entryText(message: unknown): string {
|
||||
if (typeof content === 'string') return content;
|
||||
if (Array.isArray(content)) {
|
||||
return content
|
||||
.map((block) => (block && typeof block === 'object' && (block as { type?: string }).type === 'text' ? (block as { text?: string }).text ?? '' : ''))
|
||||
.map((block) =>
|
||||
block && typeof block === 'object' && (block as { type?: string }).type === 'text'
|
||||
? ((block as { text?: string }).text ?? '')
|
||||
: '',
|
||||
)
|
||||
.join('')
|
||||
.trim();
|
||||
}
|
||||
@@ -116,7 +131,14 @@ function summarizeTranscript(filePath: string, id: string): ClaudeSessionSummary
|
||||
export type ClaudeChatMessage =
|
||||
| { role: 'user'; text: string }
|
||||
| { role: 'assistant'; id: string; text: string }
|
||||
| { role: 'tool'; toolName: string; toolInput: Record<string, unknown>; toolCallId: string; output?: string; isError?: boolean };
|
||||
| {
|
||||
role: 'tool';
|
||||
toolName: string;
|
||||
toolInput: Record<string, unknown>;
|
||||
toolCallId: string;
|
||||
output?: string;
|
||||
isError?: boolean;
|
||||
};
|
||||
|
||||
type ContentBlock =
|
||||
| { type: 'text'; text?: string }
|
||||
@@ -128,7 +150,11 @@ function blockText(content: unknown): string {
|
||||
if (typeof content === 'string') return content;
|
||||
if (Array.isArray(content)) {
|
||||
return content
|
||||
.map((b) => (b && typeof b === 'object' && (b as { type?: string }).type === 'text' ? (b as { text?: string }).text ?? '' : ''))
|
||||
.map((b) =>
|
||||
b && typeof b === 'object' && (b as { type?: string }).type === 'text'
|
||||
? ((b as { text?: string }).text ?? '')
|
||||
: '',
|
||||
)
|
||||
.join('');
|
||||
}
|
||||
return '';
|
||||
@@ -185,7 +211,12 @@ export function loadClaudeSession(email: string, cwd: string, sessionId: string)
|
||||
if (block.type === 'text' && block.text?.trim()) {
|
||||
messages.push({ role: 'assistant', id: `${sessionId}-${messages.length}`, text: block.text });
|
||||
} else if (block.type === 'tool_use') {
|
||||
const tool = { role: 'tool' as const, toolName: block.name, toolInput: block.input ?? {}, toolCallId: block.id };
|
||||
const tool = {
|
||||
role: 'tool' as const,
|
||||
toolName: block.name,
|
||||
toolInput: block.input ?? {},
|
||||
toolCallId: block.id,
|
||||
};
|
||||
messages.push(tool);
|
||||
toolById.set(block.id, tool);
|
||||
}
|
||||
@@ -257,7 +288,7 @@ export type ClaudePwd = { cwd: string; sessionCount: number; updatedAt: string;
|
||||
/** All working directories that have Claude sessions, plus the default /chat dir. Newest first. */
|
||||
export function listClaudePwds(email: string): ClaudePwd[] {
|
||||
const projectsDir = claudeProjectsDir(email);
|
||||
const defaultCwd = getClaudeSessionsCwd(email);
|
||||
const defaultCwd = getGeneralChatSessionsCwd(email);
|
||||
const byCwd = new Map<string, { count: number; updatedAt: string }>();
|
||||
|
||||
if (existsSync(projectsDir)) {
|
||||
|
||||
Reference in New Issue
Block a user