team-ljyzipelo

공개

지운 암호의 실행 취소 기록을 지우고, 답하지 않은 종료 확인은 작업이 끝나도 닫지 않음

- 암호를 지울 때(보호 해제, ZIP 창 닫기, 새 폴더 선택, 암호 창 종료) egui가 보관하는
  해당 입력창 상태도 지워 Ctrl+Z로 지운 암호가 되살아나지 않게 함. 보호를 해제하는
  순간에는 입력했다가 모두 지운 경우도 함께 처리함.
- 종료 확인 창에 답하기 전에 작업이 끝나면 바로 닫지 않고 Confirm으로 계속 물음.
  이때는 "작업이 끝났습니다. 창을 닫을까요?"와 [열어 두기], [닫기]로 보여 줌.

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

변경된 파일 3개

+151-9
수정experiments/rust-ui-memory-app/src/archive_screen.rs+60-9
@@ -212,6 +212,8 @@ pub struct ArchiveApp {
212212 zip_password: String,
213213 zip_password_confirm: String,
214214 zip_password_visible: bool,
215추가: /// 암호를 지웠으면 입력창의 실행 취소 기록도 다음 그리기 전에 지움.
216추가: forget_password_history: Vec<&'static str>,
215217 /// 작업을 시작한 뒤 작업자가 암호를 요청하면 넘길 암호. 넘기거나 작업이 끝나면 지움.
216218 pending_zip_password: Option<String>,
217219 custom_frame: bool,
@@ -264,6 +266,7 @@ impl ArchiveApp {
264266 zip_password: String::new(),
265267 zip_password_confirm: String::new(),
266268 zip_password_visible: false,
269추가: forget_password_history: Vec::new(),
267270 pending_zip_password: None,
268271 custom_frame: false,
269272 release_after_move: false,
@@ -318,6 +321,25 @@ impl ArchiveApp {
318321 bytes.fill(0);
319322 }
320323 self.password_visible = false;
324추가: // 이 함수는 암호 요청이 없는 동안 매 프레임 불리므로, 암호 창을 쓴 뒤에만 기록을 지움.
325추가: if self.password_challenge.is_some() {
326추가: self.forget_password_history
327추가: .extend(["archive-password-input", "archive-password-confirm"]);
328추가: }
329추가: }
330추가:
331추가: /// 지운 암호가 입력창의 실행 취소(Ctrl+Z)로 되살아나지 않게 egui가 보관하는
332추가: /// 입력창 상태(실행 취소 기록 포함)를 지움.
333추가: fn forget_password_history(&mut self, ctx: &egui::Context) {
334추가: if self.forget_password_history.is_empty() {
335추가: return;
336추가: }
337추가: let names = std::mem::take(&mut self.forget_password_history);
338추가: ctx.data_mut(|data| {
339추가: for name in names {
340추가: data.remove::<egui::text_edit::TextEditState>(egui::Id::unique(name));
341추가: }
342추가: });
321343 }
322344
323345 fn clear_zip_password(&mut self) {
@@ -327,6 +349,8 @@ impl ArchiveApp {
327349 wipe(&mut pending);
328350 }
329351 self.zip_password_visible = false;
352추가: self.forget_password_history
353추가: .extend(["zip-password-input", "zip-password-confirm"]);
330354 }
331355
332356 /// 암호로 보호하지 않거나, 두 암호가 같고 1~1024바이트이면 만들 수 있음.
@@ -770,7 +794,13 @@ impl ArchiveApp {
770794
771795 fn poll(&mut self) {
772796 let busy = self.model.busy();
797추가: let close_before = self.model.close;
773798 self.model.poll();
799추가: if close_before == Close::Confirm && self.model.close == Close::Review {
800추가: // 종료 확인 창에 답하기 전에 작업이 끝났음. 사용자가 닫기를 승인하지 않았으므로
801추가: // 바로 닫지 않고 계속 물음(close_dialog가 작업이 끝난 문구로 바꿔 보여 줌).
802추가: self.model.close = Close::Confirm;
803추가: }
774804 if busy && !self.model.busy() {
775805 if let Some(path) = self.owned_destination.take() {
776806 if !self.model.confirmed
@@ -788,6 +818,7 @@ impl ArchiveApp {
788818
789819 pub fn show(&mut self, root: &mut egui::Ui) {
790820 let ctx = root.ctx().clone();
821추가: self.forget_password_history(&ctx);
791822 if !self.initialized {
792823 theme::apply(&ctx);
793824 self.initialized = true;
@@ -955,6 +986,7 @@ impl ArchiveApp {
955986 self.empty(ui);
956987 }
957988 });
989추가: self.forget_password_history(&ctx);
958990 self.work_window(&ctx);
959991 self.create_window(&ctx);
960992 if self.model.challenge.is_some() {
@@ -2288,11 +2320,13 @@ impl ArchiveApp {
22882320 ui.colored_label(theme::ERROR, "두 암호가 같지 않습니다");
22892321 }
22902322 ui.label(RichText::new("암호를 잊으면 파일을 열 수 없습니다.").color(theme::MUTED));
2291삭제: } else if !self.zip_password.is_empty() || !self.zip_password_confirm.is_empty() {
2292삭제: // 체크를 해제하면 입력한 암호를 남겨 두지 않음.
2293삭제: wipe(&mut self.zip_password);
2294삭제: wipe(&mut self.zip_password_confirm);
2295삭제: self.zip_password_visible = false;
2323추가: } else if check.changed()
2324추가: || !self.zip_password.is_empty()
2325추가: || !self.zip_password_confirm.is_empty()
2326추가: {
2327추가: // 체크를 해제하면 입력한 암호와 그 실행 취소 기록을 남겨 두지 않음.
2328추가: // 입력했다가 모두 지운 경우도 기록에는 남아 있으므로 해제한 순간 함께 지움.
2329추가: self.clear_zip_password();
22962330 }
22972331 false
22982332 }
@@ -2416,13 +2450,30 @@ impl ArchiveApp {
24162450 ui.set_width(420.0);
24172451 match self.model.close {
24182452 Close::Confirm => {
2419삭제: ui.heading("작업 중 닫기");
2420삭제: ui.label("작업을 취소하고 닫을까요?");
2453추가: // 답하기 전에 작업이 끝났으면 취소할 작업이 없으므로 닫을지만 물음.
2454추가: let busy = self.model.busy();
2455추가: let (heading, text, keep, close) = if busy {
2456추가: (
2457추가: "작업 중 닫기",
2458추가: "작업을 취소하고 닫을까요?",
2459추가: "계속 작업",
2460추가: "취소하고 닫기",
2461추가: )
2462추가: } else {
2463추가: (
2464추가: "닫기",
2465추가: "작업이 끝났습니다. 창을 닫을까요?",
2466추가: "열어 두기",
2467추가: "닫기",
2468추가: )
2469추가: };
2470추가: ui.heading(heading);
2471추가: ui.label(text);
24212472 ui.horizontal(|ui| {
2422삭제: if theme::action(ui, "계속 작업", false, true).clicked() {
2473추가: if theme::action(ui, keep, false, true).clicked() {
24232474 self.model.keep_open();
24242475 }
2425삭제: if theme::action(ui, "취소하고 닫기", true, true).clicked() {
2476추가: if theme::action(ui, close, true, true).clicked() {
24262477 self.clear_password();
24272478 self.model.confirm_close();
24282479 }
수정tests/rust-app-ui/create_window.rs+45-0
@@ -480,3 +480,48 @@ fn cancelling_second_folder_choice_keeps_create_window_contents() {
480480 assert!(work_child_label("a.txt").is_none());
481481 assert!(work_child_label("암호 확인").is_none());
482482}
483추가:
484추가: #[test]
485추가: fn unchecking_password_also_forgets_undo_history() {
486추가: let scratch = Folder::new();
487추가: let factory = FakeFactory::default();
488추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
489추가: policy_click(&ctx, &mut app, "암호로 보호하기");
490추가: text(&ctx, &mut app, "zip-password-input", "undo-secret");
491추가: // egui는 입력이 1초쯤 멈춰야 실행 취소 지점을 남기므로 그만큼 프레임을 진행함.
492추가: for _ in 0..90 {
493추가: policy_render(&ctx, &mut app, vec![]);
494추가: }
495추가:
496추가: // 체크를 풀었다가 다시 켜면 암호 칸은 비어 있음.
497추가: policy_click(&ctx, &mut app, "암호로 보호하기");
498추가: policy_click(&ctx, &mut app, "암호로 보호하기");
499추가:
500추가: // 실행 취소(Ctrl+Z)를 눌러도 지운 암호가 되살아나지 않아야 함.
501추가: // 한 번만 누름(두 번째 실행 취소는 다시 처음 상태로 돌아감).
502추가: ctx.memory_mut(|memory| memory.request_focus(egui::Id::unique("zip-password-input")));
503추가: policy_render(&ctx, &mut app, vec![]);
504추가: {
505추가: policy_render(
506추가: &ctx,
507추가: &mut app,
508추가: vec![egui::Event::Key {
509추가: key: egui::Key::Z,
510추가: physical_key: None,
511추가: pressed: true,
512추가: repeat: false,
513추가: modifiers: egui::Modifiers::COMMAND,
514추가: }],
515추가: );
516추가: }
517추가: policy_click(&ctx, &mut app, "보기");
518추가: let shown = policy_render(&ctx, &mut app, vec![]);
519추가: assert!(
520추가: shown.iter().any(|(text, _)| text == "숨기기"),
521추가: "암호가 보여야 함"
522추가: );
523추가: assert!(
524추가: !shown.iter().any(|(text, _)| text.contains("undo-secret")),
525추가: "지운 암호가 실행 취소로 되살아남"
526추가: );
527추가: }
수정tests/rust-app-ui/work_window.rs+46-0
@@ -542,3 +542,49 @@ fn main_modals_are_not_covered_by_separate_result_window() {
542542 "선택 창을 닫으면 결과 창이 다시 나타나야 함"
543543 );
544544}
545추가:
546추가: #[test]
547추가: fn unanswered_close_confirmation_does_not_close_when_work_finishes() {
548추가: let scratch = Folder::new();
549추가: let factory = FakeFactory::default();
550추가: let mut app = loaded(&scratch, &factory);
551추가: factory.state.borrow_mut().manual = true;
552추가: assert!(app.begin_extract());
553추가: factory
554추가: .state
555추가: .borrow_mut()
556추가: .frame(Event::Accepted { encryption: false });
557추가: let ctx = egui::Context::default();
558추가: for _ in 0..4 {
559추가: policy_render(&ctx, &mut app, vec![]);
560추가: }
561추가: app.model.request_close();
562추가: assert_eq!(app.model.close, Close::Confirm);
563추가:
564추가: // 종료 확인 창에 답하지 않은 채 작업이 끝남.
565추가: factory
566추가: .state
567추가: .borrow_mut()
568추가: .finish(Outcome::Completed, Publication::None);
569추가: let mut shown = Vec::new();
570추가: for _ in 0..12 {
571추가: shown = policy_render(&ctx, &mut app, vec![]);
572추가: }
573추가: assert!(!app.model.busy());
574추가: assert_eq!(
575추가: app.model.close,
576추가: Close::Confirm,
577추가: "닫기를 승인하지 않았는데 앱이 닫힘"
578추가: );
579추가: assert!(
580추가: shown
581추가: .iter()
582추가: .any(|(text, _)| text == "작업이 끝났습니다. 창을 닫을까요?"),
583추가: "{shown:?}"
584추가: );
585추가:
586추가: // 그 뒤에 닫기를 고르면 바로 닫힘.
587추가: policy_click(&ctx, &mut app, "닫기");
588추가: policy_render(&ctx, &mut app, vec![]);
589추가: assert_eq!(app.model.close, Close::Allowed);
590추가: }