Skip to content

refactor: migrate update API calls from PUT to PATCH#2910

Merged
aofei merged 1 commit intogoplus:devfrom
aofei:PATCH
Mar 6, 2026
Merged

refactor: migrate update API calls from PUT to PATCH#2910
aofei merged 1 commit intogoplus:devfrom
aofei:PATCH

Conversation

@aofei
Copy link
Copy Markdown
Member

@aofei aofei commented Mar 5, 2026

  • Add client.patch and remove obsolete client.put
  • Update user, project, asset, course, and course-series update calls

Updates #2892

Copilot AI review requested due to automatic review settings March 5, 2026 11:20
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the application's API interaction layer to improve consistency and adherence to RESTful principles. By transitioning update operations from PUT to PATCH, the codebase now more accurately reflects the nature of partial resource modifications. This change also includes a general cleanup, removing unnecessary async keywords from functions that already return promises, leading to a more streamlined and efficient API client.

Highlights

  • API Method Migration: Update API calls across the application have been migrated from using the PUT HTTP method to the more semantically appropriate PATCH method for partial updates.
  • Client Utility Update: The core client utility now includes a patch method for making PATCH requests and the obsolete put method has been removed.
  • Redundant Async Keyword Removal: The async keyword has been removed from several API functions that directly return a Promise, as it is not necessary in such cases and simplifies the code.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • spx-gui/src/apis/aigc.ts
    • Removed async keyword from createTask, getTask, cancelTask, enrichAssetSettings, genSpriteContentSettings, enrichBackdropSettings, enrichCostumeSettings, enrichAnimationSettings, and enrichSpriteSettings functions.
  • spx-gui/src/apis/asset.ts
    • Updated updateAsset function to use client.patch instead of client.put.
  • spx-gui/src/apis/common/client.ts
    • Added a new patch method to the Client class for making PATCH requests.
    • Removed the put method from the Client class.
  • spx-gui/src/apis/copilot.ts
    • Removed async keyword from generateMessage function and adjusted its return type casting.
  • spx-gui/src/apis/course-series.ts
    • Removed async keyword from getCourseSeries, addCourseSeries, deleteCourseSeries, and listCourseSeries functions.
    • Updated updateCourseSeries function to use client.patch instead of client.put.
  • spx-gui/src/apis/course.ts
    • Removed async keyword from getCourse, addCourse, deleteCourse, and listCourse functions.
    • Updated updateCourse function to use client.patch instead of client.put.
  • spx-gui/src/apis/project.ts
    • Removed async keyword from addProject, listProject, getProject, recordProjectView, likeProject, and unlikeProject functions.
    • Updated updateProject function to use client.patch instead of client.put.
  • spx-gui/src/apis/sb2xbp.ts
    • Removed async keyword from convertScratchToXbp function and explicitly cast its return to Promise<Blob>.
  • spx-gui/src/apis/user.ts
    • Removed async keyword from getUser, getSignedInUser, listUsers, follow, and unfollow functions.
    • Updated updateSignedInUser function to use client.patch instead of client.put.
  • spx-gui/src/apis/util.ts
    • Removed async keyword from makeObjectUrls function and wrapped its return in Promise.resolve.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively refactors the API calls by migrating update operations from PUT to PATCH requests, aligning with RESTful best practices for partial updates. It also removes the now obsolete client.put method. Furthermore, several asynchronous functions that did not utilize await internally have been refactled to return Promises directly, improving code conciseness and efficiency. The changes are well-executed and enhance the codebase's maintainability and adherence to modern TypeScript patterns.

Comment thread spx-gui/src/apis/sb2xbp.ts
Comment thread spx-gui/src/apis/util.ts Outdated
@fennoai
Copy link
Copy Markdown
Contributor

fennoai Bot commented Mar 5, 2026

Clean, focused refactor. The PUT→PATCH migration is consistent across all update endpoints, and removing redundant async/await wrappers is a sound improvement.

Two issues worth addressing: (1) convertScratchToXbp in sb2xbp.ts — the synchronous throw before the async work is no longer auto-wrapped in a rejected Promise now that async is removed, which causes it to escape withLoading's control flow. (2) The commented-out code in util.ts uses await and would fail to compile if uncommented in the now non-async function — it should be updated to use .then() syntax.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the GUI API layer to align with the updated API spec semantics by switching update operations from PUT to PATCH, and refactors several API wrappers to remove redundant async/await.

Changes:

  • Add client.patch() and remove client.put() from the shared API client.
  • Switch user/project/asset/course/course-series update calls to use PATCH.
  • Refactor various API wrapper functions to return Promises directly instead of using async/await.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spx-gui/src/apis/common/client.ts Replace put() with patch() on the shared client.
spx-gui/src/apis/user.ts Switch signed-in user update to PATCH; remove redundant async/await in wrappers.
spx-gui/src/apis/project.ts Switch project update to PATCH; remove redundant async/await in wrappers.
spx-gui/src/apis/asset.ts Switch asset update to PATCH.
spx-gui/src/apis/course.ts Switch course update to PATCH; remove redundant async/await in wrappers.
spx-gui/src/apis/course-series.ts Switch course-series update to PATCH; remove redundant async/await in wrappers.
spx-gui/src/apis/util.ts Refactor makeObjectUrls wrapper to be non-async.
spx-gui/src/apis/sb2xbp.ts Refactor Scratch conversion wrapper to be non-async.
spx-gui/src/apis/copilot.ts Refactor generateMessage wrapper to return the Promise directly.
spx-gui/src/apis/aigc.ts Refactor several wrappers to return Promises directly.
Comments suppressed due to low confidence (1)

spx-gui/src/apis/sb2xbp.ts:19

  • convertScratchToXbp no longer uses async, so the file size guard now throws synchronously instead of returning a rejected Promise. This is a behavioral change for callers that pass the result into utilities expecting a Promise (e.g. withLoading(promise, ...)) and can also change how errors are surfaced/handled. Consider keeping async here, or return a rejected Promise for oversize files to preserve Promise-based error semantics.
export function convertScratchToXbp(file: File, signal?: AbortSignal) {
  if (file.size > maxFileSize) {
    const maxFileSizeHumanized = humanizeFileSize(maxFileSize)
    throw new DefaultException({
      en: `File size exceeds limit (max ${maxFileSizeHumanized.en})`,
      zh: `文件尺寸超限(最大 ${maxFileSizeHumanized.zh})`
    })

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread spx-gui/src/apis/util.ts Outdated
- Add `client.patch` and remove obsolete `client.put`
- Update user, project, asset, course, and course-series update calls

Updates goplus#2892

Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
@aofei aofei merged commit 470ff22 into goplus:dev Mar 6, 2026
5 checks passed
@aofei aofei deleted the PATCH branch March 6, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants