Skip to content

feat: initial fsWrite chat message #1026

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged

Conversation

ctlai95
Copy link
Contributor

@ctlai95 ctlai95 commented Apr 21, 2025

Problem

Initial FsWrite tool message implementation

image

Solution

  • Send header params from controller
  • Update mynahUi to handle tool specific messages. Things like fullWidth and padding do not belong in the flare library, so we need custom logic to add them in the UI.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ctlai95 ctlai95 marked this pull request as ready for review April 21, 2025 04:12
@ctlai95 ctlai95 requested a review from a team as a code owner April 21, 2025 04:12
switch (toolUse.name) {
case 'fsRead':
case 'listDirectory':
// no need to write tool result for listDir and fsRead into chat stream
Copy link
Contributor

@laileni-aws laileni-aws Apr 21, 2025

Choose a reason for hiding this comment

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

nit: Can I know the reason, Why ? May be I am missing some context here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we are sending it before running the tool above, but actually it might make more sense to move it here

Copy link
Contributor

Choose a reason for hiding this comment

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

We should send the tool use with the list of paths before we run it, so we tell the user what we're doing before we're actually doing it.

I can see us update a spinner to a checkmark here upon completion.

But we don't have to repeat the tool output (the list of files, the status of the edit) unless there is an error.

const fileName = path.basename(input.path)
// TODO: right now diff changes is coupled with fsWrite class, we should move it to shared utils
const fsWrite = new FsWrite(this.#features)
const diffChanges = await fsWrite.getDiffChanges(input)
Copy link
Contributor

@kmile kmile Apr 21, 2025

Choose a reason for hiding this comment

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

This could be a static, but even better would be in a shared util like you mentioned so the representation is not coupled with the tool itself.

header: {
...header,
// TODO: this is specific to fsWrite tool, modify for other tools as needed
fileList: { ...header?.fileList, fileTreeTitle: '', hideFileCount: true },
Copy link
Contributor

Choose a reason for hiding this comment

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

is only this line going to be modified for other tools or all of it? If so, just wondering if it makes sense to pull this out to a different file so that its easy to understand which tools have which interface

Copy link
Contributor

@Hweinstock Hweinstock Apr 21, 2025

Choose a reason for hiding this comment

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

+1 to separating this logic out.

header: {
...header,
// TODO: this is specific to fsWrite tool, modify for other tools as needed
fileList: { ...header?.fileList, fileTreeTitle: '', hideFileCount: true },
Copy link
Contributor

@Hweinstock Hweinstock Apr 21, 2025

Choose a reason for hiding this comment

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

+1 to separating this logic out.

// no need to write tool result for listDir and fsRead into chat stream
if (toolUse.name !== 'fsRead' && toolUse.name !== 'listDirectory') {
await chatResultStream.writeResultBlock({ body: toolResultMessage(toolUse, result) })
switch (toolUse.name) {
Copy link
Contributor

@Hweinstock Hweinstock Apr 21, 2025

Choose a reason for hiding this comment

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

For the sake of future MCP support, I think this tool specific branching should be isolated from the core logic. This also won't scale well as we add more tools.

Copy link
Contributor

@kmile kmile left a comment

Choose a reason for hiding this comment

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

I agree with the suggestions to separating out the tool specific logic from the main controller, but that can be done as a follow-up once we have all the tools in there.

@kmile kmile merged commit 3fc6e85 into aws:main Apr 21, 2025
7 checks passed
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.

5 participants