getappmap / appmap-js

Client libraries for AppMap
49 stars 17 forks source link

Pinned files should be refreshed when they change #2049

Closed kgilpin closed 1 month ago

kgilpin commented 1 month ago

When I Pin a file and then change that file, my changes are not picked up by Navie. The file is Pinned with the original file content, and doesn't seem to be refreshed when I edit the file.

github-actions[bot] commented 1 month ago

Title: Implement Auto-Refresh for Pinned Files on Changes

Problem: When a user pins a file and makes subsequent changes to that file, the changes are not reflected in Navie. The pinned file retains its original content and does not update to show the latest edits, causing discrepancies between the actual file state and its representation in the pinned section.

Analysis: The current implementation pins the file with its existing content at the time of pinning and does not have a mechanism to update the pinned content when the file undergoes changes. To address this, we need to ensure that any modifications in the file are detected and the pinned content is refreshed accordingly. This may involve implementing a file watcher or similar mechanism to listen for changes in the filesystem and update the pinned content dynamically.

If we look at the existing code, the PinFileRequest captures the file's content when pinned, but there's no logic to auto-update this content. The file pinning system should, therefore, include a feature to observe file changes and refresh the content in Navie.

Proposed Changes:

  1. packages/components/src/lib/PinFileRequest.ts:

    • Modify the PinFileRequest class to accommodate a mechanism (e.g., an event handler or callback) that can be triggered when the file content changes. Ensure that this mechanism can access the updated file content and is capable of refreshing the displayed pinned content.
  2. packages/components/src/components/chat/File.vue:

    • Implement a method to observe changes in the file's content. This could be an integration with a backend service that monitors file changes or a local file watcher using Node.js's filesystem capabilities. This method should trigger an update to the VContextContainer when the file is changed.
  3. packages/components/src/components/chat/ContextContainer.vue:

    • Adjust the component to handle updates from v-file and refresh the content displayed in the UI. This could be done through reactive properties that update when file changes are detected.
  4. File Monitoring:

    • Consider introducing a utility to handle file monitoring using Node.js's fs.watch or another appropriate mechanism. This utility can be initialized when a file is pinned and disposed of when the file is unpinned.
  5. Integration and Testing:

    • Ensure the watcher correctly initializes when a file is pinned and terminates when it's unpinned. Test the complete lifecycle, ensuring the UI updates seamlessly with file changes to reflect the latest content in pinned items.

By implementing these changes, the system should dynamically refresh pinned files in Navie, aligning their representation with real-time file edits.

apotterri commented 1 month ago

An alternative implementation, which seems simpler and more reliable, would be to incorporate the locations of pinned files into the requests sent to Navie.

appland-release commented 1 month ago

:tada: This issue has been resolved in version @appland/navie-v1.33.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

appland-release commented 1 month ago

:tada: This issue has been resolved in version @appland/components-v4.39.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

appland-release commented 1 month ago

:tada: This issue has been resolved in version @appland/appmap-v3.171.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: