mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-07 12:18:44 +02:00
feat: add scratchpad chat sessions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,7 @@ export interface RunTurnCommand {
|
||||
requestId: string;
|
||||
sessionId: string;
|
||||
projectPath: string;
|
||||
workspaceKind?: 'project' | 'scratchpad';
|
||||
pattern: PatternDefinition;
|
||||
messages: ChatMessageRecord[];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,44 @@
|
||||
import { nowIso } from '@shared/utils/ids';
|
||||
|
||||
export interface ProjectRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
path: string;
|
||||
addedAt: string;
|
||||
}
|
||||
|
||||
export const SCRATCHPAD_PROJECT_ID = 'project-scratchpad';
|
||||
export const SCRATCHPAD_PROJECT_NAME = 'Scratchpad';
|
||||
|
||||
export function createScratchpadProject(path: string, addedAt = nowIso()): ProjectRecord {
|
||||
return {
|
||||
id: SCRATCHPAD_PROJECT_ID,
|
||||
name: SCRATCHPAD_PROJECT_NAME,
|
||||
path,
|
||||
addedAt,
|
||||
};
|
||||
}
|
||||
|
||||
export function isScratchpadProject(projectIdOrProject?: string | Pick<ProjectRecord, 'id'>): boolean {
|
||||
if (!projectIdOrProject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
(typeof projectIdOrProject === 'string' ? projectIdOrProject : projectIdOrProject.id)
|
||||
=== SCRATCHPAD_PROJECT_ID
|
||||
);
|
||||
}
|
||||
|
||||
export function mergeScratchpadProject(existingProjects: ProjectRecord[], scratchpadPath: string): ProjectRecord[] {
|
||||
const existingScratchpad = existingProjects.find((project) => isScratchpadProject(project));
|
||||
const scratchpadProject = createScratchpadProject(
|
||||
scratchpadPath,
|
||||
existingScratchpad?.addedAt ?? nowIso(),
|
||||
);
|
||||
|
||||
return [
|
||||
scratchpadProject,
|
||||
...existingProjects.filter((project) => !isScratchpadProject(project.id)),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user