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

fix: circuitname in property panel #452

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

venkateshkasani
Copy link

@venkateshkasani venkateshkasani commented Feb 4, 2025

Fixes #408
Resolves the issue of circuitname not showing correctly in Properties panel.

Changes:

  1. Binded input element in the message box component to a computed ref that references a variable in a global store, and synced the input element in Properties panel with the same global reference.
  2. Fixed a typo in PropertiesPanel : src/components/Panels/PropertiesPanel.

Reference Screenshot:
image

Summary by CodeRabbit

  • New Features

    • Improved input experience with auto-focus and reactive binding for circuit names.
    • Enhanced prompt interactions by including additional circuit details and context-specific defaults.
  • Bug Fixes

    • Resolved labeling inconsistencies to ensure proper data display in panel components.
  • Refactor

    • Streamlined state initialization and store management for circuits and panel properties for increased consistency and clarity.
    • Updated property bindings for improved accuracy and reliability in component interactions.
    • Simplified component interfaces by removing unnecessary properties.

Copy link
Contributor

coderabbitai bot commented Feb 4, 2025

Walkthrough

The pull request updates several Vue components and store modules to improve circuit name handling and state management. The changes refactor the input logic in components such as MessageBox and ProjectProperty to use computed properties and store-driven approaches. The modifications include correcting property name typos in the Properties Panel components, updating event payloads, and adjusting store initializations and type definitions. Additionally, helper components and the circuit creation logic now retrieve default naming values from the prompt store, while logging and focus management are refined.

Changes

File(s) Change Summary
src/components/MessageBox/messageBox.vue Changed input binding from inputItem.val to computed circuitName; updated ref to circuitNameRef, added focus management, and modified button event payload to include circuitName instead of circuitItem (removed prop circuitItem).
src/components/Panels/PropertiesPanel/ModuleProperty/ModuleProperty.vue
src/components/Panels/PropertiesPanel/PropertiesPanel.vue
Corrected typo in property name from panleBodyData to panelBodyData in both template and script.
src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue Replaced explicit input reference with v-model bound to a new computed property name for two-way binding with SimulatorState.activeCircuit; reorganized imports.
src/components/helpers/promptComponent/PromptComponent.vue Updated @buttonClick to pass an additional circuitItem parameter to the confirmation function, adjusted its signature, and modified the placeholder in provideProjectName to "Untitled-circuit".
src/simulator/src/circuit.ts Integrated usePromptStore in createNewCircuitScope to fetch input text for naming; added a console log in switchCircuit and set activeCircuit.value explicitly in newCircuit.
src/store/SimulatorStore/state.ts
src/store/promptStore.ts
src/store/propertiesPanelStore.ts
Updated store state: changed activeCircuit.name to allow undefined and provided default object values; added new inputText property (defaulting to "Untitled-circuit") in prompt store; modified propertiesPanelObj initialization from ref(undefined) to ref() with explicit type.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MB as MessageBox.vue
    participant PP as ProjectProperty.vue
    participant PC as PromptComponent.vue
    participant Store as SimulatorStore
    participant Circuit as circuit.ts

    User->>MB: Mount component (auto-focus input)
    MB->>Store: Retrieve circuitName (computed)
    User->>PP: Update circuit name via input (v-model binding)
    PP->>Store: Update activeCircuit state
    User->>PC: Click button ("save")
    PC->>Store: Emit event with circuitItem (updated name)
    PC->>Circuit: Invoke createNewCircuitScope (using promptStore input)
    Circuit->>Store: Update activeCircuit and log circuit switch
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure that the properties panel reflects the individual circuit's name and updates correctly per circuit tab (#408)

Possibly related PRs

Suggested labels

GSOC'24

Poem

I'm a bunny on the run,
Hopping through changes, having fun.
New computed paths light up my day,
State and store lead the way.
With a twitch of my whiskers, code is neat—
Circuit names now skip to a magical beat!
🐰🌟

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed9ea1f and 427c156.

📒 Files selected for processing (1)
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Feb 4, 2025

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit 427c156
🔍 Latest deploy log https://app.netlify.com/sites/circuitverse/deploys/67a1f29f4d68620008a1fbd9
😎 Deploy Preview https://deploy-preview-452--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (1)
src/components/Panels/PropertiesPanel/ModuleProperty/ModuleProperty.vue (1)

1-43: Issue found in parent component binding

The search reveals that the parent component(s) (specifically in both v0 and v1 under PropertiesPanel.vue) are still using the incorrect binding :panle-body-data. This needs to be updated to :panel-body-data to match the intended property name in the child (ModuleProperty.vue).

  • v0/src/components/Panels/PropertiesPanel/PropertiesPanel.vue: Update :panle-body-data to :panel-body-data.
  • v1/src/components/Panels/PropertiesPanel/PropertiesPanel.vue: Update :panle-body-data to :panel-body-data.
🔗 Analysis chain

Verify parent component property binding.

The property name is now correctly defined as panelBodyData. Please ensure that all parent components using this component have updated their bindings from :panle-body-data to :panel-body-data.


I'm now generating a new shell script to search for any occurrence of the old property naming pattern in all Vue files by using a glob pattern.


I'm running an additional script to view the context of the matching lines in the affected Vue files so we can inspect whether the old property names are still in use and need to be updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of the old property name
rg -l "panle-body-data|panleBodyData" --type vue

Length of output: 78


Script:

#!/bin/bash
# Search for any remaining instances of the old property name in .vue files using a glob pattern
rg -l -g '*.vue' 'panle-body-data|panleBodyData'

Length of output: 322


Script:

#!/bin/bash
# Display context for each occurrence of the old property names in the Vue files.
for file in $(rg -l -g '*.vue' 'panle-body-data|panleBodyData'); do
  echo "=== $file ==="
  rg -n -C 2 'panle-body-data|panleBodyData' "$file"
  echo ""
done

Length of output: 3465

🧰 Tools
🪛 ESLint

[error] 33-33: 'ref' is defined but never used.

(no-unused-vars)


[error] 34-34: 'onMounted' is defined but never used.

(no-unused-vars)

🧹 Nitpick comments (5)
src/store/propertiesPanelStore.ts (1)

8-8: Consider using a more specific type instead of any.

Using any type bypasses TypeScript's type checking benefits. Consider defining an interface for the expected object structure to maintain type safety.

-const propertiesPanelObj:any = ref()
+interface PropertiesPanelObject {
+  // Define expected properties here
+}
+const propertiesPanelObj = ref<PropertiesPanelObject | null>(null)
src/store/SimulatorStore/state.ts (1)

8-8: Consider making name required since it's initialized with a default value.

The type definition makes name optional (string | undefined) but it's always initialized with an empty string. This creates an inconsistency between the type definition and actual usage.

-name: string | undefined
+name: string
src/components/MessageBox/messageBox.vue (1)

41-41: Consider using a more descriptive object structure for the event payload.

The event payload could be more explicit about its purpose.

-@click="$emit('buttonClick', buttonItem.emitOption, {name:circuitName})"
+@click="$emit('buttonClick', buttonItem.emitOption, {circuitName: circuitName})"
src/components/helpers/promptComponent/PromptComponent.vue (1)

149-158: Add type safety to the confirmation handler.

The circuitItem parameter is typed as any, which loses type safety. Consider creating an interface for the circuit item structure.

+interface CircuitItem {
+  id: string;
+  name: string;
+}

-const confirmation = (selectedOption: string, circuitItem:any): void => {
+const confirmation = (selectedOption: string, circuitItem: CircuitItem): void => {
src/simulator/src/circuit.ts (1)

190-195: Improve error handling in createNewCircuitScope.

The function should handle the case where provideCircuitName() returns undefined.

     const promptStore = usePromptStore()
     name = await provideCircuitName();
-    if (name instanceof Error) return // if user cancels the prompt
-    if (name.trim() == '') {
+    if (name instanceof Error || !name || name.trim() === '') {
         name = promptStore.prompt.inputText;
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0b26c9 and 2e22581.

📒 Files selected for processing (9)
  • src/components/MessageBox/messageBox.vue (1 hunks)
  • src/components/Panels/PropertiesPanel/ModuleProperty/ModuleProperty.vue (2 hunks)
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue (3 hunks)
  • src/components/Panels/PropertiesPanel/PropertiesPanel.vue (1 hunks)
  • src/components/helpers/promptComponent/PromptComponent.vue (5 hunks)
  • src/simulator/src/circuit.ts (4 hunks)
  • src/store/SimulatorStore/state.ts (3 hunks)
  • src/store/promptStore.ts (2 hunks)
  • src/store/propertiesPanelStore.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/Panels/PropertiesPanel/PropertiesPanel.vue
🔇 Additional comments (7)
src/store/SimulatorStore/state.ts (1)

48-48: LGTM! Good initialization with empty strings.

Initializing with empty strings instead of undefined is a good practice for reactive properties in Vue.

src/store/promptStore.ts (1)

9-10: LGTM! Good default value for circuit name.

The addition of inputText with a default value of 'Untitled-circuit' is a good practice for handling new circuits.

Also applies to: 65-65

src/components/MessageBox/messageBox.vue (2)

57-62: LGTM! Good use of computed property for two-way binding.

The computed property with getter/setter provides clean two-way binding with the store.


64-71: LGTM! Good focus management implementation.

Using nextTick ensures the DOM is updated before attempting to focus, and selecting the text provides better UX.

src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue (1)

119-126: LGTM! Good use of computed property.

The computed property implementation for the circuit name provides clean two-way data binding and proper type safety.

src/components/Panels/PropertiesPanel/ModuleProperty/ModuleProperty.vue (2)

13-14: LGTM! Property name corrected consistently.

The typo fix from panleBodyData to panelBodyData is applied consistently across all component bindings. The :key binding ensures proper component updates when the data changes.

Also applies to: 18-19, 21-21


37-37: LGTM! Property definition and destructuring updated correctly.

The property definition and destructuring are properly updated to use panelBodyData. The type definition and reactivity handling with toRefs are maintained correctly.

Also applies to: 42-42

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/helpers/promptComponent/PromptComponent.vue (1)

16-16: Add proper typing for the circuit state.

While the state management setup is correct, using any type reduces type safety. Consider defining an interface for the circuit item structure.

+interface CircuitItem {
+  id: string;
+  name: string;
+  // Add other relevant circuit properties
+}

-const projectStore = useState();
+const projectStore = useState<{
+  circuit_list: CircuitItem[];
+  activeCircuit: CircuitItem | null;
+}>();

Also applies to: 68-68

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e22581 and ed9ea1f.

📒 Files selected for processing (3)
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue (2 hunks)
  • src/components/helpers/promptComponent/PromptComponent.vue (5 hunks)
  • src/simulator/src/circuit.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/simulator/src/circuit.ts
  • src/components/Panels/PropertiesPanel/ModuleProperty/ProjectProperty/ProjectProperty.vue
🔇 Additional comments (2)
src/components/helpers/promptComponent/PromptComponent.vue (2)

9-9: LGTM! Event handler updated correctly.

The buttonClick event handler now properly passes both the selectedOption and circuitItem parameters to the confirmation method.


89-89: LGTM! Consistent placeholder text.

The placeholder text is now consistent with the circuit name input, improving user experience.

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.

🐞 Bug: [Title] Circuit Names Not Preserved Individually Across Tabs, Defaulting to Undefined
1 participant