豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 0d9f422

Browse files
authored
fix: handle network request pagination correctly (ChromeDevTools#980)
Closes ChromeDevTools#970
1 parent 5e5b746 commit 0d9f422

File tree

2 files changed

+3
-284
lines changed

2 files changed

+3
-284
lines changed

src/McpResponse.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -588,21 +588,8 @@ Call ${handleDialog.name} to handle it before continuing.`);
588588
}
589589
}
590590

591-
if (this.#networkRequestsOptions?.include) {
592-
let requests = context.getNetworkRequests(
593-
this.#networkRequestsOptions?.includePreservedRequests,
594-
);
595-
596-
// Apply resource type filtering if specified
597-
if (this.#networkRequestsOptions.resourceTypes?.length) {
598-
const normalizedTypes = new Set(
599-
this.#networkRequestsOptions.resourceTypes,
600-
);
601-
requests = requests.filter(request => {
602-
const type = request.resourceType();
603-
return normalizedTypes.has(type);
604-
});
605-
}
591+
if (this.#networkRequestsOptions?.include && data.networkRequests) {
592+
const requests = data.networkRequests;
606593

607594
response.push('## Network requests');
608595
if (requests.length) {
@@ -614,7 +601,7 @@ Call ${handleDialog.name} to handle it before continuing.`);
614601
response.push(...paginationData.info);
615602
if (data.networkRequests) {
616603
structuredContent.networkRequests = [];
617-
for (const formatter of data.networkRequests) {
604+
for (const formatter of paginationData.items) {
618605
response.push(formatter.toString());
619606
structuredContent.networkRequests.push(formatter.toJSON());
620607
}

tests/McpResponse.test.js.snapshot

Lines changed: 0 additions & 268 deletions
Original file line numberDiff line numberDiff line change
@@ -483,27 +483,6 @@ exports[`McpResponse network pagination > handles invalid page number by showing
483483
"invalidPage": true
484484
},
485485
"networkRequests": [
486-
{
487-
"requestId": 1,
488-
"method": "GET",
489-
"url": "http://example.com",
490-
"status": "[pending]",
491-
"selectedInDevToolsUI": false
492-
},
493-
{
494-
"requestId": 1,
495-
"method": "GET",
496-
"url": "http://example.com",
497-
"status": "[pending]",
498-
"selectedInDevToolsUI": false
499-
},
500-
{
501-
"requestId": 1,
502-
"method": "GET",
503-
"url": "http://example.com",
504-
"status": "[pending]",
505-
"selectedInDevToolsUI": false
506-
},
507486
{
508487
"requestId": 1,
509488
"method": "GET",
@@ -654,146 +633,6 @@ exports[`McpResponse network pagination > returns first page by default 1`] = `
654633
"url": "http://example.com",
655634
"status": "[pending]",
656635
"selectedInDevToolsUI": false
657-
},
658-
{
659-
"requestId": 1,
660-
"method": "GET-10",
661-
"url": "http://example.com",
662-
"status": "[pending]",
663-
"selectedInDevToolsUI": false
664-
},
665-
{
666-
"requestId": 1,
667-
"method": "GET-11",
668-
"url": "http://example.com",
669-
"status": "[pending]",
670-
"selectedInDevToolsUI": false
671-
},
672-
{
673-
"requestId": 1,
674-
"method": "GET-12",
675-
"url": "http://example.com",
676-
"status": "[pending]",
677-
"selectedInDevToolsUI": false
678-
},
679-
{
680-
"requestId": 1,
681-
"method": "GET-13",
682-
"url": "http://example.com",
683-
"status": "[pending]",
684-
"selectedInDevToolsUI": false
685-
},
686-
{
687-
"requestId": 1,
688-
"method": "GET-14",
689-
"url": "http://example.com",
690-
"status": "[pending]",
691-
"selectedInDevToolsUI": false
692-
},
693-
{
694-
"requestId": 1,
695-
"method": "GET-15",
696-
"url": "http://example.com",
697-
"status": "[pending]",
698-
"selectedInDevToolsUI": false
699-
},
700-
{
701-
"requestId": 1,
702-
"method": "GET-16",
703-
"url": "http://example.com",
704-
"status": "[pending]",
705-
"selectedInDevToolsUI": false
706-
},
707-
{
708-
"requestId": 1,
709-
"method": "GET-17",
710-
"url": "http://example.com",
711-
"status": "[pending]",
712-
"selectedInDevToolsUI": false
713-
},
714-
{
715-
"requestId": 1,
716-
"method": "GET-18",
717-
"url": "http://example.com",
718-
"status": "[pending]",
719-
"selectedInDevToolsUI": false
720-
},
721-
{
722-
"requestId": 1,
723-
"method": "GET-19",
724-
"url": "http://example.com",
725-
"status": "[pending]",
726-
"selectedInDevToolsUI": false
727-
},
728-
{
729-
"requestId": 1,
730-
"method": "GET-20",
731-
"url": "http://example.com",
732-
"status": "[pending]",
733-
"selectedInDevToolsUI": false
734-
},
735-
{
736-
"requestId": 1,
737-
"method": "GET-21",
738-
"url": "http://example.com",
739-
"status": "[pending]",
740-
"selectedInDevToolsUI": false
741-
},
742-
{
743-
"requestId": 1,
744-
"method": "GET-22",
745-
"url": "http://example.com",
746-
"status": "[pending]",
747-
"selectedInDevToolsUI": false
748-
},
749-
{
750-
"requestId": 1,
751-
"method": "GET-23",
752-
"url": "http://example.com",
753-
"status": "[pending]",
754-
"selectedInDevToolsUI": false
755-
},
756-
{
757-
"requestId": 1,
758-
"method": "GET-24",
759-
"url": "http://example.com",
760-
"status": "[pending]",
761-
"selectedInDevToolsUI": false
762-
},
763-
{
764-
"requestId": 1,
765-
"method": "GET-25",
766-
"url": "http://example.com",
767-
"status": "[pending]",
768-
"selectedInDevToolsUI": false
769-
},
770-
{
771-
"requestId": 1,
772-
"method": "GET-26",
773-
"url": "http://example.com",
774-
"status": "[pending]",
775-
"selectedInDevToolsUI": false
776-
},
777-
{
778-
"requestId": 1,
779-
"method": "GET-27",
780-
"url": "http://example.com",
781-
"status": "[pending]",
782-
"selectedInDevToolsUI": false
783-
},
784-
{
785-
"requestId": 1,
786-
"method": "GET-28",
787-
"url": "http://example.com",
788-
"status": "[pending]",
789-
"selectedInDevToolsUI": false
790-
},
791-
{
792-
"requestId": 1,
793-
"method": "GET-29",
794-
"url": "http://example.com",
795-
"status": "[pending]",
796-
"selectedInDevToolsUI": false
797636
}
798637
]
799638
}
@@ -811,76 +650,6 @@ exports[`McpResponse network pagination > returns subsequent page when pageIdx p
811650
"invalidPage": false
812651
},
813652
"networkRequests": [
814-
{
815-
"requestId": 1,
816-
"method": "GET-0",
817-
"url": "http://example.com",
818-
"status": "[pending]",
819-
"selectedInDevToolsUI": false
820-
},
821-
{
822-
"requestId": 1,
823-
"method": "GET-1",
824-
"url": "http://example.com",
825-
"status": "[pending]",
826-
"selectedInDevToolsUI": false
827-
},
828-
{
829-
"requestId": 1,
830-
"method": "GET-2",
831-
"url": "http://example.com",
832-
"status": "[pending]",
833-
"selectedInDevToolsUI": false
834-
},
835-
{
836-
"requestId": 1,
837-
"method": "GET-3",
838-
"url": "http://example.com",
839-
"status": "[pending]",
840-
"selectedInDevToolsUI": false
841-
},
842-
{
843-
"requestId": 1,
844-
"method": "GET-4",
845-
"url": "http://example.com",
846-
"status": "[pending]",
847-
"selectedInDevToolsUI": false
848-
},
849-
{
850-
"requestId": 1,
851-
"method": "GET-5",
852-
"url": "http://example.com",
853-
"status": "[pending]",
854-
"selectedInDevToolsUI": false
855-
},
856-
{
857-
"requestId": 1,
858-
"method": "GET-6",
859-
"url": "http://example.com",
860-
"status": "[pending]",
861-
"selectedInDevToolsUI": false
862-
},
863-
{
864-
"requestId": 1,
865-
"method": "GET-7",
866-
"url": "http://example.com",
867-
"status": "[pending]",
868-
"selectedInDevToolsUI": false
869-
},
870-
{
871-
"requestId": 1,
872-
"method": "GET-8",
873-
"url": "http://example.com",
874-
"status": "[pending]",
875-
"selectedInDevToolsUI": false
876-
},
877-
{
878-
"requestId": 1,
879-
"method": "GET-9",
880-
"url": "http://example.com",
881-
"status": "[pending]",
882-
"selectedInDevToolsUI": false
883-
},
884653
{
885654
"requestId": 1,
886655
"method": "GET-10",
@@ -950,41 +719,6 @@ exports[`McpResponse network pagination > returns subsequent page when pageIdx p
950719
"url": "http://example.com",
951720
"status": "[pending]",
952721
"selectedInDevToolsUI": false
953-
},
954-
{
955-
"requestId": 1,
956-
"method": "GET-20",
957-
"url": "http://example.com",
958-
"status": "[pending]",
959-
"selectedInDevToolsUI": false
960-
},
961-
{
962-
"requestId": 1,
963-
"method": "GET-21",
964-
"url": "http://example.com",
965-
"status": "[pending]",
966-
"selectedInDevToolsUI": false
967-
},
968-
{
969-
"requestId": 1,
970-
"method": "GET-22",
971-
"url": "http://example.com",
972-
"status": "[pending]",
973-
"selectedInDevToolsUI": false
974-
},
975-
{
976-
"requestId": 1,
977-
"method": "GET-23",
978-
"url": "http://example.com",
979-
"status": "[pending]",
980-
"selectedInDevToolsUI": false
981-
},
982-
{
983-
"requestId": 1,
984-
"method": "GET-24",
985-
"url": "http://example.com",
986-
"status": "[pending]",
987-
"selectedInDevToolsUI": false
988722
}
989723
]
990724
}
@@ -1438,8 +1172,6 @@ exports[`McpResponse network request filtering > shows all requests when no filt
14381172

14391173
exports[`McpResponse network request filtering > shows no requests when filter matches nothing 1`] = `
14401174
# test response
1441-
## Network requests
1442-
No requests found.
14431175
`;
14441176

14451177
exports[`McpResponse network request filtering > shows no requests when filter matches nothing 2`] = `

0 commit comments

Comments
 (0)