Skip to content

[Codex] Add selected-text prompts and configurable Chat mode - #30865

Closed
bbnotcode wants to merge 1 commit into
raycast:mainfrom
bbnotcode:codex/selected-text-thread
Closed

bbnotcode wants to merge 1 commit into
raycast:mainfrom
bbnotcode:codex/selected-text-thread

Conversation

@bbnotcode

Copy link
Copy Markdown

Description

Selecting text in another application currently requires copying it before starting a chat from Raycast. Add New Thread from Selected Text, a no-view command that reads the selection before changing application focus and prefills a new chat. Empty or unreadable selections show feedback without launching a chat or falling back to the clipboard.

  • Add Selected Text Prompt Prefix: optional instructions followed by a blank line and the selected text.
  • Add Default Chat Mode, defaulting to ordinary ChatGPT Chat for all New Thread commands, with Codex as an option. Use an explicit mode parameter in the desktop deeplink.
  • In Chat mode, omit working directories and skip folder/history loading in the prompt form. Codex mode retains directory validation and selection.
  • Update README and CHANGELOG with setup instructions and limitations.

Related to #30825.

Behavior and compatibility

This changes the default behavior of existing New Thread commands to Chat. Users can choose Codex in the new preference to restore coding tasks. Maintainer feedback on this default is welcome.

The desktop deeplink prefills the composer; it does not automatically send the message. This targets the main Chat page, not the floating Quick Chat window. The mode=chat and mode=codex routing was checked against the installed desktop app's URL parser; it is not presented as a documented public API guarantee.

Validation

  • npm run build — passed; local Raycast distribution updated.
  • npx tsc --noEmit — passed.
  • npm run lint — passed.
  • npm test — 4 existing tests passed.
  • Local mocked checks passed for default/explicit Chat and Codex routing, directory omission in Chat mode, Unicode and special-character prompt encoding, prefix composition, empty/unreadable selections, and launch failure handling.
  • git diff --check — passed.

Screencast

Pending. This PR is a draft because a real cross-application selection → Raycast → desktop Chat verification and recording have not been completed. Desktop UI automation was unavailable in the development environment.

Manual verification: set a prefix, select multiline text in another application, invoke the new command, and verify Chat mode and the prefilled prompt. Also verify an empty selection, clipboard/manual prompt entry, and switching the preference back to Codex with a working directory.

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: codex Issues related to the codex extension platform: macOS labels Sep 7, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

🔔 @asifk987 you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="codex/selected-text-thread"
FORK_URL="https://github.com/bbnotcode/raycast-extensions.git"
EXTENSION_NAME="codex"
REPO_NAME="raycast-extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 15 business days.

@bbnotcode
bbnotcode marked this pull request as ready for review September 7, 2026 14:16
@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a no-view command that prefills ChatGPT from selected text, introduces configurable Chat/Codex routing for all New Thread commands, and hides working-directory functionality in Chat mode.

  • Adds selected-text prompt composition with an optional reusable prefix.
  • Adds explicit desktop deeplink mode routing and Codex-only path handling.
  • Gates directory/history loading and form controls by the selected mode.
  • Updates the extension manifest, README, and changelog.

Confidence Score: 4/5

The implementation appears functionally safe, but the pull request must be undrafted to satisfy the repository requirement; the metadata mismatch and missing deeplink tests should also be addressed.

No concrete runtime failure was established, but the manifest now misdescribes the default New Thread behavior, the shared undocumented deeplink mapping lacks committed regression coverage, and the draft state violates an explicit repository requirement.

Files Needing Attention: extensions/codex/package.json, extensions/codex/src/utils/launch.ts

Important Files Changed

Filename Overview
extensions/codex/src/utils/launch.ts Adds shared Chat/Codex mode resolution and mode-aware desktop deeplink construction; focused regression tests are missing.
extensions/codex/src/new-thread-from-selected-text.ts Safely reads selected text before changing focus, refuses empty or unreadable selections, composes the configured prefix, and launches the shared chat flow.
extensions/codex/src/new-thread-with-prompt.tsx Skips directory-related loading and controls in Chat mode while retaining existing Codex directory selection and validation.
extensions/codex/src/utils/selected-text-prompt.ts Normalizes selected text and adds the optional instruction prefix with the documented blank-line separator.
extensions/codex/package.json Registers the selected-text command and mode preferences, but New Thread descriptions remain Codex-specific despite the new Chat default.
Prompt To Fix All With AI
### Issue 1
extensions/codex/package.json:111
**Descriptions promise wrong mode.** The new preference defaults every New Thread command to ordinary ChatGPT Chat, but all four command descriptions say they start a Codex thread. Raycast therefore advertises a different action from the default behavior, which can mislead users. Update the affected descriptions to explain that the mode is configurable.

### Issue 2
extensions/codex/src/utils/launch.ts:125-133
**Deeplink routing lacks tests.** The new URL builder controls explicit Chat/Codex routing and conditionally includes the working directory for every New Thread command, but the committed tests do not cover these parameters. Since this desktop protocol is undocumented, add focused URL-construction tests so routing changes cannot silently break all New Thread commands.

### Issue 3
extensions/codex/package.json:80
**Pull request remains draft.** The pull request is still marked as a draft, which violates the repository directive that pull requests must be undrafted before team review. This repository requirement must be satisfied before merging.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(codex): add selected-text prompts a..." | Re-trigger Greptile

"description": "Mode used by all New Thread commands. Working directory settings apply only to Codex mode.",
"type": "dropdown",
"required": false,
"default": "chat",

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.

P2 Descriptions promise wrong mode. The new preference defaults every New Thread command to ordinary ChatGPT Chat, but all four command descriptions say they start a Codex thread. Raycast therefore advertises a different action from the default behavior, which can mislead users. Update the affected descriptions to explain that the mode is configurable.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/codex/package.json
Line: 111

Comment:
**Descriptions promise wrong mode.** The new preference defaults every New Thread command to ordinary ChatGPT Chat, but all four command descriptions say they start a Codex thread. Raycast therefore advertises a different action from the default behavior, which can mislead users. Update the affected descriptions to explain that the mode is configurable.

**Knowledge Base Used:**
- [Extension catalog and package model](https://app.greptile.com/raycast/-/custom-context/knowledge-base/raycast/extensions/-/docs/extension-catalog.md)
- [Extension package contract](https://app.greptile.com/raycast/-/custom-context/knowledge-base/raycast/extensions/-/docs/extension-package-contract.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +125 to 133
const params = new URLSearchParams({ mode });

if (prompt) {
params.set("prompt", prompt);
}

if (path) {
if (path && mode === "codex") {
params.set("path", path);
}

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.

P2 Deeplink routing lacks tests. The new URL builder controls explicit Chat/Codex routing and conditionally includes the working directory for every New Thread command, but the committed tests do not cover these parameters. Since this desktop protocol is undocumented, add focused URL-construction tests so routing changes cannot silently break all New Thread commands.

Knowledge Base Used: Extension command implementation patterns

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/codex/src/utils/launch.ts
Line: 125-133

Comment:
**Deeplink routing lacks tests.** The new URL builder controls explicit Chat/Codex routing and conditionally includes the working directory for every New Thread command, but the committed tests do not cover these parameters. Since this desktop protocol is undocumented, add focused URL-construction tests so routing changes cannot silently break all New Thread commands.

**Knowledge Base Used:** [Extension command implementation patterns](https://app.greptile.com/raycast/-/custom-context/knowledge-base/raycast/extensions/-/docs/extension-command-implementation.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

]
},
{
"name": "new-thread-from-selected-text",

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.

P2 Pull request remains draft. The pull request is still marked as a draft, which violates the repository directive that pull requests must be undrafted before team review. This repository requirement must be satisfied before merging.

Rule Used: Pull requests must be undrafted before they can be... (source)

Learned From
raycast/extensions#18182

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/codex/package.json
Line: 80

Comment:
**Pull request remains draft.** The pull request is still marked as a draft, which violates the repository directive that pull requests must be undrafted before team review. This repository requirement must be satisfied before merging.

**Rule Used:** Pull requests must be undrafted before they can be... ([source](https://app.greptile.com/raycast/-/custom-context?memory=d302c23a-ba3d-4c77-9e77-90f49f817dce))

**Learned From**
[raycast/extensions#18182](https://github.com/raycast/extensions/pull/18182)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@asifk987

asifk987 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@bbnotcode Thanks for this, and the mode idea is a good catch. I hadn't realized the app just keeps whatever mode it was last in when the link doesn't carry one, so today my New Thread commands drift depending on how you last used Codex. Setting it explicitly is the right fix, but I'm landing it a bit differently. Default to codex rather than chat, so the existing commands keep doing what their names say and nobody's Default Working Directory stops applying to them after an update. The app takes a third value too (mode=work for ChatGPT Work), so the global preference will offer all three. I'm also keeping path on the URL in every mode, since I tested work with a directory attached and it opens fine.

On the selected text command, I already had that built and it's going out in the next release, so I'll land mine (our implementations came out nearly identical). The prompt prefix is the one piece you had that I didn't, so I'm taking that and crediting you for it. I scoped that preference to the command rather than the whole extension since it only applies to the new selected text command.

Lots of other updates and new commands as well that I'll open a PR for later today!

@0xdhrv 0xdhrv self-assigned this Sep 8, 2026
@asifk987 asifk987 mentioned this pull request Sep 8, 2026
5 tasks done
@0xdhrv

0xdhrv commented Sep 11, 2026

Copy link
Copy Markdown
Member

Closing this based on the above discussion.

@asifk987 checking if you add @bbnotcode as contributor?

@0xdhrv 0xdhrv closed this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension: codex Issues related to the codex extension extension fix / improvement Label for PRs with extension's fix improvements platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants