Skip to content

fix(task): respect configured directory when editing tasks - #10955

Merged
jdx merged 13 commits into
jdx:mainfrom
risu729:codex-20260712-220427-32cf60
Jul 13, 2026
Merged

jdx merged 13 commits into
jdx:mainfrom
risu729:codex-20260712-220427-32cf60

Conversation

@risu729

@risu729 risu729 commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • choose the first existing directory from the effective task_config.includes list when creating a file task
  • preserve default include behavior, using the first default entry only when no default directory exists
  • return an error instead of silently using a default directory when explicit includes contain no existing directory
  • edit existing tasks at their known source without requiring a file-task creation directory

Behavioral decision

Explicit include paths are not auto-created. An entry may represent a task TOML file or a directory, so mise must not infer the type of a path that does not exist. For example, with includes = ["tasks"]:

  • if tasks/ exists, a new file task is created there;
  • if tasks does not exist, the command returns an error and does not create either tasks/ or mise-tasks/;
  • the user should create the intended directory before running mise tasks edit or mise tasks add --file.

This matches the clarification in Discussion #10954. Built-in default includes are known directory paths, so when none exist mise may still create the first effective default entry.

Root cause

Task::task_dir fell back to mise-tasks whenever no include expanded to an existing directory. That ignored the replacement semantics of an explicit task_config.includes value and could create a task outside the configured include paths.

Validation

  • mise run lint-fix
  • cargo check --all-features
  • mise run test:e2e e2e/tasks/test_task_edit_nested_names
  • shellcheck -x e2e/tasks/test_task_edit_nested_names

Addresses #10954

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Task include resolution now selects file-task creation directories from effective includes, propagates invalid-directory errors, and preserves inline-task handling. End-to-end coverage verifies defaults, explicit includes, ordering, ambiguity, and replacement behavior.

Changes

Task include resolution

Layer / File(s) Summary
Include pattern resolution
src/config/mod.rs
Effective include patterns and their resolution base are selected, expanded, and deduplicated.
Configured task directory selection
src/config/mod.rs, src/task/mod.rs
File-task creation selects the first existing configured directory and returns an error when no valid target can be determined.
Command integration and end-to-end validation
src/cli/tasks/add.rs, src/cli/tasks/edit.rs, e2e/tasks/test_task_edit_nested_names
Task commands propagate directory errors; tests cover default and explicit includes, include ordering, ambiguity, default replacement, and inline tasks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TasksEdit
  participant TaskTaskDir
  participant Config
  participant Filesystem
  User->>TasksEdit: edit task with --path
  TasksEdit->>TaskTaskDir: resolve task directory
  TaskTaskDir->>Config: resolve effective includes
  Config-->>TaskTaskDir: include patterns and resolution base
  TaskTaskDir->>Filesystem: inspect candidate directories
  Filesystem-->>TaskTaskDir: selected directory or error
  TaskTaskDir-->>TasksEdit: return path or propagate failure
  TasksEdit-->>User: create task file or display failure
Loading

Possibly related PRs

  • jdx/mise#10191: Changes task include resolution and base-directory handling in src/config/mod.rs.
  • jdx/mise#10225: Modifies task-include expansion and path resolution used by task directory selection.

Poem

A bunny hopped through tasks bright,
Found configured paths just right.
Missing trails now clearly say,
Where new task files should be placed today.
Hop, hop—edits take flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: task editing now respects configured directories.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes mise tasks edit and mise tasks add --file to respect explicitly configured task_config.includes when selecting the directory for new file tasks. The old Task::task_dir() always fell back to mise-tasks when no include resolved to an existing directory, silently ignoring explicit includes replacement semantics.

  • Extracts task_include_patterns_for_dir to carry a uses_defaults flag, then adds task_creation_dir_for_dir which picks the first existing include directory, falls back to the first default path when none exists under the built-in defaults, and returns an error when explicit includes contain no existing directory.
  • Changes Task::task_dir() to return Result<PathBuf> and updates both callers (edit.rs, add.rs) to propagate the error with ?.
  • In edit.rs, moves the task_dir() call inside the else branch so it is never invoked when editing an already-known task.

Confidence Score: 5/5

Safe to merge — changes are narrowly scoped to task directory selection with correct error propagation throughout the call chain.

The new task_creation_dir_for_dir correctly separates default-include fallback from explicit-include error paths, task_dir() now returns Result and both callers propagate it, and the key fix in edit.rs defers task_dir() to the new-task branch only. Six new e2e scenarios validate all boundary conditions.

No files require special attention.

Important Files Changed

Filename Overview
src/config/mod.rs Refactors task include resolution into task_include_patterns_for_dir (private) and adds task_creation_dir_for_dir (public), correctly distinguishing default vs. explicit includes and returning an error for explicit includes with no existing directory.
src/task/mod.rs Changes task_dir() signature from async fn -> PathBuf to async fn -> Result<PathBuf>, delegating to task_creation_dir_for_dir and propagating errors properly.
src/cli/tasks/edit.rs Moves task_dir() call into the else branch so it is only invoked for new tasks, not for editing existing ones; propagates the error with ?.
src/cli/tasks/add.rs Single-line change: adds ? to propagate the Result from the updated task_dir().await.
e2e/tasks/test_task_edit_nested_names Adds comprehensive e2e tests covering: default-include fallback to first existing directory, error on missing explicit directory, first-existing-dir selection, multiple-missing error, file-only includes (no directory), and editing inline tasks with empty includes.

Reviews (11): Last reviewed commit: "refactor(task): iterate task include dir..." | Re-trigger Greptile

@risu729

risu729 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

This comment was generated by an AI coding assistant.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

@risu729: Sure, I'll review the changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@risu729

risu729 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

This comment was generated by an AI coding assistant.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

@risu729: Sure, I'll review the changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@risu729
risu729 marked this pull request as ready for review July 12, 2026 17:30
@jdx
jdx merged commit 16d6541 into jdx:main Jul 13, 2026
33 checks passed
@risu729
risu729 deleted the codex-20260712-220427-32cf60 branch July 14, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants