Skip to content

fix(mcp): strip active project prefix on edit_note autocreate - #1776

Closed
ningyixi wants to merge 1 commit into
basicmachines-co:mainfrom
ningyixi:fix/edit-note-strip-project-prefix
Closed

ningyixi wants to merge 1 commit into
basicmachines-co:mainfrom
ningyixi:fix/edit-note-strip-project-prefix

Conversation

@ningyixi

Copy link
Copy Markdown
Contributor

Summary

  • edit_note append/prepend auto-create treated project-qualified identifiers (e.g. demo/scratch/note or memory://demo/scratch/note) as on-disk paths, so a missing note was created under an extra <project>/ directory.
  • Existing-note resolution already understood the project slug; creation did not.
  • Add _strip_active_project_prefix and use it before _parse_identifier_to_title_and_directory on the autocreate path. Plain paths are only stripped when permalinks_include_project is enabled, so a real folder named like the project remains reachable as demo/demo/....

Fixes #1775

Test plan

  • pytest tests/mcp/test_tool_edit_note.py -k "strip_active_project_prefix or strips_project_prefix" (9 passed)
  • Broader related suite including append/prepend autocreate and unresolved memory URL cases (17 passed)
  • ruff format / ruff check on touched files

When append/prepend auto-creates a missing note from a project-qualified
identifier (permalink or memory:// URL), drop the active project slug
before deriving the on-disk path so files are not nested under an extra
project-named directory.

Fixes basicmachines-co#1775

Signed-off-by: ningyixi <ningyixi@users.noreply.github.com>
@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T13:39:13.373591Z 2424b84 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2424b84e14

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +901 to +905
create_identifier = _strip_active_project_prefix(
identifier.strip(),
active_project.permalink,
include_project=ConfigManager().config.permalinks_include_project,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize project prefixes before disk recovery

When permalinks_include_project is true and notes/foo.md exists on disk but is not indexed yet, an append via test-project/notes/foo reaches _resolve_after_disk_recovery with the still-prefixed entity_identifier, so index-file probes only test-project/notes/foo(.md/.markdown) and misses the real file. These lines then strip the prefix and POST a create at notes/foo.md; local creation rejects the unexpected existing file (while deferred/cloud creation can accept content that cannot materialize), so the documented recovery path does not append the note. Derive and share the project-relative identifier before attempting disk recovery.

AGENTS.md reference: AGENTS.md:L157-L161

Useful? React with 👍 / 👎.

@phernandez

Copy link
Copy Markdown
Member

Thanks @ningyixi! Your fix landed in #1782 with your commit preserved (rebase-merged). We extended it so the server compares every reading of the path against the folders that exist, and refuses ambiguous or out-of-project paths.

@phernandez phernandez closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants