forked from microsoft/copilot-for-eclipse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomInstructionPreferencePage.java
More file actions
533 lines (447 loc) · 21.9 KB
/
Copy pathCustomInstructionPreferencePage.java
File metadata and controls
533 lines (447 loc) · 21.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package com.microsoft.copilot.eclipse.ui.preferences;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.ToolTip;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.EditorPart;
import com.microsoft.copilot.eclipse.core.Constants;
import com.microsoft.copilot.eclipse.core.CopilotCore;
import com.microsoft.copilot.eclipse.core.chat.CustomInstructionsChatLoadScope;
import com.microsoft.copilot.eclipse.ui.CopilotUi;
import com.microsoft.copilot.eclipse.ui.utils.PreferencesUtils;
import com.microsoft.copilot.eclipse.ui.utils.SwtUtils;
import com.microsoft.copilot.eclipse.ui.utils.UiUtils;
/**
* Preference page for GitHub Copilot Custom Instructions settings.
*/
public class CustomInstructionPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public static final String ID = "com.microsoft.copilot.eclipse.ui.preferences.CustomInstructionPreferencePage";
private BooleanFieldEditor enableWorkspaceInstrField;
private StringFieldEditor workspaceInstrField;
private StringFieldEditor gitCommitInstrField;
private Combo chatInstrLoadScopeCombo;
private static final CustomInstructionsChatLoadScope[] SCOPES = CustomInstructionsChatLoadScope.values();
// Variables to track initial preference values for change detection
private boolean initialWorkspaceEnabled;
private String initialWorkspaceInstructions;
private String initialGitCommitInstructions;
private CustomInstructionsChatLoadScope initialChatCustomInstrLoadScope;
private static final String GITHUB = ".github";
private static final String COPILOT_INSTRUCTIONS = "copilot-instructions.md";
// Constants for tooltip configuration
private static final int TOOLTIP_OFFSET_Y = 20;
private static final int TOOLTIP_AUTO_HIDE_DELAY_MS = 5000;
// Reusable GridDataFactory for group layout data
private static final GridDataFactory GROUP_GRID_DATA_FACTORY =
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false);
/**
* Constructor for CustomInstructionPreferencePage.
*/
public CustomInstructionPreferencePage() {
super(GRID);
}
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(CopilotUi.getPlugin().getPreferenceStore());
}
@Override
protected void createFieldEditors() {
Composite parent = getFieldEditorParent();
parent.setLayout(new GridLayout(1, true));
GridLayout gl = new GridLayout(1, true);
gl.marginTop = 2;
gl.marginLeft = 2;
createWorkspaceInstructionsField(parent, gl);
createProjectInstructionsField(parent, gl);
createGitCommitInstructionsField(parent, gl);
// Initialize tracking of preference values after fields are created
initializePreferenceValues();
}
/**
* Initialize the tracking variables with current preference values.
*/
private void initializePreferenceValues() {
initialWorkspaceEnabled = getPreferenceStore().getBoolean(Constants.CUSTOM_INSTRUCTIONS_WORKSPACE_ENABLED);
initialWorkspaceInstructions = getPreferenceStore().getString(Constants.CUSTOM_INSTRUCTIONS_WORKSPACE);
initialGitCommitInstructions = getPreferenceStore().getString(Constants.CUSTOM_INSTRUCTIONS_GIT_COMMIT);
initialChatCustomInstrLoadScope = PreferencesUtils.getCustomInstructionsChatLoadScope(getPreferenceStore());
updateChatInstrLoadScopeComboSelection(false);
}
/**
* Check if any preference values have changed from their initial values.
*
* @return true if any preferences have changed, false otherwise
*/
private boolean hasPreferencesChanged() {
boolean currentWorkspaceEnabled = enableWorkspaceInstrField.getBooleanValue();
String currentWorkspaceInstructions = workspaceInstrField.getStringValue();
String currentGitCommitInstructions = gitCommitInstrField.getStringValue();
CustomInstructionsChatLoadScope currentCustomInstrLoadScope = getSelectedCustomInstrLoadScope();
return currentWorkspaceEnabled != initialWorkspaceEnabled
|| !StringUtils.equals(currentWorkspaceInstructions, initialWorkspaceInstructions)
|| !StringUtils.equals(currentGitCommitInstructions, initialGitCommitInstructions)
|| !initialChatCustomInstrLoadScope.equals(currentCustomInstrLoadScope);
}
@Override
public boolean performOk() {
// Save the current preference values
initialWorkspaceEnabled = enableWorkspaceInstrField.getBooleanValue();
initialWorkspaceInstructions = workspaceInstrField.getStringValue();
initialGitCommitInstructions = gitCommitInstrField.getStringValue();
initialChatCustomInstrLoadScope = getSelectedCustomInstrLoadScope();
getPreferenceStore().setValue(Constants.CUSTOM_INSTRUCTIONS_CHAT_LOAD_SCOPE,
initialChatCustomInstrLoadScope.getValue());
// Call super to save preferences
return super.performOk();
}
@Override
protected void performDefaults() {
super.performDefaults();
updateChatInstrLoadScopeComboSelection(true);
}
private void updateChatInstrLoadScopeComboSelection(boolean useDefaultValue) {
IPreferenceStore store = getPreferenceStore();
if (chatInstrLoadScopeCombo == null || chatInstrLoadScopeCombo.isDisposed() || store == null) {
return;
}
CustomInstructionsChatLoadScope scope = useDefaultValue
? PreferencesUtils.getCustomInstructionsChatLoadScopeDefault(store)
: PreferencesUtils.getCustomInstructionsChatLoadScope(store);
// we rely here on using the enum entry order that we use in our combobox using the SCOPES array
chatInstrLoadScopeCombo.select(scope.ordinal());
}
private CustomInstructionsChatLoadScope getSelectedCustomInstrLoadScope() {
int selectionIndex = chatInstrLoadScopeCombo.getSelectionIndex();
if (selectionIndex >= 0 && selectionIndex < SCOPES.length) {
return SCOPES[selectionIndex];
} else {
return CustomInstructionsChatLoadScope.DEFAULT_VALUE;
}
}
private static String getCustomInstrLoadScopeLabel(CustomInstructionsChatLoadScope scope) {
return switch (scope) {
case ALL_PROJECTS -> Messages.preferences_page_custom_instructions_chat_load_scope_all;
case REFERENCED_PROJECTS -> Messages.preferences_page_custom_instructions_chat_load_scope_referenced;
};
}
private void createWorkspaceInstructionsField(Composite parent, GridLayout gl) {
// workspace instructions group
Group workspaceInstrGroup = new Group(parent, SWT.NONE);
workspaceInstrGroup.setLayout(gl);
GROUP_GRID_DATA_FACTORY.applyTo(workspaceInstrGroup);
workspaceInstrGroup.setText(Messages.preferences_page_custom_instructions_workspace);
// Add workspace instructions field
Composite workspaceInstrFieldContainer = new Composite(workspaceInstrGroup, SWT.NONE);
workspaceInstrFieldContainer.setLayout(gl);
workspaceInstrFieldContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Add enable workspace instructions checkbox - use same parent as workspaceInstrField
enableWorkspaceInstrField = new BooleanFieldEditor(Constants.CUSTOM_INSTRUCTIONS_WORKSPACE_ENABLED,
Messages.preferences_page_custom_instructions_workspace_enable, workspaceInstrFieldContainer);
addField(enableWorkspaceInstrField);
PreferencePageUtils.createExternalLink(workspaceInstrFieldContainer,
Messages.preferences_page_custom_instructions_copilot_instructions_desc, null);
workspaceInstrField = new StringFieldEditor(Constants.CUSTOM_INSTRUCTIONS_WORKSPACE, "",
StringFieldEditor.UNLIMITED, 4, StringFieldEditor.VALIDATE_ON_KEY_STROKE, workspaceInstrFieldContainer);
// disable the label of the input field, so that the input box can be positioned at the beginning
// of the container.
workspaceInstrField.getLabelControl(workspaceInstrFieldContainer).dispose();
addField(workspaceInstrField);
// Add note using WrappableNoteLabel
new WrappableNoteLabel(workspaceInstrGroup, Messages.preferences_page_note_prefix + " ",
Messages.preferences_page_custom_instructions_copilot_instructions_note);
}
private void createProjectInstructionsField(Composite parent, GridLayout gl) {
// project instructions group
Group projectInstrGroup = new Group(parent, SWT.NONE);
projectInstrGroup.setLayout(gl);
GROUP_GRID_DATA_FACTORY.applyTo(projectInstrGroup);
projectInstrGroup.setText(Messages.preferences_page_custom_instructions_project);
// Add project instructions field
Composite projectInstrFieldContainer = new Composite(projectInstrGroup, SWT.NONE);
GridLayout projectInstrFieldLayout = new GridLayout(1, true);
projectInstrFieldLayout.marginWidth = 0;
projectInstrFieldLayout.marginHeight = 0;
projectInstrFieldContainer.setLayout(projectInstrFieldLayout);
projectInstrFieldContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
PreferencePageUtils.createExternalLink(projectInstrFieldContainer,
Messages.preferences_page_custom_instructions_project_intro, null);
// Create a container for the table and buttons
Composite tableContainer = new Composite(projectInstrFieldContainer, SWT.NONE);
GridLayout tableLayout = new GridLayout(2, false);
tableLayout.marginWidth = 0;
tableLayout.marginHeight = 0;
tableContainer.setLayout(tableLayout);
tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Create the table
Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
table.setHeaderVisible(true);
table.setLinesVisible(true);
GridData tableGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
tableGridData.heightHint = 150; // Set a reasonable height
table.setLayoutData(tableGridData);
// Create table columns
TableColumn projectNameColumn = new TableColumn(table, SWT.LEFT);
projectNameColumn.setText(Messages.preferences_page_custom_instructions_project_table_projectName);
projectNameColumn.setWidth(150);
TableColumn fileLocationColumn = new TableColumn(table, SWT.LEFT);
fileLocationColumn.setText(Messages.preferences_page_custom_instructions_project_table_fileLocation);
// Set the file location column to take remaining width (table width - project name column width)
fileLocationColumn.setWidth(tableGridData.widthHint > 0 ? tableGridData.widthHint - 150 : 400);
// Add resize listener to make the file location column take remaining width
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(org.eclipse.swt.events.ControlEvent e) {
int tableWidth = table.getClientArea().width;
int projectNameWidth = projectNameColumn.getWidth();
int remainingWidth = tableWidth - projectNameWidth;
if (remainingWidth > 100) { // Minimum width for file location column
fileLocationColumn.setWidth(remainingWidth);
}
}
});
// Populate table with actual workspace projects
populateProjectTable(table);
// Create edit button
createButton(tableContainer, table);
// Add note using WrappableNoteLabel
new WrappableNoteLabel(projectInstrGroup, Messages.preferences_page_note_prefix + " ",
Messages.preferences_page_custom_instructions_project_table_note);
// add label and drop-down list for custom instructions loading scope options
Composite chatInstrContainer = new Composite(projectInstrGroup, SWT.NONE);
GridLayout containerLayout = new GridLayout(2, false);
containerLayout.marginWidth = 0;
containerLayout.marginHeight = 0;
chatInstrContainer.setLayout(containerLayout);
chatInstrContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Label label = new Label(chatInstrContainer, SWT.NONE);
label.setText(Messages.preferences_page_custom_instructions_chat_load_scope_label);
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
chatInstrLoadScopeCombo = new Combo(chatInstrContainer, SWT.DROP_DOWN | SWT.READ_ONLY);
String[] items = Arrays.stream(SCOPES)
.map(CustomInstructionPreferencePage::getCustomInstrLoadScopeLabel)
.toArray(String[]::new);
chatInstrLoadScopeCombo.setItems(items);
chatInstrLoadScopeCombo.setToolTipText(Messages.preferences_page_custom_instructions_chat_load_scope_combo_tooltip);
chatInstrLoadScopeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}
private void createGitCommitInstructionsField(Composite parent, GridLayout gl) {
// git commit instructions group
Group gitCommitInstrGroup = new Group(parent, SWT.NONE);
gitCommitInstrGroup.setLayout(gl);
GROUP_GRID_DATA_FACTORY.applyTo(gitCommitInstrGroup);
gitCommitInstrGroup.setText(Messages.preferences_page_custom_instructions_git_commit);
// Add git commit instructions field
Composite gitCommitInstrFieldContainer = new Composite(gitCommitInstrGroup, SWT.NONE);
gitCommitInstrFieldContainer.setLayout(gl);
gitCommitInstrFieldContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
PreferencePageUtils.createExternalLink(gitCommitInstrFieldContainer,
Messages.preferences_page_custom_instructions_git_commit_desc, null);
gitCommitInstrField = new StringFieldEditor(Constants.CUSTOM_INSTRUCTIONS_GIT_COMMIT, "",
StringFieldEditor.UNLIMITED, 4, StringFieldEditor.VALIDATE_ON_KEY_STROKE, gitCommitInstrFieldContainer);
// disable the label of the input field, so that the input box can be positioned at the beginning
// of the container.
gitCommitInstrField.getLabelControl(gitCommitInstrFieldContainer).dispose();
addField(gitCommitInstrField);
// Add note using WrappableNoteLabel
new WrappableNoteLabel(gitCommitInstrGroup, Messages.preferences_page_note_prefix + " ",
Messages.preferences_page_custom_instructions_git_commit_note);
}
private void createButton(Composite tableContainer, Table table) {
// Create button container
Composite buttonContainer = new Composite(tableContainer, SWT.NONE);
GridLayout buttonLayout = new GridLayout(1, false);
buttonContainer.setLayout(buttonLayout);
buttonContainer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
// Edit button
Button editButton = new Button(buttonContainer, SWT.PUSH);
editButton.setText(Messages.preferences_page_custom_instructions_project_table_editButton);
GridData editButtonGridData = new GridData(SWT.FILL, SWT.TOP, true, false);
editButtonGridData.widthHint = Math.max(convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH),
editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x) + 5;
editButton.setLayoutData(editButtonGridData);
editButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
handleEditButtonClick(table);
}));
// Enable/disable buttons based on selection
table.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
boolean hasSelection = table.getSelectionIndex() >= 0;
editButton.setEnabled(hasSelection);
}));
// Initially disable buttons if no selection
editButton.setEnabled(false);
}
private void handleEditButtonClick(Table table) {
int selectionIndex = table.getSelectionIndex();
if (selectionIndex < 0) {
return;
}
String projectName = table.getItem(selectionIndex).getText(0);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (project == null || !project.exists()) {
return;
}
openInstructionFile(project, projectName);
}
private void openInstructionFile(IProject project, String projectName) {
IPath projectLocation = project.getLocation();
if (projectLocation == null) {
return;
}
IFile instructionFile = project.getFolder(GITHUB).getFile(COPILOT_INSTRUCTIONS);
try {
instructionFile.refreshLocal(IFile.DEPTH_ZERO, new NullProgressMonitor());
if (!instructionFile.exists()) {
return;
}
IWorkbenchPage page = UiUtils.getActivePage();
IDE.openEditor(page, instructionFile);
promptToClosePreferencePage();
} catch (IllegalStateException | CoreException ex) {
CopilotCore.LOGGER.error("Failed to open copilot-instructions.md in editor", ex);
}
}
/**
* Shows a tooltip reminder to the user to save the file after editing.
*/
private void showSaveReminderTooltip() {
SwtUtils.getDisplay().asyncExec(() -> {
Shell activeShell = SwtUtils.getDisplay().getActiveShell();
if (activeShell == null) {
return;
}
Point tooltipPosition = tryGetEditorPosition();
if (tooltipPosition == null) {
return;
}
ToolTip tooltip = new ToolTip(activeShell, SWT.BALLOON | SWT.ICON_INFORMATION);
tooltip.setText(Messages.preferences_page_custom_instructions_project_file_save_reminder_title);
tooltip.setMessage(Messages.preferences_page_custom_instructions_project_file_save_reminder_desc);
tooltip.setLocation(tooltipPosition);
tooltip.setVisible(true);
tooltip.setAutoHide(true);
scheduleTooltipAutoHide(tooltip);
});
}
/**
* Attempts to get the position relative to the active editor.
*/
private Point tryGetEditorPosition() {
try {
IWorkbenchPage page = UiUtils.getActivePage();
if (page == null || page.getActiveEditor() == null) {
return null;
}
IEditorPart activeEditor = page.getActiveEditor();
if (!(activeEditor instanceof EditorPart)) {
return null;
}
ITextViewer textViewer = activeEditor.getAdapter(ITextViewer.class);
if (textViewer == null) {
return null;
}
// Get the text widget and its caret position
StyledText textWidget = textViewer.getTextWidget();
if (textWidget == null || textWidget.isDisposed()) {
return null;
}
// Get caret location relative to the text widget
Point caretLocation = textWidget.getLocationAtOffset(textWidget.getCaretOffset());
// Convert to display coordinates
Point displayLocation = textWidget.toDisplay(caretLocation.x, caretLocation.y);
return new Point(displayLocation.x, displayLocation.y + TOOLTIP_OFFSET_Y);
} catch (Exception e) {
CopilotCore.LOGGER.error("Failed to get editor position for tooltip", e);
return null;
}
}
/**
* Schedules the tooltip to auto-hide after a delay.
*/
private void scheduleTooltipAutoHide(ToolTip tooltip) {
SwtUtils.getDisplay().timerExec(TOOLTIP_AUTO_HIDE_DELAY_MS, () -> {
if (!tooltip.isDisposed()) {
tooltip.dispose();
}
});
}
private void promptToClosePreferencePage() {
// Check if any preferences have changed
if (!hasPreferencesChanged()) {
// No changes made, close the preference page directly
getShell().close();
showSaveReminderTooltip();
return;
}
// Preferences have changed, show the dialog to ask user what to do
int result = MessageDialog.open(MessageDialog.QUESTION, getShell(),
Messages.preferences_page_custom_instructions_project_editDialog_title,
Messages.preferences_page_custom_instructions_project_editDialog_message, SWT.NONE,
Messages.preferences_page_custom_instructions_project_editDialog_button_stay,
Messages.preferences_page_custom_instructions_project_editDialog_button_close);
if (result == 1) {
getShell().close();
showSaveReminderTooltip();
}
}
private void createTableItem(Table table, String projectName, String fileLocation) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, projectName);
item.setText(1, fileLocation);
}
/**
* Populates the table with actual workspace projects that have copilot instructions files.
*/
private void populateProjectTable(Table table) {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
if (project.exists() && project.isOpen()) {
String projectName = project.getName();
IPath projectLocation = project.getLocation();
if (projectLocation != null) {
// Use proper path separator for cross-platform compatibility
IPath instructionFilePath = projectLocation.append(GITHUB).append(COPILOT_INSTRUCTIONS);
// Only add projects to the table if the copilot-instructions.md file actually exists
if (instructionFilePath.toFile().exists()) {
createTableItem(table, projectName, projectLocation.toOSString());
}
}
}
}
}
}