-
Notifications
You must be signed in to change notification settings - Fork 74
Resolve the listeners not showing issue #1554
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -214,6 +214,7 @@ export function ServiceConfigureView(props: ServiceConfigureProps) { | |||||||||||||||||||||||||||||||||||||||
| const [currentIdentifier, setCurrentIdentifier] = useState<string | null>(null); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const [isSaving, setIsSaving] = useState<boolean>(false); | ||||||||||||||||||||||||||||||||||||||||
| const [position, setPosition] = useState<NodePosition>(props.position); | ||||||||||||||||||||||||||||||||||||||||
| const [existingListenerType, setExistingListenerType] = useState<string>(""); // Example: "Listener", "CdcListener" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| const [selectedListener, setSelectedListener] = useState<string | null>(null); | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -296,8 +297,8 @@ export function ServiceConfigureView(props: ServiceConfigureProps) { | |||||||||||||||||||||||||||||||||||||||
| }, []); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||
| fetchService(props.position); | ||||||||||||||||||||||||||||||||||||||||
| }, [props.position]); | ||||||||||||||||||||||||||||||||||||||||
| fetchService(position); | ||||||||||||||||||||||||||||||||||||||||
| }, [position]); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
299
to
+301
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After each There are two clean options: Option A — drop the direct 🐛 Option A: let the effect drive fetching // handleOnDetachListener
setPosition(updatedArtifact.position);
setCurrentIdentifier(updatedArtifact.name);
- await fetchService(updatedArtifact.position);
setChangeMap({});
setDirtyFormMap({});
// handleSave – listener loop
setPosition(updatedServiceArtifact.position);
+ // useEffect will re-fetch once position changes
// handleSave – service loop
setCurrentIdentifier(updatedArtifact.name);
setPosition(updatedArtifact.position);
- await fetchService(updatedArtifact.position);Option B — keep direct 🐛 Option B: effect only for initial mount useEffect(() => {
fetchService(position);
-}, [position]);
+}, []); // run once on mount; mutations call fetchService directlyAlso applies to: 664-666, 713-713, 737-738 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||
| if (props.listenerName) { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -475,6 +476,10 @@ export function ServiceConfigureView(props: ServiceConfigureProps) { | |||||||||||||||||||||||||||||||||||||||
| // Set the service model | ||||||||||||||||||||||||||||||||||||||||
| setServiceModel(res.service); | ||||||||||||||||||||||||||||||||||||||||
| setConfigTitle(`${getDisplayServiceName(res.service)} Configuration`); | ||||||||||||||||||||||||||||||||||||||||
| // Set the current identifier from the service name | ||||||||||||||||||||||||||||||||||||||||
| if (res.service.name && !currentIdentifier) { | ||||||||||||||||||||||||||||||||||||||||
| setCurrentIdentifier(res.service.name); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| // Set the service listeners | ||||||||||||||||||||||||||||||||||||||||
| setServiceListeners(res.service); | ||||||||||||||||||||||||||||||||||||||||
| // Find the listener type | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -656,6 +661,7 @@ export function ServiceConfigureView(props: ServiceConfigureProps) { | |||||||||||||||||||||||||||||||||||||||
| console.error("No artifact returned after detaching listener"); | ||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| setPosition(updatedArtifact.position); | ||||||||||||||||||||||||||||||||||||||||
| setCurrentIdentifier(updatedArtifact.name); | ||||||||||||||||||||||||||||||||||||||||
| await fetchService(updatedArtifact.position); | ||||||||||||||||||||||||||||||||||||||||
| setChangeMap({}); | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -698,16 +704,37 @@ export function ServiceConfigureView(props: ServiceConfigureProps) { | |||||||||||||||||||||||||||||||||||||||
| const serviceChanges = changes.filter((c) => c.isService); | ||||||||||||||||||||||||||||||||||||||||
| // Listeners first, then service last | ||||||||||||||||||||||||||||||||||||||||
| for (const change of listenerChanges) { | ||||||||||||||||||||||||||||||||||||||||
| await rpcClient.getServiceDesignerRpcClient().updateListenerSourceCode({ filePath: change.filePath, listener: change.data as ListenerModel }); | ||||||||||||||||||||||||||||||||||||||||
| const listnerResponse = await rpcClient.getServiceDesignerRpcClient().updateListenerSourceCode({ filePath: change.filePath, listener: change.data as ListenerModel }); | ||||||||||||||||||||||||||||||||||||||||
| const updatedServiceArtifact = listnerResponse.artifacts.filter(artifact => artifact.name ===currentIdentifier).at(0); | ||||||||||||||||||||||||||||||||||||||||
| if (!updatedServiceArtifact) { | ||||||||||||||||||||||||||||||||||||||||
| console.error("No service artifact returned after updating listener"); | ||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| setPosition(updatedServiceArtifact.position); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
706
to
714
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in variable name: Minor naming inconsistency. Suggested fix- const listnerResponse = await rpcClient.getServiceDesignerRpcClient().updateListenerSourceCode({ filePath: change.filePath, listener: change.data as ListenerModel });
- const updatedServiceArtifact = listnerResponse.artifacts.filter(artifact => artifact.name ===currentIdentifier).at(0);
+ const listenerResponse = await rpcClient.getServiceDesignerRpcClient().updateListenerSourceCode({ filePath: change.filePath, listener: change.data as ListenerModel });
+ const updatedServiceArtifact = listenerResponse.artifacts.filter(artifact => artifact.name === currentIdentifier).at(0);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Update service changes | ||||||||||||||||||||||||||||||||||||||||
| for (const change of serviceChanges) { | ||||||||||||||||||||||||||||||||||||||||
| const res = await rpcClient.getServiceDesignerRpcClient().updateServiceSourceCode({ filePath: change.filePath, service: change.data as ServiceModel }); | ||||||||||||||||||||||||||||||||||||||||
| // TODO: The backend needs to be refactored to support this types model | ||||||||||||||||||||||||||||||||||||||||
| const service = change.data as ServiceModel; | ||||||||||||||||||||||||||||||||||||||||
| const updatedService = { | ||||||||||||||||||||||||||||||||||||||||
| ...serviceModel, | ||||||||||||||||||||||||||||||||||||||||
| properties: { | ||||||||||||||||||||||||||||||||||||||||
| ...serviceModel.properties, | ||||||||||||||||||||||||||||||||||||||||
| listener: { | ||||||||||||||||||||||||||||||||||||||||
| ...serviceModel.properties.listener, | ||||||||||||||||||||||||||||||||||||||||
| value: service.properties.listener?.values[0] || service.properties.listener?.value || "", | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
| const res = await rpcClient.getServiceDesignerRpcClient().updateServiceSourceCode({ filePath: change.filePath, service: updatedService }); | ||||||||||||||||||||||||||||||||||||||||
| const updatedArtifact = res.artifacts.at(0); | ||||||||||||||||||||||||||||||||||||||||
| if (!updatedArtifact) { | ||||||||||||||||||||||||||||||||||||||||
| console.error("No artifact returned after saving service changes"); | ||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| setCurrentIdentifier(updatedArtifact.name); | ||||||||||||||||||||||||||||||||||||||||
| setPosition(updatedArtifact.position); | ||||||||||||||||||||||||||||||||||||||||
| await fetchService(updatedArtifact.position); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| setChangeMap({}); | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1013,14 +1040,6 @@ function ServiceConfigureListenerEditView(props: ServiceConfigureListenerEditVie | |||||||||||||||||||||||||||||||||||||||
| onDirtyChange?.(isDirty, filePath, position); | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Check if this is a legacy listener (legacy FTP listeners carry path/folderPath in listener properties) | ||||||||||||||||||||||||||||||||||||||||
| const isLegacyListener = | ||||||||||||||||||||||||||||||||||||||||
| listenerModel?.properties?.folderPath !== undefined || | ||||||||||||||||||||||||||||||||||||||||
| listenerModel?.properties?.path !== undefined; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // For attached listeners in new system (no folderPath in listener), show only monitoring path | ||||||||||||||||||||||||||||||||||||||||
| const showMinimalConfig = isAttachedListener && !isLegacyListener; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||
| <ServiceConfigureListenerEditViewContainer> | ||||||||||||||||||||||||||||||||||||||||
| {!listenerModel && | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1029,7 +1048,7 @@ function ServiceConfigureListenerEditView(props: ServiceConfigureListenerEditVie | |||||||||||||||||||||||||||||||||||||||
| <Typography variant="h3" sx={{ marginTop: '16px' }}>Loading...</Typography> | ||||||||||||||||||||||||||||||||||||||||
| </LoadingContainer> | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| {listenerModel && !showMinimalConfig && | ||||||||||||||||||||||||||||||||||||||||
| {listenerModel && | ||||||||||||||||||||||||||||||||||||||||
| <ListenerConfigForm | ||||||||||||||||||||||||||||||||||||||||
| listenerModel={listenerModel} | ||||||||||||||||||||||||||||||||||||||||
| filePath={filePath} | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1041,14 +1060,6 @@ function ServiceConfigureListenerEditView(props: ServiceConfigureListenerEditVie | |||||||||||||||||||||||||||||||||||||||
| onValidityChange={onValidityChange} | ||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| {listenerModel && showMinimalConfig && | ||||||||||||||||||||||||||||||||||||||||
| <AttachedListenerMinimalConfig | ||||||||||||||||||||||||||||||||||||||||
| listenerName={listenerName} | ||||||||||||||||||||||||||||||||||||||||
| onSave={onSubmit} | ||||||||||||||||||||||||||||||||||||||||
| isSaving={saving} | ||||||||||||||||||||||||||||||||||||||||
| savingText={savingText} | ||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| </ServiceConfigureListenerEditViewContainer> | ||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 93
🏁 Script executed:
# Check the component file structure to understand line numbers better wc -l workspaces/ballerina/ballerina-visualizer/src/views/BI/ServiceDesigner/ServiceConfigureView.tsxRepository: wso2/vscode-extensions
Length of output: 166
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 1678
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 93
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 93
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 48
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 4313
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 2103
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 221
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 649
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 1304
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 2352
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 97
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 5107
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 215
🏁 Script executed:
Repository: wso2/vscode-extensions
Length of output: 1278
Sync local position state with
props.positionchanges.The local
positionstate is initialized fromprops.positionbut never updated when the prop changes. SinceServiceEditViewreceives the originalprops.position(line 891) and depends on it in its effect hook to fetch service data, any internal position updates fromsetPositionwon't propagate toServiceEditView, causing it to work with stale position data.Add a sync effect:
Suggested sync effect
📝 Committable suggestion
🤖 Prompt for AI Agents