team-ljyzipelo

공개

파일 선택 대기 중 별도 진행 창에서 작업이 시작되지 않게 함

선택 창 안내 모달은 메인 창만 막아, Linux에서 열기 선택 창이 응답을
기다리는 동안 별도 결과 창의 [다시 시도]로 이전 추출이 다시 시작됐음
(PR #95 리뷰 P2). 진행 창의 버튼을 선택 대기 중 비활성화하고, 모든 작업이
지나는 start()에서도 대기 상태면 시작하지 않음.

별도 viewport 콜백을 실제로 실행하는 회귀 시험을 추가함. 대기 중 클릭은
Start 수를 늘리지 않고, 선택 창을 닫은 뒤 같은 클릭은 재시도를 시작함.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
작성자
LeeJunyoung
작성 시각
커밋
f501a5db07bfce31ac4174e05fee91877ee4b2ab
부모
f3f54eb
이 시점의 파일 보기

변경된 파일 3개

+169-0
수정experiments/rust-ui-memory-app/src/archive_screen.rs+10-0
@@ -191,6 +191,10 @@ impl ArchiveApp {
191191 }
192192
193193 fn start(&mut self, request: Start) -> bool {
194추가: // 파일 선택 창이 응답을 기다리는 동안에는 어느 창에서도 새 작업을 시작하지 않음.
195추가: if self.picker.is_some() {
196추가: return false;
197추가: }
194198 self.last_request = Some(request.clone());
195199 self.dismissed = false;
196200 self.details = false;
@@ -1363,6 +1367,12 @@ impl ArchiveApp {
13631367 }
13641368
13651369 fn work_area(&mut self, ui: &mut egui::Ui) {
1370추가: // 선택 창 안내 모달은 메인 창만 막으므로, 별도 진행 창의 버튼은 여기서 막음.
1371추가: let enabled = self.picker.is_none();
1372추가: ui.add_enabled_ui(enabled, |ui| self.work_contents(ui));
1373추가: }
1374추가:
1375추가: fn work_contents(&mut self, ui: &mut egui::Ui) {
13661376 if self.model.busy() {
13671377 self.progress(ui);
13681378 } else if self.result_visible() {
수정tests/rust-app-ui/presentation.rs+1-0
@@ -910,6 +910,7 @@ mod widgets {
910910 include!("long_layout.rs");
911911 include!("explorer_selection.rs");
912912 include!("window_frame.rs");
913추가: include!("work_window.rs");
913914}
914915
915916#[cfg(feature = "ui")]
추가tests/rust-app-ui/work_window.rs+158-0
@@ -0,0 +1,158 @@
1추가: // 별도 진행 창(실제 즉시 viewport 콜백)에서 파일 선택 대기 중에 작업이 시작되지 않는지 확인함.
2추가:
3추가: #[derive(Default)]
4추가: struct WorkChild {
5추가: events: Vec<egui::Event>,
6추가: labels: Vec<(String, egui::Pos2)>,
7추가: rendered: usize,
8추가: }
9추가:
10추가: std::thread_local! {
11추가: static WORK_CHILD: std::cell::RefCell<WorkChild> = Default::default();
12추가: }
13추가:
14추가: /// eframe처럼 별도 viewport 콜백을 같은 Context에서 실행하고, 그 viewport에만 입력을 넣음.
15추가: fn install_work_child_renderer() {
16추가: egui::Context::set_immediate_viewport_renderer(|ctx, mut viewport| {
17추가: let events = WORK_CHILD.with(|child| std::mem::take(&mut child.borrow_mut().events));
18추가: let mut raw = egui::RawInput {
19추가: viewport_id: viewport.ids.this,
20추가: screen_rect: Some(egui::Rect::from_min_size(
21추가: egui::Pos2::ZERO,
22추가: egui::vec2(480.0, 240.0),
23추가: )),
24추가: events,
25추가: ..Default::default()
26추가: };
27추가: raw.viewports.insert(
28추가: viewport.ids.this,
29추가: egui::ViewportInfo {
30추가: parent: Some(viewport.ids.parent),
31추가: focused: Some(true),
32추가: ..Default::default()
33추가: },
34추가: );
35추가: let mut output = ctx.run_ui(
36추가: raw,
37추가: |ui| (viewport.viewport_ui_cb)(ui),
38추가: );
39추가: output.textures_delta.clear();
40추가: WORK_CHILD.with(|child| {
41추가: let mut child = child.borrow_mut();
42추가: child.labels = labels(&output.shapes);
43추가: child.rendered += 1;
44추가: });
45추가: });
46추가: }
47추가:
48추가: fn work_child_label(label: &str) -> Option<egui::Pos2> {
49추가: WORK_CHILD.with(|child| {
50추가: child
51추가: .borrow()
52추가: .labels
53추가: .iter()
54추가: .rev()
55추가: .find(|(text, _)| text == label)
56추가: .map(|(_, pos)| *pos)
57추가: })
58추가: }
59추가:
60추가: fn work_child_click(ctx: &egui::Context, app: &mut ArchiveApp, point: egui::Pos2) {
61추가: for pressed in [true, false] {
62추가: WORK_CHILD.with(|child| {
63추가: child.borrow_mut().events = vec![
64추가: egui::Event::PointerMoved(point),
65추가: egui::Event::PointerButton {
66추가: pos: point,
67추가: button: egui::PointerButton::Primary,
68추가: pressed,
69추가: modifiers: egui::Modifiers::NONE,
70추가: },
71추가: ];
72추가: });
73추가: policy_render(ctx, app, vec![]);
74추가: }
75추가: }
76추가:
77추가: /// 열기 선택 창의 응답을 시험이 보낼 때까지 보류함.
78추가: #[derive(Clone, Default)]
79추가: struct HeldDialogs(
80추가: std::rc::Rc<
81추가: std::cell::RefCell<
82추가: Vec<std::sync::mpsc::Sender<zipelo_ui_memory_app::archive_dialog::DialogAnswer>>,
83추가: >,
84추가: >,
85추가: );
86추가:
87추가: impl zipelo_ui_memory_app::archive_dialog::Dialogs for HeldDialogs {
88추가: fn choose(
89추가: &mut self,
90추가: _: zipelo_ui_memory_app::archive_dialog::DialogRequest,
91추가: ) -> zipelo_ui_memory_app::archive_dialog::DialogAnswer {
92추가: Ok(None)
93추가: }
94추가:
95추가: fn start(
96추가: &mut self,
97추가: _: zipelo_ui_memory_app::archive_dialog::DialogRequest,
98추가: ) -> zipelo_ui_memory_app::archive_dialog::PendingDialog {
99추가: let (sender, receiver) = std::sync::mpsc::channel();
100추가: self.0.borrow_mut().push(sender);
101추가: zipelo_ui_memory_app::archive_dialog::PendingDialog::Waiting(receiver)
102추가: }
103추가: }
104추가:
105추가: #[test]
106추가: fn picker_wait_blocks_retry_in_separate_work_window() {
107추가: let scratch = Folder::new();
108추가: let factory = FakeFactory::default();
109추가: let mut app = loaded(&scratch, &factory);
110추가: factory.state.borrow_mut().manual = true;
111추가: assert!(app.begin_extract());
112추가: {
113추가: let mut worker = factory.state.borrow_mut();
114추가: worker.frame(Event::Accepted { encryption: false });
115추가: worker.finish(Outcome::Failed, Publication::None);
116추가: for event in &mut worker.queue {
117추가: if let HostEvent::Frame {
118추가: event: Event::Terminal(t),
119추가: ..
120추가: } = event
121추가: {
122추가: t.error = Some(ErrorCode::Io);
123추가: }
124추가: }
125추가: }
126추가: let ctx = egui::Context::default();
127추가: ctx.set_embed_viewports(false);
128추가: install_work_child_renderer();
129추가: for _ in 0..10 {
130추가: policy_render(&ctx, &mut app, vec![]);
131추가: }
132추가: assert!(
133추가: WORK_CHILD.with(|child| child.borrow().rendered) > 0,
134추가: "결과가 별도 viewport에 그려져야 함"
135추가: );
136추가: let retry = work_child_label("다시 시도").expect("별도 결과 창에 다시 시도 버튼이 있어야 함");
137추가:
138추가: let dialogs = HeldDialogs::default();
139추가: app.set_dialogs(Box::new(dialogs.clone()));
140추가: policy_click(&ctx, &mut app, "열기");
141추가: assert_eq!(dialogs.0.borrow().len(), 1, "열기 선택 창이 응답을 기다려야 함");
142추가: let before = factory.state.borrow().starts.len();
143추가: work_child_click(&ctx, &mut app, retry);
144추가: assert_eq!(
145추가: factory.state.borrow().starts.len(),
146추가: before,
147추가: "파일 선택 창이 열린 동안 별도 결과 창에서 작업이 시작됨"
148추가: );
149추가:
150추가: // 대조: 선택 창을 닫으면 같은 클릭으로 다시 시도가 시작됨.
151추가: dialogs.0.borrow()[0].send(Ok(None)).unwrap();
152추가: for _ in 0..3 {
153추가: policy_render(&ctx, &mut app, vec![]);
154추가: }
155추가: let retry = work_child_label("다시 시도").expect("선택 창을 닫은 뒤에도 결과가 남아야 함");
156추가: work_child_click(&ctx, &mut app, retry);
157추가: assert_eq!(factory.state.borrow().starts.len(), before + 1);
158추가: }