Skip to content

Commit ddfd891

Browse files
MrFlounderclaude
andcommitted
feat(draw): make sessions global across workspaces
Store draw sessions in ~/.crabcode/draw/<project-alias>/ instead of per-workspace .crab/draw/, matching the crab wip storage pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b71744d commit ddfd891

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

plugins/draw/src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ function showHelp(): void {
7373
console.log(' --port <port> Use specific port (default: auto from 7220)');
7474
console.log(' --help, -h Show this help');
7575
console.log('');
76-
console.log('Sessions are saved to .crab/draw/ in your project directory.');
77-
console.log('Commit them to git so teammates can access them with the same commands.');
76+
console.log('Sessions are saved globally to ~/.crabcode/draw/.');
77+
console.log('They are shared across all workspaces in the same project.');
7878
}
7979

8080
async function main(): Promise<void> {

plugins/draw/src/commands/open.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function openSession(projectRoot: string, opts: OpenOptions): Promi
9595
httpServer.close();
9696
if (tunnel) tunnel.close();
9797

98-
console.log(`Session saved to .crab/draw/${opts.sessionId}/`);
98+
console.log(`Session saved: ${opts.sessionId}`);
9999
process.exit(0);
100100
};
101101

plugins/draw/src/commands/start.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ export async function startSession(projectRoot: string, opts: StartOptions): Pro
112112
httpServer.close();
113113
if (tunnel) tunnel.close();
114114

115-
console.log(`Session saved to .crab/draw/${sessionId}/`);
116-
console.log(` Drawing: .crab/draw/${sessionId}/drawing.excalidraw`);
115+
console.log(`Session saved: ${sessionId}`);
117116
console.log(` Reopen: crab draw ${sessionId}\n`);
118117

119118
process.exit(0);

plugins/draw/src/storage/sessions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import fs from 'node:fs';
2+
import os from 'node:os';
23
import path from 'node:path';
34
import type { DrawSession, ExcalidrawElement } from '../types.js';
45

5-
function drawDir(projectRoot: string): string {
6-
return path.join(projectRoot, '.crab', 'draw');
6+
function drawDir(_projectRoot: string): string {
7+
const configDir = process.env.CRAB_CONFIG_DIR || path.join(os.homedir(), '.crabcode');
8+
const projectAlias = process.env.CRAB_PROJECT_ALIAS;
9+
const base = path.join(configDir, 'draw');
10+
return projectAlias ? path.join(base, projectAlias) : base;
711
}
812

913
function sessionDir(projectRoot: string, id: string): string {

src/crabcode

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7599,7 +7599,7 @@ handle_draw_command() {
75997599
draw_help
76007600
else
76017601
# No args = start new session
7602-
CRAB_PROJECT_ROOT="${REPO_PATH:-$(pwd)}" node "$PLUGIN_DIR/dist/cli.js" "$@"
7602+
CRAB_PROJECT_ROOT="${REPO_PATH:-$(pwd)}" CRAB_CONFIG_DIR="$CONFIG_DIR" CRAB_PROJECT_ALIAS="$PROJECT_ALIAS" node "$PLUGIN_DIR/dist/cli.js" "$@"
76037603
fi
76047604
;;
76057605
*)
@@ -7614,7 +7614,7 @@ handle_draw_command() {
76147614
return 1
76157615
fi
76167616
# Pass all args to the Node.js CLI
7617-
CRAB_PROJECT_ROOT="${REPO_PATH:-$(pwd)}" node "$PLUGIN_DIR/dist/cli.js" "$@"
7617+
CRAB_PROJECT_ROOT="${REPO_PATH:-$(pwd)}" CRAB_CONFIG_DIR="$CONFIG_DIR" CRAB_PROJECT_ALIAS="$PROJECT_ALIAS" node "$PLUGIN_DIR/dist/cli.js" "$@"
76187618
;;
76197619
esac
76207620
}

0 commit comments

Comments
 (0)