Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: refine user input style #2680

Merged
merged 1 commit into from
Mar 25, 2025
Merged

perf: refine user input style #2680

merged 1 commit into from
Mar 25, 2025

Conversation

wangdan-fit2cloud
Copy link
Contributor

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

Copy link

f2c-ci-robot bot commented Mar 25, 2025

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.

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/test-infra repository.

Copy link

f2c-ci-robot bot commented Mar 25, 2025

[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.

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

@wangdan-fit2cloud wangdan-fit2cloud merged commit ba4e55d into main Mar 25, 2025
4 checks passed
@wangdan-fit2cloud wangdan-fit2cloud deleted the pr@main/user-input branch March 25, 2025 10:33
</div>
</template>
<el-switch size="small" v-model="chat_data.model_setting.reasoning_content_enable" />
</el-form-item>
</el-form>
</el-card>

Copy link
Contributor

Choose a reason for hiding this comment

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

This code contains some formatting discrepancies and redundancy. Here are my recommendations:

  1. In line 116, replace @click="openMcpServersDialog" with <button> tag.
  2. Remove the duplicate el-form-item at line 171 because it has already been rendered above.

Here's what the updated code should look like:

@@ -116,28 +116,43 @@
           />
         </el-form-item>

+        <div class="flex-between mb-16">
+          <div class="lighter">{{ $t('views.applicationWorkflow.nodes.mcpNode.tool') }}</div>
+          <button type="primary" link @click="openMcpServersDialog">Settings</button>
+        </div>
       
       <el-form @click.prevent>
         <template #label>
           <div class="flex-between">
             <div>{{ $t('views.applicationApplicationForm.form.reasoningContent.label') }}</div>
-            <el-button
-              type="primary"
-              link
-              @click="openReasoningParamSettingDialog"
-              @refreshForm="refreshParam"
-            >
-              Settings
-            </el-button>
+            <button type="primary" link @click="openReasoningParamSettingDialog">Settings</button>
           </div>
         </template>
         <el-switch size="small" v-model="chat_data.model_setting.reasoning_content_enable" />
       </el-form>   
     </el-card>

max-width: 100%;
}
}
</style>
Copy link
Contributor

Choose a reason for hiding this comment

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

There are no significant issues with the provided code snippet. It appears to be maintaining proper logic for displaying input fields based on various conditions and handling form submissions.

Optimization suggestions include:

  1. Reducing unnecessary CSS complexity by combining similar declarations in media queries.
  2. Ensuring that all classes have clear naming conventions and describe their functionality effectively.

These changes can help improve maintainability and readability of the codebase.

max-width: 100%;
}
}
}
</style>
Copy link
Contributor

Choose a reason for hiding this comment

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

The provided TypeScript Vue component for an AI chat with additional styles is generally clean and functional, but there are a couple of minor suggestions and corrections:

Suggested Corrections/Improvements

  1. Remove Redundant :show Binding:
    The v-show="showUserInputContent" directive in the <div>vShow> element can sometimes be redundant when used on child elements that rely on their parent's existence.

  2. Add Missing Close Brace to CSS Block:
    Ensure that each closing brace (}) in your SCSS or LESS is properly paired. In this case, the .debug-ai-chat, @media only screen and (max-width: 768px) block should have its corresponding closing bracket.

  3. Correct Variable Usage:
    The variable heightStyleProp is not being utilized anywhere in your template logic, which might indicate it should either be removed or updated based on its intended use.

  4. Optimization Suggestions

    • Avoid Repeated Class Names: Since both .ai-chat and .debug-ai-chat share similar style rules, consider combining them into one class if they don't differ significantly.

    • Use Conditional Classes Wisely: Instead of applying different classes like firstUserInput or popperUserInput conditionally, you could refactor the logic for these styles directly in the inline styles or computed properties to improve readability.

  5. Enhance Responsiveness:
    If you want to ensure the user input container has a maximum width even at very small screens without affecting the entire dialog box, reconsider using media queries more strategically and possibly adding conditional wrapping around larger layout components.

Below is the revised version of your code incorporating some of these considerations:

<template>
  <div ref="aiChatRef" class="ai-chat" :class="type" :style="[...baseStyles, customStyles]">
    <!-- Your existing content here -->
  </div>
</template>

<script setup lang="ts">
import { ref, defineExpose} from 'vue';

const aiChatRef = ref(null);
const firsUserInput = reactive(false);

// Define your props and other necessary variables

defineExpose({
  // Export your expose methods here
});
</script>

<style scoped>
.ai-chat {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center; /* Removed unnecessary padding */
}

.user-form-container {
  /* Add default styling as needed */
  max-width: 70%; /* Adjusted based on your needs */
}

.debug-ai-chat {
  .user-form-container {
    max-width: 100%; /* Ensures wider than default on smaller screens */
  }
}

.popperUserInput {
  position: absolute;
  background-color: #fff;
  border-radius: 8px;
  font-size: 16px;
  padding: 1rem;
  z-index: 1000;
  width: calc(100% - 50px);
  max-width: 400px;
}

@media only screen and (max-width: 768px) {
  .firstUserInput {
    .user-form-container {
      max-width: 100%; /* Always ensures wide form container on mobile */
    }
  }
}
</style>

By making these adjustments and optimizations, your AI chat component will be more efficient, maintainable, and responsive across devices.

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.

2 participants