|
| 1 | +# Chat: Add Context (Attach Files) |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Tests the **Add Context** button in the Chat view, which lets users attach |
| 6 | +workspace files to a chat prompt. Attached files provide additional context to |
| 7 | +Copilot so it can give more relevant answers. The button is an icon-only flat |
| 8 | +button (tooltip: **Add Context...**) in the action bar's file reference area. |
| 9 | + |
| 10 | +After attaching, files appear as **chips** below the input area showing the |
| 11 | +file name and a close (×) button. Users can click a chip to open the file, or |
| 12 | +click × to remove it. |
| 13 | + |
| 14 | +Entry points exercised: |
| 15 | +- **Ctrl+Alt+I** (or status bar → **Open Chat**), then click the Add Context |
| 16 | + button in the action bar. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Eclipse IDE with the GitHub Copilot for Eclipse plugin installed and |
| 23 | + activated. |
| 24 | +- A signed-in Copilot account. |
| 25 | +- A Java project is open in the workspace with at least two files. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## 1. Attach files, verify chips, remove, and send with context |
| 30 | + |
| 31 | +### TC-001: Attach files via the Add Context button, verify file chips, remove a file, and send a prompt with attached context |
| 32 | + |
| 33 | +**Type:** `Happy Path` |
| 34 | +**Priority:** `P0` |
| 35 | + |
| 36 | +#### Preconditions |
| 37 | + |
| 38 | +- The Chat view is open. |
| 39 | +- The workspace contains at least two Java files. |
| 40 | + |
| 41 | +#### Steps |
| 42 | + |
| 43 | +1. Locate the **Add Context** button in the action bar (icon-only button with |
| 44 | + tooltip **Add Context...**). |
| 45 | +2. Verify the button appears as a flat icon without a visible rectangular |
| 46 | + border. |
| 47 | +3. Click the **Add Context** button. |
| 48 | +4. Verify a file picker dialog opens (title: **Search attachments**). |
| 49 | +5. Select two files from the workspace and click **OK**. |
| 50 | +6. Verify the dialog closes and two **file chips** appear below the chat input |
| 51 | + area, each showing the file name and a close (×) button. |
| 52 | +7. Click the × button on one of the file chips. |
| 53 | +8. Verify that chip is removed and only one file chip remains. |
| 54 | +9. Click on the remaining file chip's file name. |
| 55 | +10. Verify the corresponding file opens (or is revealed) in the editor. |
| 56 | +11. Type a prompt (e.g. `explain this file`) in the chat input and click |
| 57 | + **Send**. |
| 58 | +12. Wait for the Copilot turn to complete. |
| 59 | +13. Verify the response references or uses content from the attached file. |
| 60 | + |
| 61 | +#### Expected Result |
| 62 | + |
| 63 | +- The Add Context button opens the file picker dialog. |
| 64 | +- Selected files appear as removable chips below the input area. |
| 65 | +- Clicking × removes the chip. |
| 66 | +- Clicking the file name opens the file in the editor. |
| 67 | +- Sending a prompt with an attached file includes that file as context in the |
| 68 | + conversation. |
| 69 | + |
| 70 | +#### 📸 Key Screenshots |
| 71 | + |
| 72 | +- [ ] **Add Context button** — flat icon button in the action bar, no border. |
| 73 | +- [ ] **File picker dialog** — dialog showing workspace files to select. |
| 74 | +- [ ] **File chips** — two file chips visible below the chat input area. |
| 75 | +- [ ] **After removing one chip** — only one chip remaining. |
| 76 | +- [ ] **Response with context** — Copilot turn that references the attached |
| 77 | + file content. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## 2. Currently active file is shown automatically |
| 82 | + |
| 83 | +### TC-002: The currently open file appears as a reference in the action bar |
| 84 | + |
| 85 | +**Type:** `Happy Path` |
| 86 | +**Priority:** `P0` |
| 87 | + |
| 88 | +#### Preconditions |
| 89 | + |
| 90 | +- The Chat view is open. |
| 91 | +- A Java file is open and active in the editor. |
| 92 | + |
| 93 | +#### Steps |
| 94 | + |
| 95 | +1. Open a Java file in the editor (click on it in the Package Explorer or |
| 96 | + switch to an already-open tab). |
| 97 | +2. Switch focus to the Chat view. |
| 98 | +3. Observe the file reference area in the action bar. |
| 99 | + |
| 100 | +#### Expected Result |
| 101 | + |
| 102 | +- The currently active editor file is automatically shown as a reference in |
| 103 | + the action bar (displaying the file name). |
| 104 | +- Switching to a different file in the editor updates the displayed reference. |
| 105 | + |
| 106 | +#### 📸 Key Screenshots |
| 107 | + |
| 108 | +- [ ] **Current file reference** — the action bar showing the active file name |
| 109 | + as a context reference. |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Notes on failure modes |
| 114 | + |
| 115 | +- File picker dialog does not open → the Add Context button's selection |
| 116 | + listener may not be wired; check the Eclipse error log. |
| 117 | +- File chips do not appear after selection → the ReferencedFileService may not |
| 118 | + have received the files; verify the file selection result is non-empty. |
| 119 | +- Clicking × does not remove the chip → the close button's mouse listener |
| 120 | + may not be attached; check the ReferencedFile widget. |
0 commit comments