Skip to content

Conversation

@logancyang
Copy link
Owner

@logancyang logancyang commented Nov 9, 2025

Addresses #1967

Copy link

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

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.

ℹ️ 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 on lines +317 to +328
handleSelectionChange() {
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!activeView || !activeView.editor) {
return;
}

const editor = activeView.editor;
const selectedText = editor.getSelection();

// Only process non-empty selections
if (!selectedText || !selectedText.trim()) {
return;

Choose a reason for hiding this comment

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

P1 Badge Clear selected-text context when selection is removed

The new selectionchange handler only calls handleSelectionChange when the editor selection contains text, but it never clears the selected-text context when the user deselects everything. After selecting a fragment once, selectedTextContexts remains populated indefinitely, so subsequent chats keep reusing the stale selection and Chat.tsx suppresses active-note context via effectiveIncludeActiveNote even though nothing is currently selected. Consider calling clearSelectionContext() whenever editor.getSelection() returns an empty string to avoid persisting outdated context.

Useful? React with 👍 / 👎.

Copy link
Owner Author

Choose a reason for hiding this comment

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

When focus shifts to copilot chat input, the selection is lost, so we can't clear it from context otherwise it won't ever be added to context.

@logancyang logancyang merged commit 72f3446 into master Nov 9, 2025
2 checks passed
@logancyang logancyang deleted the auto-add-selection branch November 9, 2025 23:41
@logancyang logancyang mentioned this pull request Nov 12, 2025
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