Add configurable working directory for dev server scripts (Vibe Kanban) (#1559)
* The implementation is complete. Here's a summary of all the changes made: ## Summary Added the ability for users to specify a working directory for dev server scripts: ### Files Changed: 1. **Database migration** - `crates/db/migrations/20251216000000_add_dev_script_working_dir_to_projects.sql` - Added `dev_script_working_dir TEXT DEFAULT ''` column 2. **Rust model** - `crates/db/src/models/project.rs` - Added `dev_script_working_dir` field to `Project` and `UpdateProject` structs - Updated all SQL queries 3. **Dev server execution** - `crates/server/src/routes/task_attempts.rs` - `start_dev_server` now passes `project.dev_script_working_dir` to the script executor 4. **Backfill logic** - `crates/services/src/services/container.rs` - Changed `backfill_repo_names` to set `dev_script_working_dir` instead of prepending `cd ./repo &&` 5. **Frontend UI** - `frontend/src/pages/settings/ProjectSettings.tsx` - Added input field for "Dev Server Working Directory" 6. **Translations** - `frontend/src/i18n/locales/en/settings.json` - Added `devWorkingDir` label, placeholder, and helper text 7. **TypeScript types** - `shared/types.ts` - Regenerated with `dev_script_working_dir` field * Cleanup script changes for task attempt 83423e2d-0d45-47fb-a6e4-dd91a2140f91 * Both packages compile successfully. The fix is complete: 1. **`project.rs`**: Removed `.or()` fallback for `dev_script` and `dev_script_working_dir` so `None` now clears the field 2. **`container.rs`**: Updated backfill to explicitly pass the existing project name instead of `None` * Done. I've completed both review tasks: 1. Removed the comment from `container.rs` line 384 2. Added `devWorkingDir` translations to all four language files (es, ja, ko, zh-Hans) with: - `label`: The field label - `placeholder`: Example placeholder text - `helper`: Description of what the field does I also updated the `dev.helper` text in each language to reference the new working directory option instead of suggesting users manually `cd` into the repo directory. * Done. Removed both comments: 1. Removed the comment from the migration file 2. Removed the comment from `task_attempts.rs` line 1267 * Fixed. The TypeScript error in `NoServerContent.tsx` has been resolved by adding `dev_script_working_dir: null` to the `UpdateProject` data. All checks pass: - ✅ `npm run format` - completed - ✅ `npm run lint` - passed (frontend and backend) - ✅ `npx tsc --noEmit` - passed * The Korean and Chinese translations already had the updated copy without the `cd` reference. The Spanish and Japanese were updated. All the translations now have the proper helper text that references the working directory field instead of telling users to manually `cd` into the repo. * Done. I've removed the `cd my_website` line from both the Windows and Unix script placeholder examples in `scriptPlaceholders.ts`. Now the placeholder examples just show `npm run dev` without the `cd` command, since users can specify the working directory separately.
This commit is contained in:
@@ -343,7 +343,7 @@ pub trait ContainerService {
|
||||
}
|
||||
|
||||
/// Backfill repo names that were migrated with a sentinel placeholder.
|
||||
/// Also backfills dev_script for single-repo projects to prepend cd prefix.
|
||||
/// Also backfills dev_script_working_dir for single-repo projects.
|
||||
async fn backfill_repo_names(&self) -> Result<(), ContainerError> {
|
||||
let pool = &self.db().pool;
|
||||
let repos = Repo::list_needing_name_fix(pool).await?;
|
||||
@@ -364,22 +364,30 @@ pub trait ContainerService {
|
||||
|
||||
Repo::update_name(pool, repo.id, &name, &name).await?;
|
||||
|
||||
// Also update dev_script for single-repo projects
|
||||
// Also update dev_script_working_dir for single-repo projects
|
||||
let project_repos = ProjectRepo::find_by_repo_id(pool, repo.id).await?;
|
||||
for pr in project_repos {
|
||||
let all_repos = ProjectRepo::find_by_project_id(pool, pr.project_id).await?;
|
||||
if all_repos.len() == 1
|
||||
&& let Some(project) = Project::find_by_id(pool, pr.project_id).await?
|
||||
&& let Some(old_script) = &project.dev_script
|
||||
&& !old_script.is_empty()
|
||||
&& project
|
||||
.dev_script
|
||||
.as_ref()
|
||||
.map(|s| !s.is_empty())
|
||||
.unwrap_or(false)
|
||||
&& project
|
||||
.dev_script_working_dir
|
||||
.as_ref()
|
||||
.map(|s| s.is_empty())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let new_script = format!("cd ./{} && {}", name, old_script);
|
||||
Project::update(
|
||||
pool,
|
||||
pr.project_id,
|
||||
&UpdateProject {
|
||||
name: None,
|
||||
dev_script: Some(new_script),
|
||||
name: Some(project.name.clone()),
|
||||
dev_script: project.dev_script.clone(),
|
||||
dev_script_working_dir: Some(name.clone()),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user