mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Refresh open sidebar file previews when files change (#62583)
## Why Sidebar previews load a snapshot of the file when opened, so edits on disk leave the open tab showing stale content. ## What changed Watch each previewed file’s parent directory through the app server so the preview refreshes even when an editor saves by atomically replacing the file. Poll every three seconds when a watch cannot be registered, and resubscribe when reconnecting to the same backend. Preserve the text preview’s reading position across reloads, including when the file temporarily becomes unreadable and then returns. ## Testing The sidebar test covers atomic saves and recovery after moving a directory away and back. It checks that the tab shows updated content at the existing reading position. GitOrigin-RevId: d5f7507d1a81a118fb10a0febf5e274c18f19d81
This commit is contained in:
@@ -7,7 +7,21 @@ use ratatui::widgets::Widget;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// A document can be replaced on disk; retain the offset, not the old rendered cells.
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) enum DocumentPosition {
|
||||
Offset(usize),
|
||||
Latest,
|
||||
}
|
||||
|
||||
impl TranscriptView {
|
||||
pub(crate) fn document_position(&self) -> DocumentPosition {
|
||||
match self.position {
|
||||
Position::Reading(anchor) => DocumentPosition::Offset(anchor.offset),
|
||||
Position::Latest => DocumentPosition::Latest,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn render_document(
|
||||
&mut self,
|
||||
area: Rect,
|
||||
|
||||
Reference in New Issue
Block a user