Repository navigation
Add project script actions with shortcuts, persistence, and setup-run support #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4f36062
Add project script actions with run shortcuts and persistence
juliusmarminge 1327646
Support script editing and persist project keybindings
juliusmarminge 56bce56
Fix web typecheck for optional script env
juliusmarminge b7cf04b
Address PR review feedback for scripts/keybindings handling
juliusmarminge 718a682
Address second-pass PR feedback on parser hardening
juliusmarminge 5f94bfd
Fix Windows percent escaping in script env injection
juliusmarminge 4437965
Label setup scripts in project action menu
juliusmarminge dca0b9f
Refactor project script persistence flow in ChatView
juliusmarminge 191883e
Fix keybindings parse error wrapping behavior
juliusmarminge 442bab6
Require modifier keys for script keybinding capture
juliusmarminge 0e500fe
Pass runtime env through terminal open and disable zsh prompt spacer
juliusmarminge 2a5525a
Reset script dialog state after close animation
juliusmarminge b033c60
Handle optional terminal dimensions and preserve active terminal size
juliusmarminge e31fcbd
Fix terminal stability bugs: remove autoFocus from effect deps, stabi…
cursoragent 58a7840
Remove dead code: unused shell env injection functions
cursoragent 2780666
refactor: extract shared normalizeProjectScripts into @t3tools/contracts
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| import { afterEach, describe, expect, it } from "vitest"; | ||
|
|
||
| import { ProjectRegistry } from "./projectRegistry"; | ||
|
|
||
| const tempDirs: string[] = []; | ||
|
|
||
| function makeTempDir(prefix: string): string { | ||
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix)); | ||
| tempDirs.push(dir); | ||
| return dir; | ||
| } | ||
|
|
||
| afterEach(() => { | ||
| for (const dir of tempDirs.splice(0, tempDirs.length)) { | ||
| fs.rmSync(dir, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
|
|
||
| describe("ProjectRegistry scripts", () => { | ||
| it("stores and reloads project scripts", () => { | ||
| const stateDir = makeTempDir("t3code-project-registry-state-"); | ||
| const projectDir = makeTempDir("t3code-project-registry-project-"); | ||
| const registry = new ProjectRegistry(stateDir); | ||
|
|
||
| const created = registry.add({ cwd: projectDir }).project; | ||
| const updated = registry.updateScripts({ | ||
| id: created.id, | ||
| scripts: [ | ||
| { | ||
| id: "run", | ||
| name: "Run", | ||
| command: "bun run dev", | ||
| icon: "play", | ||
| runOnWorktreeCreate: false, | ||
| }, | ||
| { | ||
| id: "setup", | ||
| name: "Setup", | ||
| command: "bun install", | ||
| icon: "configure", | ||
| runOnWorktreeCreate: true, | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| expect(updated.project.scripts).toHaveLength(2); | ||
| expect(updated.project.scripts[1]?.id).toBe("setup"); | ||
| expect(updated.project.scripts[1]?.runOnWorktreeCreate).toBe(true); | ||
|
|
||
| const reloaded = new ProjectRegistry(stateDir); | ||
| const listed = reloaded.list(); | ||
| expect(listed).toHaveLength(1); | ||
| expect(listed[0]?.scripts).toHaveLength(2); | ||
| expect(listed[0]?.scripts[0]?.id).toBe("run"); | ||
| expect(listed[0]?.scripts[1]?.id).toBe("setup"); | ||
| }); | ||
|
|
||
| it("deduplicates script ids and allows only one setup script", () => { | ||
| const stateDir = makeTempDir("t3code-project-registry-state-"); | ||
| const projectDir = makeTempDir("t3code-project-registry-project-"); | ||
| const registry = new ProjectRegistry(stateDir); | ||
| const created = registry.add({ cwd: projectDir }).project; | ||
|
|
||
| const updated = registry.updateScripts({ | ||
| id: created.id, | ||
| scripts: [ | ||
| { | ||
| id: "setup", | ||
| name: "Setup", | ||
| command: "echo setup", | ||
| icon: "configure", | ||
| runOnWorktreeCreate: true, | ||
| }, | ||
| { | ||
| id: "setup", | ||
| name: "Setup Duplicate", | ||
| command: "echo duplicate", | ||
| icon: "configure", | ||
| runOnWorktreeCreate: true, | ||
| }, | ||
| { | ||
| id: "another", | ||
| name: "Another Setup", | ||
| command: "echo another", | ||
| icon: "play", | ||
| runOnWorktreeCreate: true, | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| expect(updated.project.scripts).toHaveLength(2); | ||
| expect(updated.project.scripts[0]?.id).toBe("setup"); | ||
| expect(updated.project.scripts[0]?.runOnWorktreeCreate).toBe(true); | ||
| expect(updated.project.scripts[1]?.id).toBe("another"); | ||
| expect(updated.project.scripts[1]?.runOnWorktreeCreate).toBe(false); | ||
| }); | ||
|
|
||
| it("throws when updating scripts for an unknown project id", () => { | ||
| const stateDir = makeTempDir("t3code-project-registry-state-"); | ||
| const registry = new ProjectRegistry(stateDir); | ||
|
|
||
| expect(() => | ||
| registry.updateScripts({ | ||
| id: "missing-project", | ||
| scripts: [], | ||
| }), | ||
| ).toThrowError("Project not found"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.