Code processing method and device, electronic equipment and nonvolatile storage medium

By using shadow version control and a multimodal coding model, the system accurately identifies and distinguishes between AI-generated and user-modified code, solving the line-level conflict overwrite problem when the AI ​​programming assistant is undoing code. This achieves accuracy and security in code undoing, improving development efficiency and user trust.

CN122240451APending Publication Date: 2026-06-19HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUNAN HAPPLY SUNSHINE INTERACTIVE ENTERTAINMENT MEDIA CO LTD
Filing Date
2026-03-12
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing AI programming assistants cannot accurately distinguish between user-manually modified code and AI-generated code when undoing code. This often results in line-level conflicts overwriting user modifications during undo operations. Furthermore, the lack of understanding of the functional intent behind code changes leads to context pollution and response bias.

Method used

By introducing a shadow version control system and an intent conflict mediation engine based on LLM, and through a semantic-state dual-track synchronous architecture, we can accurately identify and distinguish between AI-generated code and user-modified code. We adopt patch synthesis processing to only undo AI-generated code while retaining user modifications, and use a multimodal coding model to evaluate semantic and structural conflict scores.

Benefits of technology

It enables precise differentiation between AI-generated content and user-modified content when revoking AI-generated code, avoiding accidental overwriting of user code, improving the security of code collaboration and the reliability of human-machine collaborative development, and reducing the time required for manual repair due to AI-induced errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240451A_ABST
    Figure CN122240451A_ABST
Patent Text Reader

Abstract

This application discloses a code processing method, apparatus, electronic device, and non-volatile storage medium. The method includes: receiving a user's revocation command; determining a first type of code and a second type of code in a main repository corresponding to the user's revocation command, wherein the first type of code is code generated by an artificial intelligence engine based on the user's request intent in a target dialogue message, and the second type of code is code manually modified by the user in the main repository after the first type of code corresponding to the target dialogue message is generated and before the user's revocation command is received; determining a conflict score between the first type of code and the second type of code; and performing patch synthesis processing on the code in the main repository if the conflict score is less than a preset threshold. This application solves the technical problem in related technologies where user-modified code is incorrectly overwritten due to physical line-level conflicts when revoking AI-generated code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer software development and artificial intelligence technology, and more specifically, to a code processing method, apparatus, electronic device, and non-volatile storage medium. Background Technology

[0002] Current mainstream AI programming assistants (such as GitHub Copilot and Cursor) primarily rely on a loosely coupled interaction model between dialogue history and code file system when assisting developers in writing code. In their workflow, AI-generated code changes are directly written to the user's main code repository, and each interaction between the user and the AI ​​is merely a linear text record, without a structured association with the code state. When a user undoes an AI-generated code change, traditional tools can only perform a rollback based on Git's line-level diff comparison, unable to distinguish which changes were AI-generated and which were manually adjusted by the user. This leads to situations where subsequent manual modifications by the user occur near the AI-modified code segment, often resulting in the undo operation being forced to overwrite or lose important user changes due to "line conflicts." Furthermore, existing systems lack the semantic understanding of the "functional intent" behind code changes, unable to determine whether the user's manual modifications depend on the logic generated by the AI, thus failing to achieve semantic-based intelligent decision-making. Simultaneously, because dialogue history and code state are not maintained synchronously, the AI ​​may still reference the already undone context in subsequent responses, causing context pollution and response bias.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] This application provides a code processing method, apparatus, electronic device, and non-volatile storage medium to at least solve the technical problem in the related art where manual code modifications by users are incorrectly overwritten due to physical line-level conflicts when undoing AI-generated code.

[0005] According to one aspect of the embodiments of this application, a code processing method is provided, comprising: receiving a user revocation instruction, wherein the user revocation instruction is used to instruct the revocation of AI-generated code corresponding to a target dialogue message, the target dialogue message being any round of dialogue message in a historical session between the user and an AI engine; determining a first type of code and a second type of code in a main repository corresponding to the user revocation instruction, wherein the first type of code is code generated by the AI ​​engine based on the user's request intent in the target dialogue message, and the second type of code is code manually modified by the user in the main repository after the generation of the first type of code corresponding to the target dialogue message and before receiving the user revocation instruction; determining a conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure; and performing patch synthesis processing on the code in the main repository when the conflict score is less than a preset score threshold, wherein the patch synthesis processing is used to revoke only the first type of code generated by the AI ​​engine while retaining the second type of code manually modified by the user.

[0006] Optionally, the method further includes: obtaining AI-generated code generated by the AI ​​engine in response to a user-sent dialogue message; writing the AI-generated code into an index file of a shadow repository and recording the correspondence between the AI-generated code and the dialogue message, wherein the shadow repository and the main repository reuse the same object database, but the shadow repository has pointers and index files independent of the main repository; and, if the AI-generated code is successfully written into the shadow repository, applying the AI-generated code to the main repository, wherein the code in the main repository is displayed on the front-end interactive interface.

[0007] Optionally, before obtaining the AI-generated code generated by the AI ​​engine in response to the user's dialogue message, the method further includes: upon receiving the user's dialogue message, determining whether there is any unsubmitted manually modified code in the main repository workspace by comparing the status of the main repository workspace and the status of the shadow repository; if it is determined that there is unsubmitted manually modified code, temporarily storing the unsubmitted manually modified code and submitting the unsubmitted manually modified code to the shadow repository.

[0008] Optionally, determining the first and second types of code corresponding to the user's cancellation instruction in the main repository includes: determining the target dialogue message corresponding to the user's cancellation instruction; extracting the AI-generated code corresponding to the target dialogue message from the shadow repository based on the correspondence between AI-generated code and dialogue messages, and identifying the AI-generated code as the first type of code corresponding to the user's cancellation instruction; determining the code portion in the main repository workspace that has changed after the generation of the first type of code by comparing the state of the main repository workspace with the state of the shadow repository when the first type of code is successfully written, and extracting the code manually modified by the user from the changed code portion to obtain the second type of code corresponding to the user's cancellation instruction.

[0009] Optionally, determining the conflict score between the first type of code and the second type of code includes: converting the first type of code and the second type of code into vector form respectively to obtain a first intent vector corresponding to the first type of code and a second intent vector corresponding to the second type of code; calculating the cosine similarity between the first intent vector and the second intent vector to obtain a first relevance parameter, wherein the first relevance parameter is used to characterize the degree of relevance between the first type of code and the second type of code in terms of functional semantics; determining the first node corresponding to the first type of code and the second node corresponding to the second type of code in the abstract syntax tree, and determining the overlap between the first node and the second node in the abstract syntax tree to obtain a second relevance parameter, wherein the second relevance parameter is used to characterize the degree of relevance between the first type of code and the second type of code in terms of code structure; and determining the conflict score based on the first relevance parameter and the second relevance parameter.

[0010] Optionally, performing patch compositing on the code in the main repository includes: determining a set of change nodes by comparing the code in the current main repository with the code in the shadow repository before writing the first type of code, wherein the set of change nodes contains at least one change node, and each change node corresponds to a part of the code segment that has been changed; determining the local semantic vector of the code segment corresponding to each change node, and determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message; determining the tag information corresponding to each change node in the set of change nodes based on the relevance score, wherein the tag information is used to indicate whether to retain the code segment corresponding to the change node during the patch compositing process; and deleting or retaining the code segment corresponding to the change node in the main repository according to the tag information.

[0011] Optionally, determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message includes: processing the code segment corresponding to the change node using the code feature channel in the multimodal coding model to obtain the local semantic vector. The multimodal coding model is trained on the target training set and then trained through cross-modal alignment of code and text. The target training set includes multiple training samples, each containing a code segment and the corresponding text corpus; processing the target dialogue message using the intent feature channel in the multimodal coding model to obtain the user intent vector, where the user intent vector and the local semantic vector reside in the same high-dimensional semantic space; and calculating the cosine similarity between the local semantic vector and the user intent vector to obtain the relevance score.

[0012] According to another aspect of the embodiments of this application, a code processing apparatus is also provided, comprising: an instruction receiving module, configured to receive a user revocation instruction, wherein the user revocation instruction is used to instruct the revocation of AI-generated code corresponding to a target dialogue message, the target dialogue message being any round of dialogue message in a historical session between the user and the AI ​​engine; a code determination module, configured to determine a first type of code and a second type of code in a main repository corresponding to the user revocation instruction, wherein the first type of code is code generated by the AI ​​engine based on the user's request intent in the target dialogue message, and the second type of code is code manually modified by the user in the main repository after the first type of code corresponding to the target dialogue message is generated and before the user revocation instruction is received; a conflict analysis module, configured to determine a conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure; and a code revocation module, configured to perform patch synthesis processing on the code in the main repository when the conflict score is less than a preset score threshold, wherein the patch synthesis processing is used to revoke only the first type of code generated by the AI ​​engine while retaining the second type of code manually modified by the user.

[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the program executes a code processing method during runtime.

[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes a code processing method by running the computer program.

[0015] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program, wherein when the computer program is executed by a processor, it implements the steps of a code processing method.

[0016] In this embodiment, a user revocation instruction is received, wherein the user revocation instruction is used to instruct the revocation of AI-generated code corresponding to the target dialogue message, and the target dialogue message is any round of dialogue message in the user's historical conversation with the AI ​​engine; a first type of code and a second type of code corresponding to the user revocation instruction are determined in the main repository, wherein the first type of code is code generated by the AI ​​engine based on the user's request intent in the target dialogue message, and the second type of code is code manually modified by the user in the main repository after the generation of the first type of code corresponding to the target dialogue message and before receiving the user revocation instruction; a conflict score is determined between the first type of code and the second type of code, wherein the conflict score is used to characterize the first type of code. The degree of correlation between the code and the second type of code in terms of functional semantics and code structure; when the conflict score is less than a preset score threshold, patch synthesis processing is performed on the code in the main repository. The patch synthesis processing is used to only undo the first type of code generated by the artificial intelligence engine while retaining the second type of code manually modified by the user. By introducing a natural language conversation history and code library file state synchronization mechanism, the boundary between AI-generated content and user-customized modification content is accurately distinguished. It can achieve controllable undoing of AI-generated code without interfering with the user's work results, thereby solving the technical problem in related technologies where user-manually modified code is incorrectly overwritten due to physical line-level conflicts when undoing AI-generated code. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1 This is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a code processing method according to an embodiment of this application;

[0019] Figure 2 This is a schematic diagram of a code processing method flow according to an embodiment of this application;

[0020] Figure 3 This is a schematic diagram of the system architecture of an AI development state synchronization system based on semantic intent alignment, according to an embodiment of this application.

[0021] Figure 4 This is a schematic diagram of a code revocation process provided according to an embodiment of this application;

[0022] Figure 5 This is a schematic diagram of the structure of a code processing device provided according to an embodiment of this application. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0025] In the AI-assisted development process of related technologies, when undoing AI-generated code, issues such as "physical conflicts" and "semantic breaks" can easily arise between the code to be undone and the code subsequently manually modified by the user. AI programming assistants in related technologies (such as GitHub Copilot and Cursor) mainly face the following challenges:

[0026] 1) State disconnect: Chat history is linear, while the file system is stateful. Undoing a chat message usually cannot accurately restore the code side effects of that message.

[0027] 2) Physical conflicts: Traditional version control (such as Git) is based on "lines". If an AI modifies a piece of code, and then a user manually inserts logic into that code, when the user wants to undo the AI's changes, traditional tools will be forced to overwrite the user's manual changes due to "line conflicts", resulting in data loss.

[0028] 3) Lack of intent understanding: Existing tools do not understand the functional intent behind code changes and cannot determine whether the user's manual modifications depend on the logic previously generated by the AI.

[0029] To address the aforementioned issues, this application provides a solution that, by introducing a Shadow Version Control System (Shadow VCS) and an LLM-based intent conflict resolution engine, can significantly reduce code maintenance costs in AI pair programming, decrease manual repair time caused by AI errors, and increase developers' trust in and frequency of use of AI tools. This will be explained in detail below.

[0030] According to an embodiment of this application, a method embodiment for code processing is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0031] The methods and embodiments provided in this application can be executed on mobile terminals, computer terminals, or similar computing devices. Figure 1 A hardware structure block diagram of a computer terminal (or electronic device) for implementing a code processing method is shown. Figure 1 As shown, the computer terminal 10 (or electronic device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0032] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or electronic device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0033] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the code processing method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the above-mentioned code processing method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0034] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0035] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or electronic device).

[0036] Under the above operating environment, this application provides a code processing method. Figure 2 This is a schematic diagram of a code processing method flow provided according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0037] Step S202: Receive user cancellation instruction, wherein the user cancellation instruction is used to indicate the cancellation of the AI-generated code corresponding to the target dialogue message, and the target dialogue message is any round of dialogue message in the user's historical conversation with the AI ​​engine;

[0038] In this embodiment, the user's cancellation instruction is explicitly used to instruct the cancellation of AI-generated code corresponding to a specific dialogue message. This dialogue message originates from any round of interaction in the historical conversation record between the user and the AI ​​engine. The act of receiving this instruction does not involve limitations on the source of the instruction, the triggering method, or the interactive interface; it only requires that the system can recognize and respond to a specific round of dialogue message specified by the user, which serves as the sole basis for triggering the code cancellation operation.

[0039] Step S204: Determine the first type of code and the second type of code in the main repository that correspond to the user's cancellation instruction. The first type of code is generated by the artificial intelligence engine based on the user's request intent in the target dialogue message. The second type of code is the code that the user manually modifies in the main repository after generating the first type of code corresponding to the target dialogue message and before receiving the user's cancellation instruction.

[0040] Step S206: Determine the conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure;

[0041] Step S208: If the conflict score is less than a preset score threshold, perform patch synthesis processing on the code in the main repository. The patch synthesis processing is used to only undo the first type of code generated by the artificial intelligence engine and retain the second type of code manually modified by the user.

[0042] When the conflict score is below a preset threshold, the system performs patch synthesis on the code in the main repository. This process only reverts the first type of code generated by the AI ​​engine, while ensuring that the second type of code manually modified by users remains unaffected. This operation does not rely on overwriting rollbacks based on file line numbers or physical locations. Instead, it selectively corrects the code in the main repository based on the conflict score, removing only AI-generated content that is deemed safe to revert, while preserving all user-modified parts that are not identified as conflicting. This achieves a non-destructive simplification and adjustment of the codebase.

[0043] By introducing a natural language conversation history and code repository file state synchronization mechanism through the above steps, the boundary between AI-generated content and user-customized modifications is accurately distinguished. This allows for the controlled reversal of AI-generated code without interfering with the user's work, thereby solving the technical problem in related technologies where manual modifications by the user are incorrectly overwritten due to physical line-level conflicts when reversing AI-generated code.

[0044] The code processing method in steps S202 to S208 of the embodiments of this application will be further described below.

[0045] In this embodiment, upon receiving a user's revocation command, the system first identifies the AI-generated code (first type of code) corresponding to the command and the code manually modified by the user afterward (second type of code). By analyzing the correlation between the two at the functional semantic and code structure levels, a conflict score that truly reflects their semantic conflict and structural coupling relationship is calculated. When the score is lower than a preset threshold, it indicates that there is no substantial functional dependency or structural interference between the user's manually modified content and the AI-generated code. The system then triggers patch synthesis processing, accurately stripping the AI-generated code while fully preserving the user's manually modified code content. This avoids the problem of user code being mistakenly overwritten due to the crude rollback method based on physical line-level differences in traditional methods. It effectively solves the technical defect of mistakenly clearing user's work when revoking AI-generated code due to the inability to identify semantic correlation. It achieves accurate respect for user intent and intelligent differentiation of code changes, significantly improving the security of code collaboration and the reliability of human-machine collaborative development.

[0046] To achieve the above functions, this application proposes a semantic-state dual-track synchronization architecture, specifically as follows: Figure 3 As shown, Figure 3 This paper demonstrates the system architecture and data flow of the AI ​​code generation stage in this embodiment, which embodies the dual-track mechanism of "isolated writing to the shadow repository" and "semantic intent extraction": When a user sends a Prompt through the session manager, the IDE plugin layer physically writes the AI-generated code into the user's workspace (i.e., the main repository workspace) for real-time preview. Simultaneously, a Hook mechanism triggers the shadow version control system to record code change snapshots in an isolated environment, achieving state synchronization between the main repository and the shadow repository. At the same time, the semantic intent extractor captures code changes to generate semantic vectors, which, along with message identifiers, are stored in a message-intent-snapshot mapping table, providing dialogue-level coordinate positioning and semantic retrieval capabilities for subsequent accurate reversal. A detailed description follows.

[0047] In this embodiment, a "transparent proxy layer" can be built in the user's local development environment, located between the user's main repository and the AI ​​generation engine (i.e., the artificial intelligence engine). This transparent proxy layer enables a synchronization mechanism between the main repository and the shadow repository, as detailed below.

[0048] In some embodiments of this application, the method further includes: obtaining AI-generated code generated by the AI ​​engine in response to a dialogue message sent by the user; writing the AI-generated code into an index file of a shadow repository and recording the correspondence between the AI-generated code and the dialogue message, wherein the shadow repository and the main repository reuse the same object database, but the shadow repository has pointers and index files independent of the main repository; and, if the AI-generated code is successfully written into the shadow repository, applying the AI-generated code to the main repository, wherein the code in the main repository is displayed on the front-end interactive interface.

[0049] Specifically, when the plugin starts and the project loads, the system can initialize a shadow repository in a hidden path under the project root directory (such as .vscode / .shadow_git / ). To avoid doubling disk space usage, the system does not perform a full file copy. Instead, it uses `git clone --shared` or hard link technology to allow the shadow repository to directly reuse the main repository's `.git / objects` database. The shadow repository has independent pointers and index files, ensuring that its commit history is completely decoupled from the main repository and does not interfere with each other.

[0050] When AI-generated code changes, the system first retrieves the code generated by the AI ​​engine in response to the user's dialogue message and writes it to the shadow repository. Specifically, the AI-generated code can be applied to the index of the shadow repository first, and a commit can be generated. Only after the shadow repository has been successfully written will the system apply the generated file changes to the user's main workspace for real-time preview. In other words, the AI-generated code is only applied to the main repository after it has been successfully written to the shadow repository.

[0051] To ensure that the AI's code generation is based on the latest user context, this application also introduces a system implementation of an "instant snapshot" strategy, which can achieve passive synchronization of user increments, as detailed below.

[0052] In some embodiments of this application, before obtaining the AI-generated code generated by the AI ​​engine in response to a user-sent dialogue message, the method further includes: upon receiving a user-sent dialogue message, determining whether there is any unsubmitted manually modified code in the main repository workspace by comparing the status of the main repository workspace and the status of the shadow repository; if it is determined that there is unsubmitted manually modified code, temporarily storing the unsubmitted manually modified code and submitting the unsubmitted manually modified code to the shadow repository.

[0053] Specifically, before a user sends a dialogue message to the AI ​​engine to request code generation, the system proactively identifies any uncommitted manual modifications by comparing the real-time status of the main repository's workspace with the current status of the shadow repository. If uncommitted modifications are detected, they are immediately stored and committed to the shadow repository, ensuring that the context recorded in the shadow repository always reflects the user's latest actual working state. For example, at the moment a user sends an AI dialogue request message, the system compares the status of the main repository's workspace and the shadow repository. If uncommitted manual modifications are detected, the system automatically stores and commits these changes to the shadow repository, ensuring that the shadow repository is always a "superset" of the main repository, containing all user code but with finer granularity.

[0054] Therefore, when the AI ​​engine generates code based on this dialogue message, the context it relies on is consistent with the user's actual editing progress. This ensures that when the undo operation is performed, the conflict score between the first type of code and the second type of code can accurately reflect the real correlation between the two in terms of functional semantics and code structure, avoiding semantic misjudgment and inaccurate rollback decisions caused by the lag in the shadow repository state.

[0055] This application embodiment implements pre-isolation and session-level traceability of AI-generated changes through a shadow repository, avoiding the risk of accidental overwriting caused by code mixing in an unrecorded environment, ensuring that undo operations are accurate, traceable, and reproducible, and ultimately achieving reliable protection of the results of user manual intervention in the AI-assisted coding process, improving the security and user experience of collaborative code editing.

[0056] The following describes the workflow steps for the scenario where a user plans to revoke the target dialogue message, specifically the AI-generated code (Type 1 code). The overall workflow is as follows: Figure 4 As shown, when a user requests to retract a message, the system first retrieves the AI ​​change set A (i.e., the first type of code) corresponding to the message from the mapping table, and compares it with the user's subsequent modifications U (i.e., the second type of code) captured in the current workspace. Then, it converts both into vectors through semantic encoding and calculates a semantic conflict score (Score). If the Score is below the threshold (no conflict), the system extracts the original snapshot of the shadow repository and merges the user's modifications U as a patch. Finally, it performs a non-destructive rollback update of the workspace, achieving the core effect of retracting only the AI ​​code while retaining the user's modifications. If the Score is above the threshold (logical dependency exists), the system prompts the user that the current manual modification depends on this AI logic and suggests partial retraction or manual adjustment. The following is a detailed explanation of this process.

[0057] Upon receiving a user's cancellation instruction, first determine the first type of code and the second type of code corresponding to the user's cancellation instruction. The specific steps are as follows.

[0058] In some embodiments of this application, determining the first type of code and the second type of code corresponding to the user's cancellation instruction in the main repository includes the following steps: determining the target dialogue message corresponding to the user's cancellation instruction; extracting the AI-generated code corresponding to the target dialogue message from the shadow repository based on the correspondence between AI-generated code and dialogue messages, and determining the AI-generated code as the first type of code corresponding to the user's cancellation instruction; determining the code portion in the main repository workspace that has changed after the generation of the first type of code by comparing the state of the main repository workspace with the state of the shadow repository when the first type of code is successfully written, and extracting the code manually modified by the user from the changed code portion to obtain the second type of code corresponding to the user's cancellation instruction.

[0059] Specifically, by receiving user revocation commands and determining their corresponding target dialogue messages, and combining the pre-recorded correspondence between AI-generated code and dialogue messages in the shadow repository (mapping table), the first type of code generated in that round of dialogue can be accurately extracted. Based on this, by comparing the current workspace state of the main repository with the historical snapshot state of the shadow repository when the first type of code was successfully written, all changes that have occurred in the main repository since the AI ​​code was written can be directly identified, and the second type of code formed by user manual modifications can be separated from it. Thus, without relying on semantic parsing or AST analysis, a literal and traceable precise division of AI-generated code and user-mandated changes can be achieved, ensuring that subsequent patch synthesis operations only remove the AI-generated part while fully preserving the results of user intervention.

[0060] Next, the semantic conflict moderation model is used to analyze the conflict scores between the first type of code and the second type of code. The specific steps are as follows.

[0061] In some embodiments of this application, determining the conflict score between the first type of code and the second type of code includes the following steps: converting the first type of code and the second type of code into vector form respectively to obtain a first intent vector corresponding to the first type of code and a second intent vector corresponding to the second type of code; calculating the cosine similarity between the first intent vector and the second intent vector to obtain a first relevance parameter, wherein the first relevance parameter is used to characterize the degree of relevance between the first type of code and the second type of code in terms of functional semantics; determining the first node corresponding to the first type of code and the second node corresponding to the second type of code in the abstract syntax tree, and determining the overlap between the first node and the second node in the abstract syntax tree to obtain a second relevance parameter, wherein the second relevance parameter is used to characterize the degree of relevance between the first type of code and the second type of code in terms of code structure; and determining the conflict score based on the first relevance parameter and the second relevance parameter.

[0062] Specifically, we can first use the first type of code generated by artificial intelligence. The second type of code modified manually by the user These are converted into intent vectors respectively. For example, the encoding model can combine the code diff and the corresponding commit message / prompt to generate the first intent vector corresponding to the first type of code. The second intent vector corresponding to the second type of code Then, the cosine similarity between the two is calculated. To obtain the first relevant parameter representing the degree of semantic relevance of function, where the value of cosine similarity ranges from [0,1]. The larger the value, the closer the functional intentions of the two are and the higher the possibility of conflict.

[0063] Additionally, it can identify the nodes corresponding to the two types of code based on the abstract syntax tree structure and calculate their overlap. To obtain a second correlation parameter that characterizes the degree of correlation between code structures, this parameter is used to quantify the physical overlap between two code segments at the Abstract Syntax Tree (AST) level. It can be calculated by determining how many of the AST nodes modified by the user are directly modified from AI-generated nodes.

[0064] Finally, the conflict score can be determined by combining the first and second relevant parameters, as shown in the following formula:

[0065]

[0066] in, is a weighting coefficient used to balance the weights of "semantic conflict" and "physical conflict".

[0067] Through the above process, this application embodiment can accurately assess the dependency relationship between two types of code from both semantic function and code structure dimensions without relying on physical line-level matching. It can effectively distinguish whether user modifications are substantially related to AI-generated code, avoid erroneous overwriting due to semantically unrelated or structurally independent modifications being misjudged as conflicts, achieve accurate undoing of AI-generated code and lossless preservation of user modifications, and ultimately solve the problem of unnecessary code overwriting or erroneous preservation caused by the inability of traditional line-level conflict detection mechanisms to identify complex dependencies at the semantic and structural levels, thereby improving the intelligence and security of code undoing operations.

[0068] If the conflict score is lower than the preset score threshold, it indicates that there is no conflict between the first type of code and the second type of code. The workspace can be updated by performing a non-destructive rollback using the synthesis engine, as detailed below.

[0069] In some embodiments of this application, performing patch synthesis processing on the code in the main repository includes: determining a set of change nodes by comparing the code in the current main repository with the code in the shadow repository before writing the first type of code, wherein the set of change nodes contains at least one change node, and each change node corresponds to a part of the code segment that has been changed; determining the local semantic vector of the code segment corresponding to each change node, and determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message; determining the tag information corresponding to each change node in the set of change nodes based on the relevance score, wherein the tag information is used to indicate whether to retain the code segment corresponding to the change node during the patch synthesis process; and performing deletion or retention operations on the code segment corresponding to the change node in the main repository according to the tag information.

[0070] In this embodiment, the synthesis engine does not use simple file overwriting, but instead generates a reverse patch that only removes the vector. Strongly correlated AST branches, while retaining the relevant branches through AST recombination technology. Related code nodes.

[0071] Specifically, we can first calculate the difference between the current working area and the previous version (Pre-AI state) of the shadow repository, locate all the changed AST node sets {Node_1, Node_2, ..., Node_n}, that is, by comparing the code in the current main repository with the code in the shadow repository before the first type of code was written, we can accurately identify all the local change fragments caused by the AI-generated code, and form a change node set containing at least one change node;

[0072] Then, for each changed node Node_i (e.g., a function call, a conditional branch, or a line of comment), the code encoder can independently generate its local semantic vector; and further calculate the cosine similarity between the local semantic vector corresponding to each changed node and the user intent vector AI intent vector corresponding to the target dialogue message to be revoked, denoted as the relevance score S, as follows.

[0073] In some embodiments of this application, determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message includes: processing the code segment corresponding to the change node using the code feature channel in a multimodal coding model to obtain the local semantic vector, wherein the multimodal coding model is trained on a target training set and obtained after cross-modal alignment training of code and text, the target training set includes multiple training samples, each training sample containing a code segment and the corresponding text corpus; processing the target dialogue message using the intent feature channel in the multimodal coding model to obtain the user intent vector, wherein the user intent vector and the local semantic vector are located in the same high-dimensional semantic space; and calculating the cosine similarity between the local semantic vector and the user intent vector to obtain the relevance score.

[0074] In this embodiment, to map the code change diff and the user's natural language intent prompt to the same high-dimensional semantic space for measurement, this application proposes a dual-path feature extraction and spatial alignment architecture. Specifically, a multimodal coding model pre-trained on a large-scale code-text corpus can be used to extract local semantic vectors and user intent vectors. Feature extraction and alignment are achieved by utilizing the cross-modal alignment capabilities learned within the multimodal coding model.

[0075] This multimodal coding model can be logically divided into two coding channels: a code feature channel and an intent feature channel, generating a fixed-length code semantic vector V_code (local semantic vector) and an intent semantic vector V_intent (user intent vector). Since the selected pre-trained model (such as GraphCodeBERT) has already completed multimodal alignment through MLM (masked language model) and DFG (data flow graph) tasks during the pre-training stage, the system can directly extract the vector corresponding to the [CLS] label of the last hidden state of the model without the need for additional projection layer training, thus ensuring that V_code and V_intent are comparable in the same geometric space.

[0076] Furthermore, a relevance score can be obtained by calculating the cosine similarity between two vectors. This score is used to accurately quantify the degree of association between AI-generated code and user-modified code at the functional semantic level, thereby effectively distinguishing between semantically unrelated generated code and user-intention-driven modifications during undo operations, as detailed below.

[0077] In this embodiment, based on relevance scores, labels for retention or deletion can be dynamically assigned to each changed node, enabling fine-grained semantic judgment of code changes. For example, assuming a relevance threshold θ of 0.8, if the relevance score S>=θ, the node is determined to be a core component of the AI-generated logic and marked as "to be removed"; if S<θ, the node is determined to be irrelevant logic manually inserted by the user and marked as "retained". The synthesis engine then performs pruning operations on the AST tree based on these labels, removing only branches marked as "to be removed," and finally serializing the remaining AST into a reverse patch applied to the file. This achieves intelligent retention of manually modified content with low relevance to the user's true intent when revoking AI-generated code, thus breaking through the traditional coarse-grained processing method that relies solely on overall code conflict scores. It effectively avoids the problem of mistakenly deleting valid user modifications due to physical line-level overlap, achieving intelligent code management that accurately distinguishes between AI-generated and manually modified code in complex collaborative scenarios, protecting user code sovereignty.

[0078] This application's solution, upon receiving a user's revocation command, first identifies the first type of AI-generated code corresponding to the target dialogue message, and the second type of code manually modified by the user in the main repository after the code's generation but before the revocation command is received. Then, by quantifying the correlation between the first and second types of code in terms of functional semantics and code structure, a conflict score reflecting the potential conflict risk between the two is calculated. When this conflict score is below a preset threshold, it is determined that the user-modified code and the AI-generated code are logically highly independent. At this point, a patch synthesis process that only clears the AI-generated portion is triggered, ensuring that the user's self-modified second type of code is completely preserved, thereby avoiding the physical line overlap and erroneous overwriting problem caused by traditional line-level revocation operations. This process accurately distinguishes the boundary between AI-generated content and user-customized modifications, achieving controllable revocation of AI-generated code without interfering with the user's work. It effectively solves the technical problem in existing technologies where user-modified code is erroneously overwritten due to physical line-level conflicts when revoking AI-generated code, achieving the technical effect of maintaining user code autonomy and integrity while ensuring development efficiency.

[0079] According to an embodiment of this application, an embodiment of a code processing apparatus is also provided. Figure 5 This is a schematic diagram of the structure of a code processing device according to an embodiment of this application. Figure 5 As shown, the device includes:

[0080] The instruction receiving module 50 is used to receive user cancellation instructions, wherein the user cancellation instructions are used to indicate the cancellation of the AI-generated code corresponding to the target dialogue message, and the target dialogue message is any round of dialogue message in the user's historical conversation with the AI ​​engine;

[0081] The code determination module 52 is used to determine the first type of code and the second type of code in the main repository that correspond to the user's cancellation instruction. The first type of code is the code generated by the artificial intelligence engine based on the user's request intent in the target dialogue message. The second type of code is the code that the user manually modifies in the main repository after generating the first type of code corresponding to the target dialogue message and before receiving the user's cancellation instruction.

[0082] The conflict analysis module 54 is used to determine the conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure;

[0083] The code undo module 56 is used to perform patch synthesis processing on the code in the main repository when the conflict score is less than a preset score threshold. The patch synthesis processing is used to undo only the first type of code generated by the artificial intelligence engine and retain the second type of code manually modified by the user.

[0084] Optionally, the code processing device is further configured to: acquire AI-generated code generated by the AI ​​engine in response to a dialogue message sent by the user; write the AI-generated code into an index file of a shadow repository and record the correspondence between the AI-generated code and the dialogue message, wherein the shadow repository and the main repository reuse the same object database, but the shadow repository has pointers and index files independent of the main repository; and, if the AI-generated code is successfully written into the shadow repository, apply the AI-generated code to the main repository, wherein the code in the main repository is displayed on the front-end interactive interface.

[0085] Optionally, before obtaining the AI-generated code generated by the AI ​​engine in response to the user's dialogue message, the method further includes: upon receiving the user's dialogue message, determining whether there is any unsubmitted manually modified code in the main repository workspace by comparing the status of the main repository workspace and the shadow repository; if it is determined that there is unsubmitted manually modified code, temporarily storing the unsubmitted manually modified code and submitting it to the shadow repository.

[0086] Optionally, determining the first and second types of code corresponding to the user's cancellation instruction in the main repository includes: determining the target dialogue message corresponding to the user's cancellation instruction; extracting the AI-generated code corresponding to the target dialogue message from the shadow repository based on the correspondence between AI-generated code and dialogue messages, and identifying the AI-generated code as the first type of code corresponding to the user's cancellation instruction; determining the code portion in the main repository workspace that has changed after the generation of the first type of code by comparing the state of the main repository workspace with the state of the shadow repository when the first type of code is successfully written, and extracting the code manually modified by the user from the changed code portion to obtain the second type of code corresponding to the user's cancellation instruction.

[0087] Optionally, determining the conflict score between the first type of code and the second type of code includes: converting the first type of code and the second type of code into vector form respectively to obtain a first intent vector corresponding to the first type of code and a second intent vector corresponding to the second type of code; calculating the cosine similarity between the first intent vector and the second intent vector to obtain a first relevance parameter, wherein the first relevance parameter is used to characterize the degree of relevance between the first type of code and the second type of code in terms of functional semantics; determining the first node corresponding to the first type of code and the second node corresponding to the second type of code in the abstract syntax tree, and determining the overlap between the first node and the second node in the abstract syntax tree to obtain a second relevance parameter, wherein the second relevance parameter is used to characterize the degree of relevance between the first type of code and the second type of code in terms of code structure; and determining the conflict score based on the first relevance parameter and the second relevance parameter.

[0088] Optionally, performing patch compositing on the code in the main repository includes: determining a set of change nodes by comparing the code in the current main repository with the code in the shadow repository before writing the first type of code, wherein the set of change nodes contains at least one change node, and each change node corresponds to a part of the code segment that has been changed; determining the local semantic vector of the code segment corresponding to each change node, and determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message; determining the tag information corresponding to each change node in the set of change nodes based on the relevance score, wherein the tag information is used to indicate whether to retain the code segment corresponding to the change node during the patch compositing process; and deleting or retaining the code segment corresponding to the change node in the main repository according to the tag information.

[0089] Optionally, determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message includes: processing the code segment corresponding to the change node using the code feature channel in the multimodal coding model to obtain the local semantic vector. The multimodal coding model is trained on the target training set and then trained through cross-modal alignment of code and text. The target training set includes multiple training samples, each containing a code segment and the corresponding text corpus; processing the target dialogue message using the intent feature channel in the multimodal coding model to obtain the user intent vector, where the user intent vector and the local semantic vector reside in the same high-dimensional semantic space; and calculating the cosine similarity between the local semantic vector and the user intent vector to obtain the relevance score.

[0090] It should be noted that each module in the above-mentioned code processing device can be a program module (for example, a set of program instructions that implement a certain function) or a hardware module. For the latter, it can be manifested in the following forms, but is not limited to them: each of the above modules is manifested as a processor, or the functions of each of the above modules are implemented by a processor.

[0091] It should be noted that the code processing device provided in this embodiment can be used to execute... Figure 2 The code processing method shown above is also applicable to the embodiments of this application, and will not be repeated here.

[0092] This application embodiment also provides a non-volatile storage medium, which includes a stored computer program. The device containing the non-volatile storage medium executes the following code processing method by running the computer program: receiving a user revocation instruction, wherein the user revocation instruction is used to instruct the revocation of AI-generated code corresponding to a target dialogue message, the target dialogue message being any round of dialogue message in the user's historical conversation with the AI ​​engine; determining a first type of code and a second type of code in the main repository corresponding to the user revocation instruction, wherein the first type of code is code generated by the AI ​​engine based on the user's request intent in the target dialogue message, and the second type of code is code manually modified by the user in the main repository after generating the first type of code corresponding to the target dialogue message and before receiving the user revocation instruction; determining a conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure; and performing patch synthesis processing on the code in the main repository when the conflict score is less than a preset score threshold, wherein the patch synthesis processing is used to only revoke the first type of code generated by the AI ​​engine while retaining the second type of code manually modified by the user.

[0093] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the code processing method described in various embodiments of this application: receiving a user revocation instruction, wherein the user revocation instruction is used to instruct the revocation of AI-generated code corresponding to a target dialogue message, the target dialogue message being any round of dialogue message in the user's historical conversation with the AI ​​engine; determining a first type of code and a second type of code in the main repository corresponding to the user revocation instruction, wherein the first type of code is code generated by the AI ​​engine based on the user's request intent in the target dialogue message, and the second type of code is code manually modified by the user in the main repository after generating the first type of code corresponding to the target dialogue message and before receiving the user revocation instruction; determining a conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure; and performing patch synthesis processing on the code in the main repository when the conflict score is less than a preset score threshold, wherein the patch synthesis processing is used to only revoke the first type of code generated by the AI ​​engine while retaining the second type of code manually modified by the user.

[0094] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0095] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0096] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0097] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0098] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0099] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0100] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A code processing method, characterized in that, include: Receive user cancellation instruction, wherein the user cancellation instruction is used to indicate the cancellation of the AI-generated code corresponding to the target dialogue message, and the target dialogue message is any round of dialogue message in the user's historical conversation with the AI ​​engine; Identify a first type of code and a second type of code in the main repository that correspond to the user's cancellation instruction. The first type of code is generated by the artificial intelligence engine based on the user's request intent in the target dialogue message. The second type of code is the code that the user manually modifies in the main repository after generating the first type of code corresponding to the target dialogue message and before receiving the user's cancellation instruction. Determine the conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure; If the conflict score is less than a preset score threshold, a patch synthesis process is performed on the code in the main repository. The patch synthesis process is used to only undo the first type of code generated by the artificial intelligence engine and retain the second type of code manually modified by the user.

2. The code processing method according to claim 1, characterized in that, The method further includes: Obtain the AI-generated code generated by the AI ​​engine in response to the user's dialogue messages; The AI-generated code is written into the index file of the shadow repository, and the correspondence between the AI-generated code and the dialogue message is recorded. The shadow repository reuses the same object database as the main repository, but the shadow repository has pointers and index files that are independent of the main repository. If the AI-generated code is successfully written to the shadow repository, the AI-generated code is applied to the main repository, where the code in the main repository will be displayed on the front-end interactive interface.

3. The code processing method according to claim 2, characterized in that, Before obtaining the AI-generated code generated by the AI ​​engine in response to the user-sent dialogue messages, the method further includes: Upon receiving a dialogue message from a user, the system compares the status of the main repository workspace with the status of the shadow repository to determine whether there is any manually modified code in the main repository workspace that the user has not submitted. If it is determined that there is manually modified code that the user has not submitted, the user's unsubmitted manually modified code is temporarily stored and then submitted to the shadow repository.

4. The code processing method according to claim 2, characterized in that, The first and second types of codes corresponding to the user's revocation command in the main repository include: Determine the target dialogue message corresponding to the user's cancellation instruction; Based on the correspondence between the AI-generated code and the dialogue message, the AI-generated code corresponding to the target dialogue message is extracted from the shadow repository, and the AI-generated code is identified as the first type of code corresponding to the user's cancellation instruction; By comparing the state of the main repository workspace with the state of the shadow repository when the first type of code was successfully written, the code portion of the main repository workspace that has changed after the first type of code was generated is determined, and the code manually modified by the user is extracted from the changed code portion to obtain the second type of code corresponding to the user's undo instruction.

5. The code processing method according to claim 1, characterized in that, Determining the conflict score between the first type of code and the second type of code includes: Convert the first type of code and the second type of code into vector form respectively to obtain the first intent vector corresponding to the first type of code and the second intent vector corresponding to the second type of code; Calculate the cosine similarity between the first intent vector and the second intent vector to obtain a first correlation parameter, wherein the first correlation parameter is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics; The first node corresponding to the first type of code on the abstract syntax tree and the second node corresponding to the second type of code on the abstract syntax tree are determined, and the overlap between the first node and the second node on the abstract syntax tree is determined to obtain a second correlation parameter, wherein the second correlation parameter is used to characterize the degree of correlation between the first type of code and the second type of code in code structure; The conflict score is determined based on the first relevant parameter and the second relevant parameter.

6. The code processing method according to claim 2, characterized in that, Performing patch synthesis processing on the code in the main repository includes: By comparing the code in the current main repository with the code in the shadow repository before the first type of code was written, a set of change nodes is determined, wherein the set of change nodes contains at least one change node, and each change node corresponds to a part of the code segment that has been changed; Determine the local semantic vector of the code segment corresponding to each change node, and determine the correlation score between the local semantic vector and the user intent vector corresponding to the target dialogue message; Based on the relevance score, the tag information corresponding to each change node in the change node set is determined, wherein the tag information is used to indicate whether the code segment corresponding to the change node is retained during the patch synthesis process; Based on the tag information, the code snippets corresponding to the change nodes in the main repository are either deleted or retained.

7. The code processing method according to claim 6, characterized in that, Determining the relevance score between the local semantic vector and the user intent vector corresponding to the target dialogue message includes: The code feature channel in the multimodal coding model is used to process the code segment corresponding to the change node to obtain the local semantic vector. The multimodal coding model is trained on a target training set and then trained by cross-modal alignment of code and text. The target training set includes multiple training samples, and each training sample contains a code segment and the text corpus corresponding to the code segment. The target dialogue message is processed using the intent feature channel in a multimodal coding model to obtain the user intent vector, wherein the user intent vector and the local semantic vector are located in the same high-dimensional semantic space; The cosine similarity between the local semantic vector and the user intent vector is calculated to obtain the relevance score.

8. A code processing device, characterized in that, include: The instruction receiving module is used to receive user cancellation instructions, wherein the user cancellation instructions are used to indicate the cancellation of the AI-generated code corresponding to the target dialogue message, and the target dialogue message is any round of dialogue message in the user's historical conversation with the AI ​​engine; The code determination module is used to determine the first type of code and the second type of code in the main repository that correspond to the user's cancellation instruction. The first type of code is generated by the artificial intelligence engine based on the user's request intent in the target dialogue message. The second type of code is the code that the user manually modified in the main repository after generating the first type of code corresponding to the target dialogue message and before receiving the user's cancellation instruction. A conflict analysis module is used to determine the conflict score between the first type of code and the second type of code, wherein the conflict score is used to characterize the degree of correlation between the first type of code and the second type of code in terms of functional semantics and code structure; The code undo module is used to perform patch synthesis processing on the code in the main repository when the conflict score is less than a preset score threshold. The patch synthesis processing is used to only undo the first type of code generated by the artificial intelligence engine and retain the second type of code manually modified by the user.

9. An electronic device, characterized in that, include: A memory and a processor, the processor being configured to run a program stored in the memory, wherein the program, when running, performs the code processing method according to any one of claims 1 to 7.

10. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the code processing method according to any one of claims 1 to 7 by running the computer program.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the code processing method according to any one of claims 1 to 7.