Skip to content
Snippets Groups Projects

Use selected text in base prompt if present

Merged Jan Provaznik requested to merge jp-tasks-code into master
All threads resolved!

What does this MR do and why?

When user selects some code, it makes sense to include this in the prompt (and prefer over blob from referrer).

Related to #431359 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. In rails console enable code_tasks
    Feature.enable(:code_tasks)
  2. Open gitlab duo chat UI
  3. In a separate browser tab open graphql-explorer and send message request below:
mutation {
  aiAction(input: {chat: {content: "Refactor selected code", currentFile: {
    fileName: "test.py",
    selectedText: "
def extract
  lines = content.to_s.lines
  comment_block = []
  trimmed_lines = 0
end
",
    contentAboveCursor: "
module CodeSuggestions
  class InstructionsExtractor
    EMPTY_LINES_LIMIT = 1
    MIN_LINES_OF_CODE = 5
",
  }}}) {
    clientMutationId
    errors
  }
}
  1. check in chat UI that an answer relevant to the selected text is returned

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jan Provaznik

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Jan Provaznik changed the description

    changed the description

  • Contributor

    Allure report

    allure-report-publisher generated test report!

    e2e-test-on-gdk: :white_check_mark: test report for 3d67c48c

    expand test summary
    +-----------------------------------------------------------------------+
    |                            suites summary                             |
    +------------------+--------+--------+---------+-------+-------+--------+
    |                  | passed | failed | skipped | flaky | total | result |
    +------------------+--------+--------+---------+-------+-------+--------+
    | Plan             | 55     | 0      | 0       | 0     | 55    | ✅     |
    | Verify           | 32     | 0      | 0       | 0     | 32    | ✅     |
    | Govern           | 48     | 0      | 0       | 0     | 48    | ✅     |
    | Monitor          | 4      | 0      | 0       | 0     | 4     | ✅     |
    | Create           | 40     | 0      | 7       | 0     | 47    | ✅     |
    | Data Stores      | 22     | 0      | 0       | 0     | 22    | ✅     |
    | Framework sanity | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Package          | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Manage           | 0      | 0      | 1       | 0     | 1     | ➖     |
    +------------------+--------+--------+---------+-------+-------+--------+
    | Total            | 201    | 0      | 10      | 0     | 211   | ✅     |
    +------------------+--------+--------+---------+-------+-------+--------+

    e2e-package-and-test: :white_check_mark: test report for 3d67c48c

    expand test summary
    +-----------------------------------------------------------------------+
    |                            suites summary                             |
    +------------------+--------+--------+---------+-------+-------+--------+
    |                  | passed | failed | skipped | flaky | total | result |
    +------------------+--------+--------+---------+-------+-------+--------+
    | Create           | 539    | 0      | 88      | 0     | 627   | ✅     |
    | Govern           | 6      | 0      | 0       | 0     | 6     | ✅     |
    | Monitor          | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Framework sanity | 0      | 0      | 2       | 0     | 2     | ➖     |
    | Plan             | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Data Stores      | 4      | 0      | 0       | 0     | 4     | ✅     |
    | Package          | 0      | 0      | 2       | 0     | 2     | ➖     |
    +------------------+--------+--------+---------+-------+-------+--------+
    | Total            | 565    | 0      | 92      | 0     | 657   | ✅     |
    +------------------+--------+--------+---------+-------+-------+--------+
  • Jan Provaznik added 195 commits

    added 195 commits

    Compare with previous version

  • Jan Provaznik changed the description

    changed the description

  • Jan Provaznik requested review from @nicolasdular

    requested review from @nicolasdular

  • Nicolas Dular approved this merge request

    approved this merge request

  • Nicolas Dular requested review from @mksionek

    requested review from @mksionek

  • Jan Provaznik added 1 commit

    added 1 commit

    • 3d67c48c - Rename current_file to current_file_context

    Compare with previous version

  • LGTM

  • Gosia Ksionek approved this merge request

    approved this merge request

  • Gosia Ksionek resolved all threads

    resolved all threads

  • merged

  • Gosia Ksionek mentioned in commit 9cdc7b76

    mentioned in commit 9cdc7b76

  • added workflowstaging label and removed workflowcanary label

  • Please register or sign in to reply
    Loading