Skip to content

Add reload action for open files - #2948

Open
Devanshu-174 wants to merge 1 commit into
Acode-Foundation:mainfrom
Devanshu-174:feat/reload-file-button
Open

Devanshu-174 wants to merge 1 commit into
Acode-Foundation:mainfrom
Devanshu-174:feat/reload-file-button

Conversation

@Devanshu-174

Copy link
Copy Markdown

What changed

Added a Reload option for files that exist on disk.

Behavior

  • Reloads the current file from disk
  • Updates the editor with the latest file content
  • Warns before discarding unsaved changes

Testing

  • Opened a file in Acode
  • Verified the Reload option appears
  • Modified the file and reloaded it successfully
  • Verified unsaved changes show a warning before reload

Fixes #2390

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 2/5

[Medium risk] Adds file reload action to the editor.

This PR is not safe to merge until reload protects edits made during the read and handles the non-editor tabs where the action appears.

Findings

  1. P1 Security New edits can be lost ▶
  2. P1 Media tabs cannot reload ▶
  3. P2 Reload loses cursor position ▶

Summary

Adds a Reload item to the file menu and a command that rereads the active file, prompting before discarding existing unsaved changes.

  • Edits made while the read is pending can still be lost without warning.
  • The action is also offered on media tabs, which it does not refresh.
  • Manual reload does not preserve the cursor position.

Reviews (1) · Last reviewed commit: "feat: add reload file action"

Comment thread src/lib/editorFile.js
Comment on lines +1655 to +1659
const value = await fs.readFile(this.encoding);

this.session.setValue(value);

this.markLoaded({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 security New edits can be lost

If the user types while the file read is pending, the unsaved-change check has already passed. Reload then replaces those edits and marks the file clean without warning. Recheck the document before replacing it. How this was verified: Editor changes mark the file unsaved during the awaited read, but the subsequent replacement and markLoaded clear that state without another check.

Comment thread src/views/file-menu.hbs
Comment on lines 55 to +56
{{#file_on_disk}}
<li action="reload">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Media tabs cannot reload

This condition also shows Reload on image, audio, and video tabs because they have file URIs. Those tabs have no editor session to refresh, and the reload method does not rebuild their displayed media. Selecting Reload therefore does not update the file the user sees. Restrict the action to editor files or add a media reload path.

Comment thread src/lib/editorFile.js

const value = await fs.readFile(this.encoding);

this.session.setValue(value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Reload loses cursor position

Replacing the document here does not retain the cursor position, so someone reloading while working at a particular line can lose their place. The existing disk-change reload saves and restores the cursor; manual reload should do the same.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Add Reload File button, just call it Reload

1 participant