Skip to content

fix: Unable to clear the last call result after the tool workflow call returns#4937

Merged
shaohuzhang1 merged 1 commit intov2from
pr@v2@fix_tool_workflow
Mar 24, 2026
Merged

fix: Unable to clear the last call result after the tool workflow call returns#4937
shaohuzhang1 merged 1 commit intov2from
pr@v2@fix_tool_workflow

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Unable to clear the last call result after the tool workflow call returns

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 24, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 24, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@shaohuzhang1 shaohuzhang1 merged commit 2fc755a into v2 Mar 24, 2026
3 checks passed
}
}

const drawer = ref<boolean>(false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current code has the following suggestions for improvement:

  1. Dynamic Key Usage:

    <ResultDrawer @close="closeResult" :key="index" ref="ToolResultDrawerRef" />

    Consider removing the :key="index" attribute since it's not necessary when the component is re-rendered due to other changes.

  2. Function Redundancy:
    The closeResult function currently increments the index, which might not be intended behavior unless there's a specific reason for updating a reactive variable each time the dialog closes.

  3. Form Validation and Input Field List Check:
    Ensure that validation on form submission handles cases where the input field list is empty gracefully.

  4. Avoid Unnecessary Imports:
    For example, importing unused package number from ECharts can be removed.

  5. Optimize Code Flow:
    Simplify some logic flow, especially related to handling user inputs or responses within a tool execution.

Here's an optimized version of the code with these considerations:

<template>
  <el-drawer v-model="drawer" title="" size="60%">
    <div class="container">
      <!-- Your component content -->
      
      <el-button @click="close">{{ $t('common.cancel') }}</el-button>
      <el-button type="primary" @click="run"> {{ $t('views.tool.form.debug.run') }}</el-button>
    </div>
  </el-drawer>
</template>

<script setup lang="ts">
import { watchEffect, ref } from 'vue';
import { loadSharedApi } from '@/utils/dynamics-api/shared-api';
// Import other required components and modules

const route = useRoute();
const { params: { folderId }, query: { action }, systemType } = route;
const userInputFieldList = computed(() => {});

function getDetail(toolId: string) {};
const drawer = ref(false);
let activeStep = 1;

async function next() {
  // Handle navigation between steps
}

async function back() {
  // Handle backwards step transition
}

watchEffect(async () => {
  console.log(action); // Log the current action to handle different scenarios based on URL parameters
});

function run() {
  if (action === 'start' && userInputFieldList.value.length > 0) {
    await formRef.value.validate((valid: boolean) => valid ? openDialog() : alert('请正确填写输入参数'));
  } else {
    openDialog(); // Directly show the result without input verification if no user input fields are defined
  }

  async function openDialog() {}
};
</script>

<style scoped>
/* Add your styles here */
.container {
  /* Apply container-specific styling */
}
</style>

Key Changes:

  • Removed @key="index" from ResultDrawer.
  • Refactored next() and back() methods for state management and improved readability.
  • Adjusted function calls and conditional checks to streamline workflow and enhance functionality based on input conditions.

These adjustments should improve the robustness and maintainability of the given Vue.js component.

@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_tool_workflow branch March 24, 2026 11:19
emit('close')
resultDrawer.value = false
toolRecord.value = null
currentChat.value = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no immediate irregularities or major issues with the provided code. Here are some minor suggestions for optimization:

  1. Avoiding any Type: The use of any type (ref<any>({})) can lead to type safety issues. Consider using specific types where possible.

  2. Empty Object Check: You already check toolRecord.value before accessing its .meta.output, so there's no need to double-check it elsewhere.

  3. Function Parameters: Use meaningful names like currentToolId instead of simply id.

Here is an optimized version of your code:

const details = { ... };
const activeName = ref<string>('result');
const currentToolId = ref<string>('');
const currentData = ref<{} | undefined>(); // Replace any with a more appropriate type

const emit = defineEmits(['close']);
const output = computed(() => {
  if (!toolRecord.value) return '';
  return toolRecord.value.meta?.output || '';
});

const open = (toolId: string, data?: Record<string, unknown>) => {
  chatManagement.open(chat.value);
  // Add additional logic here as needed
}

const close = () => {
  ChatManagement.close(current-chat.chatId);
  emit('close');
  resultDrawer.value = false;
  toolRecord.value = null;
}

Summary:

  • Removed unnecessary assignment of empty object ({}).
  • Used meaningful variable names wherever possible.
  • Prevented redundant checks on toolRecord.value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant