codeflash-internal/js/cf-api/endpoints/suggest-pr-changes.ts

367 lines
12 KiB
TypeScript
Raw Normal View History

cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
import { determineValidHunks, fileDiffsToMap, isDiffContentsWellFormed } from "../diff_utils.js"
import { userNickname } from "../auth0-mgmt.js"
import { getInstallationOctokitByOwner, isUserCollaborator } from "../github/github-utils.js"
import { githubApp } from "../github/github-app.js"
2025-03-19 23:19:09 +00:00
import { buildDependentPrTitle, buildPrCommentBody } from "../github/pr-changes-utils.js"
import {
createDependentPullRequest,
createNewBranchFromDiffContents,
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
} from "../github/create-pr-from-diffcontents.js"
import { posthog } from "../analytics.js"
code-suggester package upgrade to npm registry (#1522) ### **PR Type** - Enhancement ___ ### **Description** - Updated all import paths to use @codeflash-ai/code-suggester - Upgraded code-suggester dependency version in package.json - Applied type cast for octokit in getPullRequestHunks call ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>diff_utils.test.ts</strong><dd><code>Update FileDiffContent import in tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/diff_utils.test.ts - Changed FileDiffContent import path to @codeflash-ai/code-suggester </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1522/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>diff_utils.ts</strong><dd><code>Upgrade import paths and apply octokit cast</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/diff_utils.ts <li>Updated all import paths for code-suggester modules<br> <li> Cast octokit argument in getPullRequestHunks call </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1522/files#diff-f6212b48c365856b4ceb25da3ad03bd15fe171161cff046a31a92586272d4771">+4/-4</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>create-pr.ts</strong><dd><code>Fix FileDiffContent import path in create-pr endpoint</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/create-pr.ts - Updated FileDiffContent import to new package path </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1522/files#diff-728a794bb81f944ae7db030f5e6ae1c1ba6888aa46e4be6846ebc5bd1ce12c2c">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Update suggester and FileDiffContent import paths</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts - Changed suggester and FileDiffContent imports to new package </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1522/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import path in create-pr-from-diffcontents</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/github/create-pr-from-diffcontents.ts - Updated FileDiffContent import to @codeflash-ai/code-suggester </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1522/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Upgrade code-suggester dependency</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded dependency: replaced code-suggester with <br>@codeflash-ai/code-suggester v5.0.2 </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1522/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+1/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-24 19:58:12 +00:00
import suggester from "@codeflash-ai/code-suggester"
import { type FileDiffContent } from "@codeflash-ai/code-suggester/build/src/types.js"
import { PrismaClient } from "@prisma/client"
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
import { sendSlackMessage } from "../github/slack_util.js"
import { Request, Response } from "express"
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
import { AnyOctokit, AuthorizedUserReq, PullRequestDB } from "../types.js"
interface CustomRequest extends Request {
2025-02-21 05:18:55 +00:00
userId?: string
}
const prisma = new PrismaClient()
2024-12-19 19:17:18 +00:00
const slackNotificationConfig = {
"Future-House": ["aviary", "paper-qa"],
"langflow-ai": ["langflow"],
"albumentations-team": ["albumentations"],
2025-03-19 23:19:09 +00:00
"Skyvern-AI": ["skyvern"],
2025-04-15 22:25:24 +00:00
roboflow: ["inference"],
2024-12-19 19:17:18 +00:00
}
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
export async function suggestPrChanges(
req: AuthorizedUserReq,
res: Response,
): Promise<Response | undefined> {
try {
const {
owner,
repo,
pullNumber,
diffContents,
prCommentFields,
existingTests,
generatedTests,
coverage_message,
} = req.body
2025-01-06 22:01:20 +00:00
const userId = req.userId
//traceId is optional to allow for backwards compatibility, can make this required in the future
const traceId = req.body.traceId || ""
console.log(`traceId: ${traceId}`)
if (!repo || !owner || !pullNumber || !isDiffContentsWellFormed(diffContents)) {
return res.status(400).send("Missing or malformed fields")
}
const nickname = await userNickname(userId)
if (nickname == null) {
return res.status(401).send("Unauthorized") // Error getting user nickname
}
const installationOctokit = await getInstallationOctokitByOwner(githubApp, owner, repo)
if (installationOctokit instanceof Error) {
return res.status(401).send(installationOctokit.message)
}
const isCollaborator = await isUserCollaborator(installationOctokit, owner, repo, nickname)
if (!isCollaborator) {
console.log(`${nickname} is not a collaborator on ${owner}/${repo}`)
return res.status(401).send("Unauthorized") // User is not a collaborator
}
console.log(`${nickname} is a collaborator on ${owner}/${repo}`)
2025-05-14 17:38:36 +00:00
// Check if the owner is roboflow
if (owner === "roboflow") {
console.log(`Rejecting request for roboflow repository`)
return res.status(401).send("Unauthorized for roboflow repositories")
}
// Suggest changes
const diffContentsMap: Map<string, FileDiffContent> = fileDiffsToMap(diffContents)
2025-01-06 22:01:20 +00:00
const { validHunks, invalidHunks } = await determineValidHunks(
installationOctokit.rest as AnyOctokit,
{ owner, repo },
pullNumber,
100,
diffContentsMap,
)
2025-02-21 05:18:55 +00:00
// a timestamp format like 2024-01-31-12.59.48
const timestamp = new Date()
.toISOString()
.replace(/:/g, ".")
.replace(/\.\d+Z$/, "")
// If you change this, please also change the regex in github-app.ts in the pull_request.closed event
const newBranchName = `codeflash/optimize-pr${pullNumber}-${timestamp}`
// Get the head branch of the original pull request
const originalPrData = await installationOctokit.rest.pulls.get({
owner,
repo,
pull_number: pullNumber,
})
const baseBranch = originalPrData.data.head.ref
combine comment and suggestion for single hunk (#1524) Final Outcome: ![image](https://github.com/user-attachments/assets/38bd4176-28ef-4299-b634-f06044a3436d) Test: 1. Option 1 - https://github.com/codeflash-ai/my-best-repo/pull/248#pullrequestreview-2714641581 [Current] option 2- https://github.com/codeflash-ai/my-best-repo/pull/248#discussion_r2012735000 (Seems to have long data in inline suggestion) Only a 1 liner change from current one [Option 1] ![image](https://github.com/user-attachments/assets/b31bb8c9-e06c-445e-8312-c6a4b442f22b) [Option 2] ![image](https://github.com/user-attachments/assets/ae5ae72e-1e5c-49fc-9e7c-34717cae9070) closes https://linear.app/codeflash-ai/issue/CF-547/make-inline-suggestions-look-better ### **PR Type** - Enhancement ___ ### **Description** - Added logging for branch ref access - Replaced code suggester with unified review creation - Aggregated suggestions into reviewComments list - Updated review response and notification references ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Unified review creation with enhanced logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts <li>Logs branch ref access before review<br> <li> Removes old code suggester calls<br> <li> Creates review with consolidated comments<br> <li> Updates response and slack notification handling </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1524/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+26/-33</a>&nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-26 03:55:12 +00:00
console.log(`Attempting to access ref for: ${owner}/${repo}, branch: ${baseBranch}`)
2025-02-21 05:18:55 +00:00
const commitMessage =
buildDependentPrTitle(
prCommentFields.function_name,
prCommentFields.speedup_pct,
Hide percentage when it's over 1000 and just show the (x) muliplier number (#1488) ### **User description** Passing 'speedup_x' through, and using that instead of percentage. (when percentage is over 1000) ___ ### **PR Type** - Enhancement ___ ### **Description** - Added new parameter `speedup_x` to PR title builders. - Modified functions to display multiplier when percentage exceeds 1000. - Updated dependent PR title calls with additional arguments. - Adjusted tests to verify new title logic. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>create-pr.ts</strong><dd><code>Update create-pr endpoint with new speedup_x parameter</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/create-pr.ts <li>Added <code>speedup_x</code> argument in buildPrTitle call.<br> <li> Minor formatting fix (removed extra semicolon).<br> <li> Updated branch creation message to include additional parameters. </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1488/files#diff-728a794bb81f944ae7db030f5e6ae1c1ba6888aa46e4be6846ebc5bd1ce12c2c">+7/-4</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Update suggest-pr-changes with new speedup_x parameter</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts <li>Inserted <code>speedup_x</code> parameter in buildDependentPrTitle call.<br> <li> Adjusted commit message composition. </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1488/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>create-pr-from-diffcontents.ts</strong><dd><code>Modify PR creation functions for updated title parameters</code></dd></summary> <hr> js/cf-api/github/create-pr-from-diffcontents.ts <li>Modified buildPrTitle call to include <code>speedup_x</code> and <code>loop_count</code>.<br> <li> Updated buildDependentPrTitle call with <code>speedup_x</code>. </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1488/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+7/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>pr-changes-utils.ts</strong><dd><code>Update title building utilities for speedup multiplier logic</code></dd></summary> <hr> js/cf-api/github/pr-changes-utils.ts <li>Added <code>speedup_x</code> parameter to buildPrTitle and buildDependentPrTitle.<br> <li> Implemented condition to use <code>speedup_x</code> when percentage > 1000.<br> <li> Refactored title functions for enhanced clarity. </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1488/files#diff-ac6988771dc3fdb0666757d9bace579f70856f1f383ddd5db264484f1b6016e4">+12/-3</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>pr-changes-utils.test.ts</strong><dd><code>Adjust tests to support new title building parameters</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/github/pr-changes-utils.test.ts <li>Updated tests for buildPrTitle with additional <code>speedup_x</code> parameter.<br> <li> Revised expected output strings in dependent PR title tests. </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1488/files#diff-b724fe01559c8ff46177344dcaa3741bc56bbda2b14ec979558bb7cf6245951a">+5/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-11 23:39:10 +00:00
prCommentFields.speedup_x,
2025-02-21 05:18:55 +00:00
pullNumber,
baseBranch,
) + `\n${prCommentFields.optimization_explanation}`
const branchCreated = await createNewBranchFromDiffContents(
installationOctokit,
owner,
repo,
newBranchName,
baseBranch,
diffContentsMap,
commitMessage,
)
if (!branchCreated) {
throw new Error(`Failed to create branch ${newBranchName}`)
}
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
let hasMultipleHunksInSameFile = false
let hasMultipleFiles = validHunks.size > 1
for (const [filePath, hunks] of validHunks.entries()) {
if (hunks.length > 1) {
console.log(
`File ${filePath} has ${hunks.length} hunks, using dependent PR instead of review comments`,
)
hasMultipleHunksInSameFile = true
break
}
}
if (hasMultipleFiles) {
console.log(
`Found ${validHunks.size} files with changes, using dependent PR instead of review comments`,
)
}
// Modified condition: Create a dependent PR if there are invalid hunks OR multiple valid hunks
// This addresses both the invalid hunks case and the code suggester library issues
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
if (
invalidHunks.size > 0 ||
validHunks.size > 1 ||
hasMultipleFiles ||
hasMultipleHunksInSameFile
) {
// we can't suggest all of the hunks for this PR, because some of them are invalid (out of scope for this PR).
// so instead, let's make a new branch, commit the changes,
// and make a new PR from that branch onto the PR's branch
console.log(
`Creating a dependent PR because there are ${invalidHunks.size > 0 ? "invalid hunks" : "multiple valid hunks"}.`,
)
console.log(`Making a new dependent PR...`)
const newPrData = await createDependentPullRequest(
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
installationOctokit as AnyOctokit,
owner,
repo,
pullNumber,
newBranchName,
baseBranch,
prCommentFields,
existingTests,
generatedTests,
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
"",
)
// Respond with the new PR details
console.log(
`Created new dependent PR #${newPrData.data.number} from branch ${newPrData.data.head.ref}`,
)
if (slackNotificationConfig[owner as keyof typeof slackNotificationConfig]?.includes(repo)) {
2025-01-02 19:12:30 +00:00
await sendSlackMessage(
`new dependent PR created: ${newPrData.data.html_url} for ${owner}/${repo}`,
)
}
2024-11-14 23:58:34 +00:00
posthog.capture({
distinctId: userId,
event: `cfapi-suggest-pr-changes-success-dependent-pr-created`,
properties: {
owner,
repo,
newPrNumber: newPrData.data.number,
newPrBranch: newPrData.data.head.ref,
2024-06-07 19:26:05 +00:00
PRURL: newPrData.data.html_url,
},
})
if (traceId !== "") {
let pull_request_db = await prisma.optimization_features.findUnique({
where: {
trace_id: traceId,
},
select: {
pull_request: true,
},
})
2024-07-20 05:15:57 +00:00
if (pull_request_db) {
2025-01-06 22:01:20 +00:00
if (pull_request_db.pull_request === null || pull_request_db.pull_request === undefined) {
2024-07-20 05:15:57 +00:00
pull_request_db.pull_request = {}
}
cf-api fix (#1512) ### **PR Type** - Enhancement - Bug fix ___ ### **Description** - Update ES module import paths with explicit .js extensions. - Refactor function signatures and type annotations for TypeScript. - Wrap Express app with @awaitjs/express for async support. - Upgrade package configurations and tsconfig settings. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td><strong>diff_utils.test.ts</strong><dd><code>Adjust import paths to include .js extensions.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c0991313f3fcb63fa2a553856b85d7df03e6d99cf98d19277fe689025f89ede1">+2/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>create-pr-from-diffcontents.ts</strong><dd><code>Update import paths and adjust Octokit typing.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b30d5e0c89beb70c0333a025726867aba5db7614911be3c46664bb59d1ab594a">+12/-11</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Use @awaitjs/express wrap to create AsyncExpressApp.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+7/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>setupAction.ts</strong><dd><code>Update workflow setup action and adjust GitHub API usage.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-88c84a935a854855fb103dbf560f6ed5ea2e73e45750c97b5a3b901a5f9399a2">+5/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.d.ts</strong><dd><code>Add new type definitions for Octokit and AsyncExpressApp.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-370b1e96082f265e191b7aac76caa9feb60d32d56c36a2924725200b3d41f423">+45/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>types.ts</strong><dd><code>Remove obsolete types; migrate to types.d.ts.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-8d1257d2e60e56e9c02c59b85078e89ad41af60267b02842daf203da3231902f">+0/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Bug fix</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>is-github-app-installed.ts</strong><dd><code>Add ts-ignore and adjust GitHub app installation endpoint.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-4b97bd2b461108930999b4af7e47d4763ad1b9490f7352130109c39f5abf4561">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>suggest-pr-changes.ts</strong><dd><code>Refactor types, cast Octokit instance, and update parameters.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+22/-15</a>&nbsp; </td> </tr> <tr> <td><strong>check-valid-api-key.ts</strong><dd><code>Refine middleware typing with NextFunction.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-c04a6087bbabce916c7547acf14c186caf7af3ec6ff68b7e49102c3fe87e453c">+9/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>track-usage.ts</strong><dd><code>Change Request type to AuthorizedUserReq in usage tracker.</code></dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-9248228a33147544ca9b58ff8b9c737b33763dd3e29717c82c38808bb7e34db3">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td><strong>package.json</strong><dd><code>Upgrade dependencies and refine build/deploy scripts.</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+8/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>tsconfig.json</strong><dd><code>Modify module, strict, and lib options for NodeNext.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-3532a852c82c88daeed6b57a35cd52c4a2589c909edc756613d67e280ab9b23e">+6/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td><strong>migration.sql</strong><dd><code>Add placeholder migration for rolled back changes.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1512/files#diff-98f5513f409a695839ec0bb0ee8e77d3c858e26c30db2113a83973dc1fa46c25">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-12 22:30:10 +00:00
;(pull_request_db as PullRequestDB).pull_request.dependent_pr_url =
newPrData.data.html_url
await prisma.optimization_features.update({
where: {
trace_id: traceId,
},
2025-01-06 22:01:20 +00:00
data: pull_request_db,
})
}
}
res.json(newPrData.data.number)
} else {
// Only use the code suggester library when there is exactly one valid hunk and no invalid hunks
combine comment and suggestion for single hunk (#1524) Final Outcome: ![image](https://github.com/user-attachments/assets/38bd4176-28ef-4299-b634-f06044a3436d) Test: 1. Option 1 - https://github.com/codeflash-ai/my-best-repo/pull/248#pullrequestreview-2714641581 [Current] option 2- https://github.com/codeflash-ai/my-best-repo/pull/248#discussion_r2012735000 (Seems to have long data in inline suggestion) Only a 1 liner change from current one [Option 1] ![image](https://github.com/user-attachments/assets/b31bb8c9-e06c-445e-8312-c6a4b442f22b) [Option 2] ![image](https://github.com/user-attachments/assets/ae5ae72e-1e5c-49fc-9e7c-34717cae9070) closes https://linear.app/codeflash-ai/issue/CF-547/make-inline-suggestions-look-better ### **PR Type** - Enhancement ___ ### **Description** - Added logging for branch ref access - Replaced code suggester with unified review creation - Aggregated suggestions into reviewComments list - Updated review response and notification references ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Unified review creation with enhanced logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts <li>Logs branch ref access before review<br> <li> Removes old code suggester calls<br> <li> Creates review with consolidated comments<br> <li> Updates response and slack notification handling </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1524/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+26/-33</a>&nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-26 03:55:12 +00:00
console.log(`Creating unified review for a single valid hunk.`)
// Include all the information in a single PR comment
const prCommentBody = buildPrCommentBody(
prCommentFields,
existingTests,
generatedTests,
coverage_message,
2025-02-21 05:18:55 +00:00
newBranchName,
combine comment and suggestion for single hunk (#1524) Final Outcome: ![image](https://github.com/user-attachments/assets/38bd4176-28ef-4299-b634-f06044a3436d) Test: 1. Option 1 - https://github.com/codeflash-ai/my-best-repo/pull/248#pullrequestreview-2714641581 [Current] option 2- https://github.com/codeflash-ai/my-best-repo/pull/248#discussion_r2012735000 (Seems to have long data in inline suggestion) Only a 1 liner change from current one [Option 1] ![image](https://github.com/user-attachments/assets/b31bb8c9-e06c-445e-8312-c6a4b442f22b) [Option 2] ![image](https://github.com/user-attachments/assets/ae5ae72e-1e5c-49fc-9e7c-34717cae9070) closes https://linear.app/codeflash-ai/issue/CF-547/make-inline-suggestions-look-better ### **PR Type** - Enhancement ___ ### **Description** - Added logging for branch ref access - Replaced code suggester with unified review creation - Aggregated suggestions into reviewComments list - Updated review response and notification references ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Unified review creation with enhanced logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts <li>Logs branch ref access before review<br> <li> Removes old code suggester calls<br> <li> Creates review with consolidated comments<br> <li> Updates response and slack notification handling </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1524/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+26/-33</a>&nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-26 03:55:12 +00:00
{ isUnifiedReview: true, includeHeader: false },
)
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
let reviewComments = []
let foundInvalidHunk = false
combine comment and suggestion for single hunk (#1524) Final Outcome: ![image](https://github.com/user-attachments/assets/38bd4176-28ef-4299-b634-f06044a3436d) Test: 1. Option 1 - https://github.com/codeflash-ai/my-best-repo/pull/248#pullrequestreview-2714641581 [Current] option 2- https://github.com/codeflash-ai/my-best-repo/pull/248#discussion_r2012735000 (Seems to have long data in inline suggestion) Only a 1 liner change from current one [Option 1] ![image](https://github.com/user-attachments/assets/b31bb8c9-e06c-445e-8312-c6a4b442f22b) [Option 2] ![image](https://github.com/user-attachments/assets/ae5ae72e-1e5c-49fc-9e7c-34717cae9070) closes https://linear.app/codeflash-ai/issue/CF-547/make-inline-suggestions-look-better ### **PR Type** - Enhancement ___ ### **Description** - Added logging for branch ref access - Replaced code suggester with unified review creation - Aggregated suggestions into reviewComments list - Updated review response and notification references ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Unified review creation with enhanced logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts <li>Logs branch ref access before review<br> <li> Removes old code suggester calls<br> <li> Creates review with consolidated comments<br> <li> Updates response and slack notification handling </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1524/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+26/-33</a>&nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-26 03:55:12 +00:00
// Process each valid hunk entry in the Map
for (const [filePath, hunks] of validHunks.entries()) {
// For each hunk in this file
for (const hunk of hunks) {
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
if (hunk.oldStart < hunk.oldEnd) {
const newContent = hunk.newContent.join("\n")
const isLongDiff = newContent.length > 500
let commentBody
if (isLongDiff) {
// Create a collapsible section for long diffs
commentBody =
prCommentBody +
"\n\n" +
"<details>\n" +
"<summary>Click to see suggested changes</summary>\n\n" +
"```suggestion\n" +
newContent +
"\n```\n" +
"</details>"
} else {
// For smaller diffs, show them directly
commentBody = prCommentBody + "\n\n" + "```suggestion\n" + newContent + "\n```"
}
reviewComments.push({
path: filePath,
line: hunk.oldEnd,
start_line: hunk.oldStart,
side: "RIGHT",
body: commentBody, // Format as a suggestion
})
} else {
console.log(
`Found invalid review range for ${filePath}: start_line (${hunk.oldStart}) must be less than line (${hunk.oldEnd}) with content ${hunk.newContent.join("\n")}`,
)
foundInvalidHunk = true
break
}
combine comment and suggestion for single hunk (#1524) Final Outcome: ![image](https://github.com/user-attachments/assets/38bd4176-28ef-4299-b634-f06044a3436d) Test: 1. Option 1 - https://github.com/codeflash-ai/my-best-repo/pull/248#pullrequestreview-2714641581 [Current] option 2- https://github.com/codeflash-ai/my-best-repo/pull/248#discussion_r2012735000 (Seems to have long data in inline suggestion) Only a 1 liner change from current one [Option 1] ![image](https://github.com/user-attachments/assets/b31bb8c9-e06c-445e-8312-c6a4b442f22b) [Option 2] ![image](https://github.com/user-attachments/assets/ae5ae72e-1e5c-49fc-9e7c-34717cae9070) closes https://linear.app/codeflash-ai/issue/CF-547/make-inline-suggestions-look-better ### **PR Type** - Enhancement ___ ### **Description** - Added logging for branch ref access - Replaced code suggester with unified review creation - Aggregated suggestions into reviewComments list - Updated review response and notification references ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>suggest-pr-changes.ts</strong><dd><code>Unified review creation with enhanced logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/suggest-pr-changes.ts <li>Logs branch ref access before review<br> <li> Removes old code suggester calls<br> <li> Creates review with consolidated comments<br> <li> Updates response and slack notification handling </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1524/files#diff-b4a862986fd70827b8dabcb3157972bd0d5d507cf9c12e5fbf56f24979d073f3">+26/-33</a>&nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-03-26 03:55:12 +00:00
}
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
if (foundInvalidHunk) {
break
}
}
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
// Add explanation comment
if (!foundInvalidHunk && reviewComments.length > 0) {
const review = await installationOctokit.rest.pulls.createReview({
owner,
repo,
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
pull_number: pullNumber,
commit_id: originalPrData.data.head.sha,
event: "COMMENT",
comments: reviewComments,
})
console.log(`Added review comment to PR #${pullNumber}: ${review.data.html_url}`)
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
if (
slackNotificationConfig[owner as keyof typeof slackNotificationConfig]?.includes(repo)
) {
await sendSlackMessage(`Suggestions made for ${review.data.html_url} in ${owner}/${repo}`)
}
posthog.capture({
distinctId: userId,
event: `cfapi-suggest-pr-changes-success-suggestions-made`,
properties: {
owner,
repo,
reviewId: review.data.id,
PRURL: review.data.html_url,
},
})
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
if (traceId !== "") {
let pull_request_db = await prisma.optimization_features.findUnique({
where: {
trace_id: traceId,
},
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
select: {
pull_request: true,
},
})
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
if (pull_request_db) {
// the trace_id is not in the database then ignore it, because it should already exist by this stage.
if (
pull_request_db.pull_request === null ||
pull_request_db.pull_request === undefined
) {
pull_request_db.pull_request = {}
}
;(pull_request_db as PullRequestDB).pull_request.review_suggestion_pr_url =
review.data.html_url
await prisma.optimization_features.update({
where: {
trace_id: traceId,
},
data: pull_request_db,
})
}
}
fix sentry & inline suggestions (#1546) ### **PR Type** Enhancement ___ ### **Description** - Introduce Sentry test endpoint for error capture - Integrate Sentry profiling into instrumentation - Update package dependencies for Sentry enhancements - Simplify optimization endpoints routing ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>sentry-test.ts</strong><dd><code>New Sentry test error endpoint added</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/endpoints/sentry-test.ts <li>Added a new endpoint that triggers a test error<br> <li> Captures and logs the error via Sentry </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-a1734472696f2996ba47e868f2d5bf56fa74c8010195afe7731898e6dd7325b9">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>index.ts</strong><dd><code>Integrated Sentry test router and endpoint adjustments</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/index.ts <li>Imported and applied the new Sentry test router<br> <li> Refined optimization endpoints list </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-c3e60be1461b6e80f9181080342927fd9df095197e8784ae0ff51daaec8d71d5">+3/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>instrument.ts</strong><dd><code>Improved Sentry instrumentation configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/instrument.ts <li>Enabled Sentry profiling integration<br> <li> Updated sampling rates and cleaned commentary </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-8f041330c6187cfe1b7aaa4598b1a8522d25226f0fe79c30ededa0c3bf95fa8a">+11/-9</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Dependencies</strong></td><td><table> <tr> <td> <details> <summary><strong>package.json</strong><dd><code>Updated package dependencies for Sentry improvements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> js/cf-api/package.json <li>Upgraded Sentry related packages to version 9<br> <li> Added OpenTelemetry packages for tracing integration </details> </td> <td><a href="https://github.com/codeflash-ai/codeflash-internal/pull/1546/files#diff-53ddfb1f8a02f1231d3d15a2e694ffe1407d2cc01d3e685de5653b67fec571c7">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
2025-04-02 01:19:57 +00:00
res.json(review.data.id)
} else {
// Don't create a dependent PR, just return an error response
const reason = foundInvalidHunk
? "invalid line ordering in hunks"
: "no valid review comments could be created"
console.log(`Cannot create review due to ${reason}`)
// Return a meaningful error response
return res.status(422).json({
error: `Cannot create review comments due to ${reason}`,
message: "Please consider creating a dependent PR instead",
})
}
}
} catch (error: any) {
console.log(`Error in /cfapi/suggest-pr-changes: ${error}`)
console.log(`Error message: ${error.message}`)
console.log(`Error stack: ${error.stack}`)
posthog.capture({
2025-01-06 22:01:20 +00:00
distinctId: req.userId,
event: `cfapi-suggest-pr-changes-failed-error`,
properties: {
error: error.message,
stack: error.stack,
},
})
2025-02-21 05:18:55 +00:00
res.status(500).send(`Error creating pull request: ${error.message}`)
2025-01-06 23:25:54 +00:00
}
2025-02-21 05:18:55 +00:00
}