Skip to content

fix(shell): attach dropped image paths eagerly#2183

Open
he-yufeng wants to merge 2 commits into
MoonshotAI:mainfrom
he-yufeng:fix/macos-screenshot-thumbnail-2182
Open

fix(shell): attach dropped image paths eagerly#2183
he-yufeng wants to merge 2 commits into
MoonshotAI:mainfrom
he-yufeng:fix/macos-screenshot-thumbnail-2182

Conversation

@he-yufeng

@he-yufeng he-yufeng commented May 7, 2026

Copy link
Copy Markdown

Related Issue

Resolve #2182

Description

Prompt submission now scans literal user text for local image paths when the selected model supports image input, reads the image immediately, and sends it as an ImageURLPart instead of leaving a short-lived path for ReadMediaFile to chase later.

This keeps URLs and simple filenames as text, supports quoted paths and file:// URLs, deduplicates repeated image paths, enforces the inline image size cap, sniffs image MIME bytes, and reports explicit missing image paths without crashing the prompt router.

Added regression coverage for path attachment, capability gating, missing explicit paths, simple missing filenames, and prompt-router recovery after an image path resolution error.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open in Devin Review

@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: 06a23d8a8d

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/kimi_cli/ui/shell/prompt.py Outdated

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread src/kimi_cli/ui/shell/placeholders.py

Copy link
Copy Markdown
Author

Thanks for the reviews. I pushed c5cd3e44 to handle both points:

  • history is now written only after prompt/image-path resolution succeeds, so a disappeared explicit image path is not saved into recall history
  • duplicate resolved image paths now keep the later path text as a normal text part instead of silently consuming it

Validation:

  • python -m uv run pytest tests\ui_and_conv\test_prompt_placeholders.py tests\ui_and_conv\test_shell_prompt_router.py tests\ui_and_conv\test_prompt_tips.py::test_prompt_once_appends_history_after_command_resolves tests\ui_and_conv\test_prompt_tips.py::test_prompt_once_skips_history_when_command_resolution_fails -q
  • python -m uv run ruff check src\kimi_cli\ui\shell\prompt.py src\kimi_cli\ui\shell\placeholders.py tests\ui_and_conv\test_prompt_placeholders.py tests\ui_and_conv\test_prompt_tips.py
  • python -m py_compile src\kimi_cli\ui\shell\prompt.py src\kimi_cli\ui\shell\placeholders.py tests\ui_and_conv\test_prompt_placeholders.py tests\ui_and_conv\test_prompt_tips.py
  • git diff --check

@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: c5cd3e44e9

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/kimi_cli/ui/shell/placeholders.py Outdated
@he-yufeng he-yufeng force-pushed the fix/macos-screenshot-thumbnail-2182 branch from c5cd3e4 to a4b7ae0 Compare May 8, 2026 16:07

Copy link
Copy Markdown
Author

Thanks, pushed a4b7ae0b for the wrapper-punctuation case.

The bare-path detector now avoids starting a relative path match from common wrapper punctuation, so inputs such as (/tmp/shot.png) and ![alt](./shot.png) attach the actual image path instead of treating the wrapped prefix as part of the filename. I added regression coverage for both forms.

Validation:

  • python -m uv run pytest tests\ui_and_conv\test_prompt_placeholders.py tests\ui_and_conv\test_shell_prompt_router.py tests\ui_and_conv\test_prompt_tips.py::test_prompt_once_appends_history_after_command_resolves tests\ui_and_conv\test_prompt_tips.py::test_prompt_once_skips_history_when_command_resolution_fails -q
  • python -m uv run ruff check src\kimi_cli\ui\shell\placeholders.py tests\ui_and_conv\test_prompt_placeholders.py
  • python -m py_compile src\kimi_cli\ui\shell\placeholders.py tests\ui_and_conv\test_prompt_placeholders.py
  • git diff --check upstream/main..HEAD

@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: a4b7ae0be1

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/kimi_cli/ui/shell/placeholders.py Outdated

@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: 25c64df9f8

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

raw = path_text.replace("\\ ", " ")
if raw.lower().startswith("file://"):
parsed = urlparse(raw)
raw = unquote(parsed.path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve UNC host when expanding file:// image paths

In _expand_image_path, file:// URIs are rebuilt from parsed.path only, so the authority component is dropped. On Windows, an input like file://server/share/screenshot.png should resolve to a UNC path (\\server\share\screenshot.png), but this code turns it into /share/screenshot.png (then usually into a cwd-relative path), which causes false "no longer accessible" errors and prevents attaching valid network-share images.

Useful? React with 👍 / 👎.

@he-yufeng he-yufeng force-pushed the fix/macos-screenshot-thumbnail-2182 branch from 25c64df to e9855f8 Compare June 7, 2026 00:51
@he-yufeng

Copy link
Copy Markdown
Author

Rebased onto current main and resolved the import conflict with the new shell migration nudge code. Validation on the rebased branch: pytest tests/ui_and_conv/test_prompt_placeholders.py tests/ui_and_conv/test_shell_prompt_router.py tests/ui_and_conv/test_prompt_tips.py::test_prompt_once_appends_history_after_command_resolves tests/ui_and_conv/test_prompt_tips.py::test_prompt_once_skips_history_when_command_resolution_fails -q passed (36 passed); ruff check on touched shell/test files passed; py_compile on touched shell/test files passed; git diff --check upstream/main..HEAD passed.

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.

Bug: macOS screenshot thumbnails dropped into terminal fail to attach (TemporaryItems race)

1 participant