diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-07 00:10:23 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-07 00:10:23 +0000 |
| commit | 68453478f516ae923e99df85f5642f0f865b5bcc (patch) | |
| tree | fdca9b81f7c3f4bf7d1487ea523039a4aa443032 | |
| parent | 0291a7880d29b39d7cd56a6a8be66a9b5ec3f457 (diff) | |
feat: pass selected project directory to elaborate
The elaborate call now sends working_dir from the Project dropdown.
The backend uses it (falling back to server workDir) when building
the system prompt, so AI-drafted tasks are contextualised to the
selected project.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | internal/api/elaborate.go | 10 | ||||
| -rw-r--r-- | web/app.js | 10 |
2 files changed, 15 insertions, 5 deletions
diff --git a/internal/api/elaborate.go b/internal/api/elaborate.go index d275d61..00f3297 100644 --- a/internal/api/elaborate.go +++ b/internal/api/elaborate.go @@ -86,7 +86,8 @@ func (s *Server) claudeBinaryPath() string { func (s *Server) handleElaborateTask(w http.ResponseWriter, r *http.Request) { var input struct { - Prompt string `json:"prompt"` + Prompt string `json:"prompt"` + WorkingDir string `json:"working_dir"` } if err := json.NewDecoder(r.Body).Decode(&input); err != nil { writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid JSON: " + err.Error()}) @@ -97,12 +98,17 @@ func (s *Server) handleElaborateTask(w http.ResponseWriter, r *http.Request) { return } + workDir := s.workDir + if input.WorkingDir != "" { + workDir = input.WorkingDir + } + ctx, cancel := context.WithTimeout(r.Context(), elaborateTimeout) defer cancel() cmd := exec.CommandContext(ctx, s.claudeBinaryPath(), "-p", input.Prompt, - "--system-prompt", buildElaboratePrompt(s.workDir), + "--system-prompt", buildElaboratePrompt(workDir), "--output-format", "json", "--model", "haiku", ) @@ -950,11 +950,11 @@ async function submitAnswer(taskId, questionId, answer, banner) { // ── Elaborate (Draft with AI) ───────────────────────────────────────────────── -async function elaborateTask(prompt) { +async function elaborateTask(prompt, workingDir) { const res = await fetch(`${API_BASE}/api/tasks/elaborate`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ prompt }), + body: JSON.stringify({ prompt, working_dir: workingDir }), }); if (!res.ok) { let msg = `HTTP ${res.status}`; @@ -1699,7 +1699,11 @@ if (typeof document !== 'undefined') document.addEventListener('DOMContentLoaded form.querySelectorAll('.form-error, .elaborate-banner').forEach(el => el.remove()); try { - const result = await elaborateTask(prompt); + const sel = document.getElementById('project-select'); + const workingDir = sel.value === '__new__' + ? document.getElementById('new-project-input').value.trim() + : sel.value; + const result = await elaborateTask(prompt, workingDir); // Populate form fields const f = document.getElementById('task-form'); |
