Skip to content
Open
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
18 changes: 11 additions & 7 deletions src/main/coworkStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,17 @@ export class CoworkStore {
systemPrompt: string = '',
executionMode: CoworkExecutionMode = 'local',
activeSkillIds: string[] = [],
agentId: string = 'main'
agentId: string = 'main',
options?: { hidden?: boolean }
): CoworkSession {
const id = uuidv4();
const now = Date.now();
const hidden = options?.hidden ? 1 : 0;

this.db.run(`
INSERT INTO cowork_sessions (id, title, claude_session_id, status, cwd, system_prompt, execution_mode, active_skill_ids, agent_id, pinned, created_at, updated_at)
VALUES (?, ?, NULL, 'idle', ?, ?, ?, ?, ?, 0, ?, ?)
`, [id, title, cwd, systemPrompt, executionMode, JSON.stringify(activeSkillIds), agentId, now, now]);
INSERT INTO cowork_sessions (id, title, claude_session_id, status, cwd, system_prompt, execution_mode, active_skill_ids, agent_id, pinned, hidden, created_at, updated_at)
VALUES (?, ?, NULL, 'idle', ?, ?, ?, ?, ?, 0, ?, ?, ?)
`, [id, title, cwd, systemPrompt, executionMode, JSON.stringify(activeSkillIds), agentId, hidden, now, now]);

this.saveDb();

Expand Down Expand Up @@ -728,13 +730,14 @@ export class CoworkStore {
rows = this.getAll<SessionSummaryRow>(`
SELECT id, title, status, pinned, agent_id, created_at, updated_at
FROM cowork_sessions
WHERE agent_id = ?
WHERE agent_id = ? AND COALESCE(hidden, 0) = 0
ORDER BY pinned DESC, updated_at DESC
`, [agentId]);
} else {
rows = this.getAll<SessionSummaryRow>(`
SELECT id, title, status, pinned, agent_id, created_at, updated_at
FROM cowork_sessions
WHERE COALESCE(hidden, 0) = 0
ORDER BY pinned DESC, updated_at DESC
`);
}
Expand Down Expand Up @@ -1575,6 +1578,7 @@ export class CoworkStore {
const clauses: string[] = [
"m.type IN ('user', 'assistant')",
`(${likeClauses.join(' OR ')})`,
'COALESCE(s.hidden, 0) = 0',
];
const params: Array<string | number> = terms.map((term) => `%${term}%`);

Expand Down Expand Up @@ -1656,7 +1660,7 @@ export class CoworkStore {
const beforeMs = parseTimeToMs(options.before);
const afterMs = parseTimeToMs(options.after);

const clauses: string[] = [];
const clauses: string[] = ['COALESCE(hidden, 0) = 0'];
const params: Array<string | number> = [];

if (beforeMs !== null) {
Expand All @@ -1668,7 +1672,7 @@ export class CoworkStore {
params.push(afterMs);
}

const whereClause = clauses.length ? `WHERE ${clauses.join(' AND ')}` : '';
const whereClause = `WHERE ${clauses.join(' AND ')}`;

const rows = this.getAll<{
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/main/libs/openclawChannelSessionSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export class OpenClawChannelSessionSync {

const cwd = this.getDefaultCwd();
console.log('[ChannelSessionSync] creating main agent session: key=', sessionKey, 'cwd=', cwd);
const session = this.coworkStore.createSession('[OpenClaw]', cwd, '', 'local');
const session = this.coworkStore.createSession('[OpenClaw]', cwd, '', 'local', [], 'main', { hidden: true });
console.log('[ChannelSessionSync] created main agent session:', session.id);

this.syncedSessionKeys.set(sessionKey, session.id);
Expand Down
13 changes: 13 additions & 0 deletions src/main/sqliteStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ export class SqliteStore {
// Column already exists or migration not needed.
}

// Migration: Add hidden column to cowork_sessions
try {
const sessionCols2 = this.db.exec("PRAGMA table_info(cowork_sessions);");
const sessionColNames2 = sessionCols2[0]?.values.map((row) => row[1]) || [];
if (!sessionColNames2.includes('hidden')) {
this.db.run('ALTER TABLE cowork_sessions ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0;');
this.db.run("UPDATE cowork_sessions SET hidden = 1 WHERE title = '[OpenClaw]';");
this.save();
}
} catch {
// Column already exists or migration not needed.
}

// Migration: Ensure default 'main' agent exists
try {
const mainAgent = this.db.exec("SELECT id FROM agents WHERE id = 'main'");
Expand Down