Skip to content

Commit 1498a6e

Browse files
authored
Update tabbed view setting (#9202)
1 parent 326d678 commit 1498a6e

9 files changed

Lines changed: 64 additions & 40 deletions

File tree

‎package.json‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,22 @@
651651
"markdownDescription": "%githubPullRequests.experimental.useQuickChat.description%",
652652
"default": false
653653
},
654-
"githubPullRequests.experimental.agentsOverviewTabs": {
655-
"type": "boolean",
656-
"markdownDescription": "%githubPullRequests.experimental.agentsOverviewTabs.description%",
654+
"githubPullRequests.experimental.overviewTabs": {
655+
"type": [
656+
"boolean",
657+
"string"
658+
],
659+
"enum": [
660+
false,
661+
true,
662+
"agents"
663+
],
664+
"enumDescriptions": [
665+
"%githubPullRequests.experimental.overviewTabs.false%",
666+
"%githubPullRequests.experimental.overviewTabs.true%",
667+
"%githubPullRequests.experimental.overviewTabs.agents%"
668+
],
669+
"markdownDescription": "%githubPullRequests.experimental.overviewTabs.description%",
657670
"default": false,
658671
"tags": [
659672
"experimental"

‎package.nls.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@
116116
"githubPullRequests.experimental.notificationsView.description": "Enables the notifications view, which shows a list of your GitHub notifications. When combined with `#githubPullRequests.experimental.chat#`, you can have Copilot sort and summarize your notifications. View will not show in a Codespace accessed from the browser.",
117117
"githubPullRequests.experimental.notificationsMarkPullRequests.description": "Adds an action in the Notifications view to mark pull requests with no non-empty reviews, comments, or commits since you last viewed the pull request as read.",
118118
"githubPullRequests.experimental.useQuickChat.description": "Controls whether the Copilot \"Summarize\" commands in the Pull Requests, Issues, and Notifications views will use quick chat. Only has an effect if `#githubPullRequests.experimental.chat#` is enabled.",
119-
"githubPullRequests.experimental.agentsOverviewTabs.description": "Splits the pull request description page in the Agents window into Timeline, Checks/Merge, and Metadata tabs. Has no effect outside the Agents window.",
119+
"githubPullRequests.experimental.overviewTabs.description": "Controls whether the pull request description page is split into Timeline, Checks/Merge, and Metadata tabs.",
120+
"githubPullRequests.experimental.overviewTabs.false": "Don't split the pull request description page into tabs.",
121+
"githubPullRequests.experimental.overviewTabs.true": "Split the pull request description page into tabs everywhere.",
122+
"githubPullRequests.experimental.overviewTabs.agents": "Split the pull request description page into tabs only in the Agents window.",
120123
"githubPullRequests.webviewRefreshInterval.description": "The interval, in seconds, at which the pull request and issues webviews are refreshed when the webview is the active tab.",
121124
"githubPullRequests.devMode.description": "When enabled, limits expensive API calls to prevent hitting rate limits during extension development. Disables automatic Copilot PR status polling, collapses all PR query results, and disables issue fetching.",
122125
"githubIssues.ignoreMilestones.description": "An array of milestone titles to never show issues from.",

‎src/common/settingKeys.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const EXPERIMENTAL_CHAT = 'experimental.chat';
7676
export const EXPERIMENTAL_USE_QUICK_CHAT = 'experimental.useQuickChat';
7777
export const EXPERIMENTAL_NOTIFICATIONS_PAGE_SIZE = 'experimental.notificationsViewPageSize';
7878
export const EXPERIMENTAL_NOTIFICATIONS_SCORE = 'experimental.notificationsScore';
79-
export const EXPERIMENTAL_AGENTS_OVERVIEW_TABS = 'experimental.agentsOverviewTabs';
79+
export const EXPERIMENTAL_OVERVIEW_TABS = 'experimental.overviewTabs';
8080
export const WEBVIEW_REFRESH_INTERVAL = 'webviewRefreshInterval';
8181
export const DEV_MODE = 'devMode';
8282

‎src/github/pullRequestOverview.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { commands, contexts } from '../common/executeCommands';
5353
import { openWithDefaultExternalOpener } from '../common/externalUri';
5454
import { disposeAll } from '../common/lifecycle';
5555
import Logger from '../common/logger';
56-
import { CHECKOUT_DEFAULT_BRANCH, CHECKOUT_PULL_REQUEST_BASE_BRANCH, DEFAULT_MERGE_METHOD, DELETE_BRANCH_AFTER_MERGE, EXPERIMENTAL_AGENTS_OVERVIEW_TABS, POST_DONE, PR_SETTINGS_NAMESPACE } from '../common/settingKeys';
56+
import { CHECKOUT_DEFAULT_BRANCH, CHECKOUT_PULL_REQUEST_BASE_BRANCH, DEFAULT_MERGE_METHOD, DELETE_BRANCH_AFTER_MERGE, EXPERIMENTAL_OVERVIEW_TABS, POST_DONE, PR_SETTINGS_NAMESPACE } from '../common/settingKeys';
5757
import { ITelemetry } from '../common/telemetry';
5858
import { EventType, ReviewEvent, SessionLinkInfo, TimelineEvent } from '../common/timelineEvent';
5959
import { toOpenIssueWebviewUri, toOpenPullRequestWebviewUri } from '../common/uri';
@@ -680,7 +680,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
680680
revertable: pullRequest.state === GithubItemStateEnum.Merged,
681681
isCopilotOnMyBehalf: false,
682682
isAgentSessionsWorkspace: vscode.workspace.isAgentSessionsWorkspace,
683-
agentsOverviewTabs: vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(EXPERIMENTAL_AGENTS_OVERVIEW_TABS, false),
683+
overviewTabs: vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean | 'agents'>(EXPERIMENTAL_OVERVIEW_TABS, false),
684684
stack: initialStack,
685685
stackLoaded: false,
686686
stackLoadError: false,

‎src/github/views.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export interface PullRequest extends Issue {
100100
isCopilotOnMyBehalf: boolean;
101101
/** Whether the overview is shown in the agents window, where pull requests are not checked out. */
102102
isAgentSessionsWorkspace?: boolean;
103-
/** Whether the experimental agents overview tabs setting is on. The tabs are only shown in the agents window. */
104-
agentsOverviewTabs?: boolean;
103+
/** The experimental setting to split the overview into tabs everywhere when `true`, or only in the agents window when `'agents'`. */
104+
overviewTabs?: boolean | 'agents';
105105
isCurrentlyCheckedOut: boolean;
106106
isRemoteBaseDeleted?: boolean;
107107
base: string;

‎webviews/editorWebview/index.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ html {
4141
grid-row: 1;
4242
}
4343

44-
/* In the agents window, the overview is split into tabs below the title. */
44+
/* With the experimental setting on, the overview is split into tabs below the title. */
4545
#overview-tabs {
4646
grid-column: 1 / 3;
4747
grid-row: 3;

‎webviews/editorWebview/overview.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const Overview = (pr: PullRequest) => {
4242
const isSingleColumnLayout = useMediaQuery(singleColumnLayoutQuery);
4343
const titleRef = React.useRef<HTMLDivElement>(null);
4444
const isStuck = useStickyHeader(titleRef);
45+
const showTabs = pr.overviewTabs === true || (pr.overviewTabs === 'agents' && pr.isAgentSessionsWorkspace);
4546

4647
return <>
4748
<StickyHeader pr={pr} visible={isStuck} />
@@ -51,7 +52,7 @@ export const Overview = (pr: PullRequest) => {
5152
<Header {...pr} />
5253
</div>
5354
</div>
54-
{pr.isAgentSessionsWorkspace && pr.agentsOverviewTabs ?
55+
{showTabs ?
5556
<OverviewTabs {...pr} />
5657
:
5758
<>
@@ -112,8 +113,7 @@ const OverviewTabBadges = ({ id, pr }: { id: OverviewTabId; pr: PullRequest }) =
112113
};
113114

114115
/**
115-
* With the experimental setting on, the overview of pull requests in the agents window is split into tabs that start
116-
* with the timeline.
116+
* With the experimental setting on, the overview of pull requests is split into tabs that start with the timeline.
117117
*/
118118
const OverviewTabs = (pr: PullRequest) => {
119119
const [selected, setSelected] = React.useState<OverviewTabId>('timeline');

‎webviews/editorWebview/test/builder/pullRequest.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ export const PullRequestBuilder = createBuilderClass<PullRequest>()({
7373
canRequestCopilotReview: { default: false },
7474
isCopilotOnMyBehalf: { default: false },
7575
isAgentSessionsWorkspace: { default: false },
76-
agentsOverviewTabs: { default: false },
76+
overviewTabs: { default: false },
7777
reactions: { default: [] },
7878
});

‎webviews/editorWebview/test/overview.test.tsx‎

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,8 @@ describe('Overview', function () {
14291429
}
14301430
});
14311431

1432-
describe('agents window tabs', function () {
1433-
function renderAgentsOverview(pr = new PullRequestBuilder().isAgentSessionsWorkspace(true).agentsOverviewTabs(true).build()) {
1432+
describe('overview tabs', function () {
1433+
function renderTabbedOverview(pr = new PullRequestBuilder().overviewTabs(true).build()) {
14341434
const context = new PRContext(pr);
14351435
const out = render(
14361436
<PullRequestContext.Provider value={context}>
@@ -1444,7 +1444,7 @@ describe('Overview', function () {
14441444
}
14451445

14461446
it('splits the overview into timeline, checks, and metadata tabs', function () {
1447-
const { out, tabs, selectedTab, visiblePanels } = renderAgentsOverview();
1447+
const { out, tabs, selectedTab, visiblePanels } = renderTabbedOverview();
14481448

14491449
assert.deepStrictEqual(tabs.map(tab => tab.textContent), ['Timeline', 'Checks/Merge', 'Metadata']);
14501450
assert.strictEqual(selectedTab(), 'Timeline');
@@ -1465,7 +1465,7 @@ describe('Overview', function () {
14651465
});
14661466

14671467
it('moves between tabs with the arrow, Home, and End keys', function () {
1468-
const { tabs, selectedTab } = renderAgentsOverview();
1468+
const { tabs, selectedTab } = renderTabbedOverview();
14691469

14701470
for (const [from, key, expected] of [[0, 'ArrowLeft', 2], [2, 'ArrowRight', 0], [0, 'End', 2], [2, 'Home', 0], [0, 'ArrowRight', 1]] as const) {
14711471
fireEvent.keyDown(tabs[from], { key });
@@ -1476,20 +1476,20 @@ describe('Overview', function () {
14761476
});
14771477

14781478
it('shows on the checks tab whether the pull request can be merged', function () {
1479-
const agentsPullRequest = () => new PullRequestBuilder().isAgentSessionsWorkspace(true).agentsOverviewTabs(true);
1479+
const tabbedPullRequest = () => new PullRequestBuilder().overviewTabs(true);
14801480
const failedCheck: PullRequestCheckStatus = {
14811481
id: 'build', state: CheckState.Failure, context: 'build', description: null, targetUrl: null, workflowName: undefined,
14821482
event: undefined, url: undefined, avatarUrl: undefined, isRequired: false, isCheckRun: false, databaseId: undefined,
14831483
};
14841484
const cases: [string, PullRequest, string | undefined][] = [
1485-
['mergeable', agentsPullRequest().build(), 'Ready to merge'],
1486-
['mergeable with a failed check', agentsPullRequest()
1485+
['mergeable', tabbedPullRequest().build(), 'Ready to merge'],
1486+
['mergeable with a failed check', tabbedPullRequest()
14871487
.status(status => status.state(CheckState.Failure).statuses([failedCheck])).build(), 'Ready to merge'],
1488-
['blocked with a failed check', agentsPullRequest().mergeable(PullRequestMergeability.NotMergeable)
1488+
['blocked with a failed check', tabbedPullRequest().mergeable(PullRequestMergeability.NotMergeable)
14891489
.status(status => status.state(CheckState.Failure).statuses([failedCheck])).build(), 'Cannot be merged, checks failed'],
1490-
['conflicting', agentsPullRequest().mergeable(PullRequestMergeability.Conflict).build(), 'Cannot be merged yet'],
1491-
['draft that can otherwise be merged', agentsPullRequest().isDraft(true).build(), undefined],
1492-
['draft in a stack that can otherwise be merged', agentsPullRequest().isDraft(true).number(794).stack({
1490+
['conflicting', tabbedPullRequest().mergeable(PullRequestMergeability.Conflict).build(), 'Cannot be merged yet'],
1491+
['draft that can otherwise be merged', tabbedPullRequest().isDraft(true).build(), undefined],
1492+
['draft in a stack that can otherwise be merged', tabbedPullRequest().isDraft(true).number(794).stack({
14931493
position: 2,
14941494
size: 2,
14951495
base: 'main',
@@ -1498,9 +1498,9 @@ describe('Overview', function () {
14981498
{ position: 2, number: 794, title: 'Second Change', head: 'D2', url: 'https://example.com/794', state: GithubItemStateEnum.Open, isDraft: true, mergeable: PullRequestMergeability.Mergeable },
14991499
],
15001500
}).build(), undefined],
1501-
['draft blocked by a failed check', agentsPullRequest().isDraft(true).mergeable(PullRequestMergeability.NotMergeable)
1501+
['draft blocked by a failed check', tabbedPullRequest().isDraft(true).mergeable(PullRequestMergeability.NotMergeable)
15021502
.status(status => status.state(CheckState.Failure).statuses([failedCheck])).build(), 'Cannot be merged, checks failed'],
1503-
['in a stack with a pull request below that is being checked', agentsPullRequest().number(794).stack({
1503+
['in a stack with a pull request below that is being checked', tabbedPullRequest().number(794).stack({
15041504
position: 2,
15051505
size: 2,
15061506
base: 'main',
@@ -1509,11 +1509,11 @@ describe('Overview', function () {
15091509
{ position: 2, number: 794, title: 'Second Change', head: 'D2', url: 'https://example.com/794', state: GithubItemStateEnum.Open, isDraft: false, mergeable: PullRequestMergeability.Mergeable },
15101510
],
15111511
}).build(), undefined],
1512-
['being checked', agentsPullRequest().mergeable(PullRequestMergeability.Unknown).build(), undefined],
1513-
['merged', agentsPullRequest().state(GithubItemStateEnum.Merged).build(), undefined],
1512+
['being checked', tabbedPullRequest().mergeable(PullRequestMergeability.Unknown).build(), undefined],
1513+
['merged', tabbedPullRequest().state(GithubItemStateEnum.Merged).build(), undefined],
15141514
];
15151515
for (const [description, pr, expected] of cases) {
1516-
const { tabs } = renderAgentsOverview(pr);
1516+
const { tabs } = renderTabbedOverview(pr);
15171517
assert.strictEqual(tabs[1].querySelector('.overview-tab-badge')?.getAttribute('aria-label'), expected, description);
15181518
cleanup();
15191519
}
@@ -1542,7 +1542,7 @@ describe('Overview', function () {
15421542
[[review(1, 'COMMENTED', { a: true })], undefined],
15431543
];
15441544
for (const [events, expected] of cases) {
1545-
const { out, tabs } = renderAgentsOverview(new PullRequestBuilder().isAgentSessionsWorkspace(true).agentsOverviewTabs(true).events(events).build());
1545+
const { out, tabs } = renderTabbedOverview(new PullRequestBuilder().overviewTabs(true).events(events).build());
15461546
assert.strictEqual(unresolvedCount(out), expected);
15471547
assert.strictEqual(tabs[0].querySelector('.overview-tab-count')?.textContent, expected?.split(' ')[0]);
15481548
cleanup();
@@ -1552,7 +1552,7 @@ describe('Overview', function () {
15521552
it('stops counting a conversation once its last comment is deleted', async function () {
15531553
const event = review(1, 'COMMENTED', { a: false, b: false });
15541554
event.comments.push(reviewComment(102, 1, 'b'));
1555-
const pr = new PullRequestBuilder().isAgentSessionsWorkspace(true).agentsOverviewTabs(true).events([event]).build();
1555+
const pr = new PullRequestBuilder().overviewTabs(true).events([event]).build();
15561556
const context = new PRContext(pr);
15571557
context.setPR(pr);
15581558
sinon.stub(context, 'postMessage').resolves();
@@ -1572,7 +1572,7 @@ describe('Overview', function () {
15721572
});
15731573

15741574
it('shows the timeline when asked to scroll to the pending review', function () {
1575-
const { context, out, tabs, selectedTab } = renderAgentsOverview();
1575+
const { context, out, tabs, selectedTab } = renderTabbedOverview();
15761576
fireEvent.click(tabs[1]);
15771577
const scrollIntoView = sinon.spy();
15781578
HTMLElement.prototype.scrollIntoView = scrollIntoView;
@@ -1589,7 +1589,7 @@ describe('Overview', function () {
15891589
});
15901590

15911591
it('shows the stack from the header badge before the link scrolls to it', function () {
1592-
const { out, tabs, selectedTab } = renderAgentsOverview(new PullRequestBuilder().isAgentSessionsWorkspace(true).agentsOverviewTabs(true).number(794).stack({
1592+
const { out, tabs, selectedTab } = renderTabbedOverview(new PullRequestBuilder().overviewTabs(true).number(794).stack({
15931593
position: 2,
15941594
size: 2,
15951595
base: 'main',
@@ -1623,18 +1623,26 @@ describe('Overview', function () {
16231623
});
16241624
});
16251625

1626-
it('keeps the sidebar layout without tabs unless the experimental tabs are on in the agents window', function () {
1627-
for (const [isAgentSessionsWorkspace, agentsOverviewTabs] of [[false, false], [true, false], [false, true]]) {
1628-
const pr = new PullRequestBuilder().isAgentSessionsWorkspace(isAgentSessionsWorkspace).agentsOverviewTabs(agentsOverviewTabs).build();
1626+
it('splits the overview into tabs according to the experimental setting and the window', function () {
1627+
const cases: [isAgentSessionsWorkspace: boolean, overviewTabs: boolean | 'agents', expectTabs: boolean][] = [
1628+
[false, false, false],
1629+
[true, false, false],
1630+
[false, true, true],
1631+
[true, true, true],
1632+
[false, 'agents', false],
1633+
[true, 'agents', true],
1634+
];
1635+
for (const [isAgentSessionsWorkspace, overviewTabs, expectTabs] of cases) {
1636+
const pr = new PullRequestBuilder().isAgentSessionsWorkspace(isAgentSessionsWorkspace).overviewTabs(overviewTabs).build();
16291637
const out = render(
16301638
<PullRequestContext.Provider value={new PRContext(pr)}>
16311639
<Overview {...pr} />
16321640
</PullRequestContext.Provider>,
16331641
);
16341642

1635-
const description = `agents window: ${isAgentSessionsWorkspace}, setting: ${agentsOverviewTabs}`;
1636-
assert.strictEqual(out.container.querySelector('[role="tablist"]'), null, description);
1637-
assert(out.container.querySelector('#main > #status-checks'), description);
1643+
const description = `agents window: ${isAgentSessionsWorkspace}, setting: ${overviewTabs}`;
1644+
assert.strictEqual(!!out.container.querySelector('[role="tablist"]'), expectTabs, description);
1645+
assert.strictEqual(!!out.container.querySelector('#main > #status-checks'), !expectTabs, description);
16381646
cleanup();
16391647
}
16401648
});

0 commit comments

Comments
 (0)