team-ljyzipelo

공개

큰 작업 승인과 안전한 확대 재시도를 화면에 연결한다

작성자
호시노 히나타
작성 시각
커밋
822ad1e4c859c100197f1fa501095bb6d0ab8a9c
부모
6565a4b
이 시점의 파일 보기

변경된 파일 13개

+1,121-15
수정docs/ui-scenario-guide.md+20-0
@@ -97,3 +97,23 @@ python3 tests/ci/run_rust.py local
9797
9898
9999TAR.BZ2와 TAR.XZ의 자동 해제 폴더 이름은 미리보기에 표시되지 않는다. tests/rust-app-ui/presentation.rs의 이름 시험과 tests/rust-app-real-worker/compressed_tar_flows.rs의 실제 작업자 시험에서 복합 확장자 제거와 해제 결과를 확인한다.
100추가:
101추가: ## 큰 작업의 승인과 재시도
102추가:
103추가: - resource-approval: 목록에서 큰 작업임을 확인한 뒤 처리 전 승인을 묻는 화면
104추가: - resource-ratio: 압축률 경고와 미확인 예상값을 표시하는 화면
105추가: - resource-retry: 출력 없이 한도에 걸린 뒤 "한도를 늘려 다시 시도"를 고르는 화면
106추가: - resource-partial: 일부 파일을 저장한 뒤 한도에 걸려 저장 위치를 안내하는 화면
107추가:
108추가: 일반 작업은 16 GiB와 10,000개 한도를 유지하며 압축률을 감시합니다.
109추가: 목록이나 선택한 일반 파일의 크기로 한도 초과를 알면 처리 전에 작업자가 확대 승인을 묻습니다.
110추가: 미리 알 수 없는 폴더 내부와 압축파일은 기본 한도로 시작합니다.
111추가: 출력이 없고 임시 파일 정리와 작업자 종료가 확인된 한도 오류에서만 확대 재시도를 제공합니다.
112추가: 확대 재시도를 선택해도 작업자의 승인 질문에서 "이 작업 허용"을 눌러야 진행합니다.
113추가: 이미 저장되거나 일부 남은 파일, 저장 상태나 정리가 불확실한 작업은 확대 재시도를 제공하지 않습니다.
114추가:
115추가: 승인은 해당 작업과 질문 범위에만 적용합니다. 예상값, 실제값과 저장 볼륨의 여유 공간은 구분하며
116추가: 확인하지 못한 값은 "미확인"으로 표시합니다. 여유 공간은 예약이나 모든 볼륨의 합계가 아닙니다.
117추가: 승인 후에도 상한과 공간 검사를 유지합니다. 취소 버튼과 Escape는 승인 대기 중 작업을 취소합니다.
118추가: Enter만으로 허용하지 않습니다. 기존 작업자로 자동 재시도하지 않습니다.
119추가: 미리보기는 입력과 파일 쓰기를 막으며 실제 64 GiB 작업을 수행하지 않습니다.
수정experiments/rust-ui-memory-app/src/archive_process.rs+40-2
@@ -228,6 +228,21 @@ fn event_to_ui(
228228 wire::Message::Accepted { action, encryption } if expected == Some(action) => {
229229 ui::Event::Accepted { encryption }
230230 }
231추가: wire::Message::ResourceRequired {
232추가: challenge_id,
233추가: action,
234추가: scope,
235추가: usage,
236추가: soft_limits,
237추가: ceiling,
238추가: } if expected == Some(action) => ui::Event::ResourceRequired(ui::ResourceChallenge {
239추가: id: challenge_id,
240추가: action,
241추가: scope,
242추가: usage,
243추가: soft_limits,
244추가: ceiling,
245추가: }),
231246 wire::Message::Entry(entry) => ui::Event::Entry(ui::Entry {
232247 id: entry.entry_id,
233248 name: entry.name,
@@ -451,15 +466,38 @@ impl ui::Connection for ProcessConnection {
451466 return Err("작업자 요청 채널이 닫혔거나 순서가 올바르지 않습니다".into());
452467 }
453468 let is_cancel = matches!(request.command, ui::Command::Cancel);
469추가: let expanded = matches!(&request.command, ui::Command::StartExpanded(_));
454470 let message = match request.command {
455삭제: ui::Command::Start(start) => {
471추가: ui::Command::Start(start) | ui::Command::StartExpanded(start) => {
456472 let start = start_to_wire(start);
457473 *self.expected.lock().map_err(|_| {
458474 self.stop.store(true, Ordering::Release);
459475 "작업자 요청 상태 오류"
460476 })? = Some(start.action.kind());
461삭제: wire::Message::Start(start)
477추가: let ceiling = if expanded {
478추가: wire::Limits {
479추가: input: u64::MAX,
480추가: output: 64 * 1024 * 1024 * 1024,
481추가: entries: 200_000,
482추가: }
483추가: } else {
484추가: wire::Limits::default()
485추가: };
486추가: wire::Message::StartGuarded(wire::GuardedStart {
487추가: start,
488추가: ceiling,
489추가: interactive: false,
490추가: })
462491 }
492추가: ui::Command::ResourceReply {
493추가: challenge_id,
494추가: scope,
495추가: allow,
496추가: } => wire::Message::ResourceReply {
497추가: challenge_id,
498추가: scope,
499추가: allow,
500추가: },
463501 ui::Command::Cancel => wire::Message::Cancel,
464502 ui::Command::Password {
465503 challenge_id,
수정experiments/rust-ui-memory-app/src/archive_screen.rs+151-0
@@ -1012,6 +1012,7 @@ impl ArchiveApp {
10121012 if self.model.challenge.is_some() {
10131013 self.password_dialog(&ctx, new_challenge);
10141014 }
1015추가: self.resource_dialog(&ctx);
10151016 self.close_dialog(&ctx);
10161017 self.picker_notice(&ctx);
10171018 if self.custom_frame {
@@ -1593,6 +1594,7 @@ impl ArchiveApp {
15931594 (self.create && !self.model.busy())
15941595 || self.picker.is_some()
15951596 || self.model.challenge.is_some()
1597추가: || self.model.resource.is_some()
15961598 || self.model.close != Close::Open
15971599 }
15981600
@@ -1718,6 +1720,13 @@ impl ArchiveApp {
17181720 }
17191721
17201722 fn progress(&mut self, ui: &mut egui::Ui) {
1723추가: if self.model.resource.is_some() {
1724추가: ui.horizontal(|ui| {
1725추가: ui.label("사용자 허용을 기다리고 있습니다");
1726추가: self.cancel_action(ui, false);
1727추가: });
1728추가: return;
1729추가: }
17211730 let creating = matches!(self.last_request, Some(Start::CreateZip { .. }));
17221731 let cancelling = self.model.cancellation_requested() || self.model.cancel.is_some();
17231732 let title = present::activity_text(&self.model, creating);
@@ -1824,6 +1833,7 @@ impl ArchiveApp {
18241833 };
18251834 let mut choose = false;
18261835 let mut retry = false;
1836추가: let mut expand = false;
18271837 let mut reopen = false;
18281838 let mut folder = false;
18291839 theme::panel(fill).show(ui, |ui| {
@@ -1893,6 +1903,22 @@ impl ArchiveApp {
18931903 "아무 파일도 풀지 않았습니다"
18941904 });
18951905 }
1906추가: if t.as_ref().is_some_and(|t| {
1907추가: t.error == Some(ErrorCode::Limit)
1908추가: && (t.created_count > 0
1909추가: || t.retained_partial_count > 0
1910추가: || t.publication != Publication::None)
1911추가: }) {
1912추가: ui.label(format!(
1913추가: "{}개 파일이 저장되었거나 일부 남아 있습니다. 저장 위치를 확인하세요.",
1914추가: t.as_ref().unwrap().created_count
1915추가: ));
1916추가: theme::bounded_text(
1917추가: ui,
1918추가: &self.destination.display().to_string(),
1919추가: ui.available_width(),
1920추가: );
1921추가: }
18961922 if self.details {
18971923 theme::panel(theme::STRIPE).show(ui, |ui| {
18981924 if durability_in_details {
@@ -1974,6 +2000,13 @@ impl ArchiveApp {
19742000 },
19752001 true,
19762002 ))
2003추가: } else if self.model.can_retry_expanded() {
2004추가: None
2005추가: } else if t
2006추가: .as_ref()
2007추가: .is_some_and(|t| t.error == Some(ErrorCode::Limit))
2008추가: {
2009추가: None
19772010 } else if !cancelled && (!uncertain || listing) {
19782011 Some(("다시 시도", true))
19792012 } else {
@@ -1997,6 +2030,11 @@ impl ArchiveApp {
19972030 }
19982031 }
19992032 });
2033추가: if self.model.can_retry_expanded() {
2034추가: ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
2035추가: expand = theme::action(ui, "한도를 늘려 다시 시도", true, true).clicked();
2036추가: });
2037추가: }
20002038 });
20012039 if choose {
20022040 self.open_picker(Purpose::Retry);
@@ -2004,6 +2042,27 @@ impl ArchiveApp {
20042042 if retry {
20052043 self.retry();
20062044 }
2045추가: if expand {
2046추가: let ready = if matches!(self.last_request, Some(Start::Extract { .. })) {
2047추가: match present::prepare_destination(&self.destination, self.automatic_destination) {
2048추가: Ok(created) => {
2049추가: self.owned_destination = created.then(|| self.destination.clone());
2050추가: true
2051추가: }
2052추가: Err(_) => {
2053추가: self.ui_error = Some(present::FOLDER_ERROR.into());
2054추가: false
2055추가: }
2056추가: }
2057추가: } else {
2058추가: true
2059추가: };
2060추가: if ready && self.model.retry_expanded(self.factory.as_mut()) {
2061추가: self.dismissed = false;
2062추가: self.details = false;
2063추가: self.ui_error = None;
2064추가: }
2065추가: }
20072066 if reopen {
20082067 if let Some(path) = self.model.archive.clone() {
20092068 self.open_path(path);
@@ -2383,6 +2442,98 @@ impl ArchiveApp {
23832442 cancel
23842443 }
23852444
2445추가: fn resource_dialog(&mut self, ctx: &egui::Context) {
2446추가: let Some(question) = self.model.resource.clone() else {
2447추가: return;
2448추가: };
2449추가: let Some(job) = self.model.job_id() else {
2450추가: return;
2451추가: };
2452추가: let mut allow = false;
2453추가: let mut cancel = false;
2454추가: let modal = egui::Modal::new(egui::Id::unique(("archive-resource", job, question.id)))
2455추가: .show(ctx, |ui| {
2456추가: ui.set_width((ctx.content_rect().width() - 64.0).min(460.0));
2457추가: ui.heading(if question.scope.ratio {
2458추가: "압축률이 매우 높습니다"
2459추가: } else {
2460추가: "큰 작업을 허용할까요?"
2461추가: });
2462추가: ui.label(match question.action {
2463추가: ActionKind::List => "압축파일 목록 열기",
2464추가: ActionKind::Extract => "압축 해제",
2465추가: ActionKind::CreateZip => "ZIP 만들기",
2466추가: });
2467추가: if question.scope.ratio {
2468추가: ui.label("작은 압축파일도 많은 저장 공간을 사용할 수 있습니다.");
2469추가: }
2470추가: if question.scope.output {
2471추가: ui.label(format!(
2472추가: "총량 한도: {}에서 {}로",
2473추가: present::bytes_text(question.soft_limits.output),
2474추가: present::bytes_text(question.ceiling.output)
2475추가: ));
2476추가: }
2477추가: if question.scope.entries {
2478추가: ui.label(format!(
2479추가: "항목 한도: {}개에서 {}개로",
2480추가: question.soft_limits.entries, question.ceiling.entries
2481추가: ));
2482추가: }
2483추가: let mut u = question.usage;
2484추가: let estimated = self.model.estimated_usage();
2485추가: u.estimated_bytes = u.estimated_bytes.or(estimated.estimated_bytes);
2486추가: u.estimated_entries = u.estimated_entries.or(estimated.estimated_entries);
2487추가: let bytes = |value: Option<u64>| {
2488추가: value
2489추가: .map(present::bytes_text)
2490추가: .unwrap_or_else(|| "미확인".into())
2491추가: };
2492추가: let entries = |value: Option<u32>| {
2493추가: value
2494추가: .map(|n| format!("{n}개"))
2495추가: .unwrap_or_else(|| "미확인".into())
2496추가: };
2497추가: ui.label(format!(
2498추가: "예상 총량: {} / 실제 총량: {}",
2499추가: bytes(u.estimated_bytes),
2500추가: bytes(u.actual_bytes)
2501추가: ));
2502추가: ui.label(format!(
2503추가: "예상 항목: {} / 실제 항목: {}",
2504추가: entries(u.estimated_entries),
2505추가: entries(u.actual_entries)
2506추가: ));
2507추가: if question.scope.ratio {
2508추가: ui.label(format!(
2509추가: "압축 크기: {} / 풀린 크기: {}",
2510추가: bytes(u.compressed_bytes),
2511추가: bytes(u.ratio_output_bytes)
2512추가: ));
2513추가: }
2514추가: ui.label(format!(
2515추가: "확인한 저장 볼륨의 여유 공간: {}",
2516추가: bytes(u.available_bytes)
2517추가: ));
2518추가: ui.label(format!(
2519추가: "이 작업의 상한: {} / {}개",
2520추가: present::bytes_text(question.ceiling.output),
2521추가: question.ceiling.entries
2522추가: ));
2523추가: ui.label("이 작업에만 적용합니다. 공간 부족이나 자원 상한에 도달하면 중단합니다.");
2524추가: ui.horizontal(|ui| {
2525추가: cancel = theme::action(ui, "취소", false, true).clicked();
2526추가: allow = theme::action(ui, "이 작업 허용", true, true).clicked();
2527추가: });
2528추가: });
2529추가: if cancel || modal.should_close() {
2530추가: self.clear_password();
2531추가: self.model.cancel();
2532추가: } else if allow {
2533추가: self.model.resource_reply(job, question.id, true);
2534추가: }
2535추가: }
2536추가:
23862537 fn password_dialog(&mut self, ctx: &egui::Context, new_challenge: bool) {
23872538 let (_, attempt, encrypt) = self.model.challenge.unwrap();
23882539 let mut submit = false;
수정experiments/rust-ui-memory-app/src/archive_ui.rs+234-11
@@ -72,7 +72,16 @@ impl Drop for Secret {
7272}
7373pub enum Command {
7474 Start(Start),
75삭제: Password { challenge_id: u64, secret: Secret },
75추가: StartExpanded(Start),
76추가: ResourceReply {
77추가: challenge_id: u64,
78추가: scope: ResourceScope,
79추가: allow: bool,
80추가: },
81추가: Password {
82추가: challenge_id: u64,
83추가: secret: Secret,
84추가: },
7685 Cancel,
7786}
7887pub struct Request {
@@ -171,8 +180,20 @@ pub struct Terminal {
171180 pub durability: Durability,
172181 pub cleanup: Cleanup,
173182}
183추가: pub use worker_protocol::protocol::{ActionKind, Limits, ResourceScope, ResourceUsage};
184추가: #[derive(Clone, Debug)]
185추가: pub struct ResourceChallenge {
186추가: pub id: u64,
187추가: pub action: ActionKind,
188추가: pub scope: ResourceScope,
189추가: pub usage: ResourceUsage,
190추가: pub soft_limits: Limits,
191추가: pub ceiling: Limits,
192추가: }
193추가:
174194#[derive(Clone, Debug)]
175195pub enum Event {
196추가: ResourceRequired(ResourceChallenge),
176197 Accepted {
177198 encryption: bool,
178199 },
@@ -247,6 +268,10 @@ struct Running {
247268 stderr_eof: bool,
248269 exit: Option<bool>,
249270 cancel_sequence: Option<u64>,
271추가: expanded: bool,
272추가: granted: ResourceScope,
273추가: last_challenge: u64,
274추가: estimated: ResourceUsage,
250275}
251276#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
252277pub enum Close {
@@ -267,6 +292,8 @@ pub struct Model {
267292 pub selected: BTreeSet<u32>,
268293 pub terminal: Option<Terminal>,
269294 pub challenge: Option<(u64, u32, bool)>,
295추가: pub resource: Option<ResourceChallenge>,
296추가: retry_start: Option<Start>,
270297 pub progress: Option<(Stage, u64, Option<u64>, u64)>,
271298 pub outputs: Vec<(String, Disposition)>,
272299 pub cancel: Option<CancelStatus>,
@@ -295,9 +322,121 @@ impl Model {
295322 && self.close == Close::Open
296323 }
297324 pub fn begin(&mut self, start: Start, factory: &mut dyn Factory) -> bool {
325추가: let expanded = self.needs_expansion(&start);
326추가: self.begin_with_limits(start, factory, expanded)
327추가: }
328추가: pub fn estimated_usage(&self) -> ResourceUsage {
329추가: self.running
330추가: .as_ref()
331추가: .map(|run| run.estimated)
332추가: .unwrap_or_default()
333추가: }
334추가: fn estimate(&self, start: &Start) -> ResourceUsage {
335추가: let mut usage = ResourceUsage::default();
336추가: match start {
337추가: Start::Extract { selection, .. } => {
338추가: let selected_ids: BTreeSet<_> = match selection {
339추가: Selection::All => BTreeSet::new(),
340추가: Selection::EntryIds(ids) => ids.iter().copied().collect(),
341추가: };
342추가: let directories: BTreeSet<_> = self
343추가: .entries
344추가: .iter()
345추가: .filter(|e| selected_ids.contains(&e.id) && e.kind == Kind::Directory)
346추가: .map(|e| e.name.trim_end_matches('/'))
347추가: .collect();
348추가: let selected = |entry: &&Entry| {
349추가: matches!(selection, Selection::All)
350추가: || selected_ids.contains(&entry.id)
351추가: || entry
352추가: .name
353추가: .match_indices('/')
354추가: .any(|(n, _)| directories.contains(&entry.name[..n]))
355추가: };
356추가: let entries: Vec<_> = self.entries.iter().filter(selected).collect();
357추가: usage.estimated_entries = u32::try_from(entries.len()).ok();
358추가: usage.estimated_bytes = entries
359추가: .iter()
360추가: .try_fold(0u64, |sum, e| sum.checked_add(e.bytes?));
361추가: }
362추가: Start::CreateZip { sources, .. } => {
363추가: usage.estimated_bytes = sources.iter().try_fold(0u64, |sum, (path, _)| {
364추가: let m = std::fs::symlink_metadata(path).ok()?;
365추가: if !m.is_file() {
366추가: return None;
367추가: }
368추가: sum.checked_add(m.len())
369추가: });
370추가: usage.estimated_entries = sources
371추가: .iter()
372추가: .all(|(path, _)| std::fs::symlink_metadata(path).is_ok_and(|m| m.is_file()))
373추가: .then(|| u32::try_from(sources.len()).ok())
374추가: .flatten();
375추가: }
376추가: Start::List { .. } => {}
377추가: }
378추가: usage
379추가: }
380추가: fn needs_expansion(&self, start: &Start) -> bool {
381추가: let usage = self.estimate(start);
382추가: usage
383추가: .estimated_bytes
384추가: .is_some_and(|n| n > Limits::default().output)
385추가: || usage
386추가: .estimated_entries
387추가: .is_some_and(|n| n > Limits::default().entries)
388추가: }
389추가: pub fn can_retry_expanded(&self) -> bool {
390추가: !self.busy() && self.retry_start.is_some() && self.close == Close::Open
391추가: }
392추가: pub fn retry_expanded(&mut self, factory: &mut dyn Factory) -> bool {
393추가: if !self.can_retry_expanded() {
394추가: return false;
395추가: }
396추가: let start = self.retry_start.clone().unwrap();
397추가: self.begin_with_limits(start, factory, true)
398추가: }
399추가: pub fn resource_reply(&mut self, job_id: u64, challenge_id: u64, allow: bool) -> bool {
400추가: if self.job_id() != Some(job_id) || self.cancellation_requested() {
401추가: return false;
402추가: }
403추가: let Some(question) = self.resource.clone().filter(|q| q.id == challenge_id) else {
404추가: return false;
405추가: };
406추가: if self
407추가: .send(Command::ResourceReply {
408추가: challenge_id,
409추가: scope: question.scope,
410추가: allow,
411추가: })
412추가: .is_none()
413추가: {
414추가: return false;
415추가: }
416추가: if allow {
417추가: let granted = &mut self.running.as_mut().unwrap().granted;
418추가: granted.output |= question.scope.output;
419추가: granted.entries |= question.scope.entries;
420추가: granted.ratio |= question.scope.ratio;
421추가: }
422추가: self.resource = None;
423추가: true
424추가: }
425추가: fn begin_with_limits(
426추가: &mut self,
427추가: start: Start,
428추가: factory: &mut dyn Factory,
429추가: expanded: bool,
430추가: ) -> bool {
298431 if self.busy() || self.close != Close::Open {
299432 return false;
300433 }
434추가: let selectable: BTreeSet<_> = self
435추가: .entries
436추가: .iter()
437추가: .filter(|e| matches!(e.kind, Kind::File | Kind::Directory))
438추가: .map(|e| e.id)
439추가: .collect();
301440 let validation = match &start {
302441 Start::List { archive } => archive.is_absolute(),
303442 Start::Extract {
@@ -320,12 +459,7 @@ impl Model {
320459 Selection::EntryIds(ids) => {
321460 !ids.is_empty()
322461 && ids.iter().collect::<BTreeSet<_>>().len() == ids.len()
323삭제: && ids.iter().all(|id| {
324삭제: self.entries.iter().any(|e| {
325삭제: e.id == *id
326삭제: && matches!(e.kind, Kind::File | Kind::Directory)
327삭제: })
328삭제: })
462추가: && ids.iter().all(|id| selectable.contains(id))
329463 }
330464 }
331465 }
@@ -349,6 +483,7 @@ impl Model {
349483 self.error = Some("작업 ID 한도에 도달했습니다".into());
350484 return false;
351485 };
486추가: let estimated = self.estimate(&start);
352487 let mut connection = match factory.connect(id) {
353488 Ok(c) => c,
354489 Err(e) => {
@@ -360,7 +495,11 @@ impl Model {
360495 .send(Request {
361496 job_id: id,
362497 sequence: 0,
363삭제: command: Command::Start(start.clone()),
498추가: command: if expanded {
499추가: Command::StartExpanded(start.clone())
500추가: } else {
501추가: Command::Start(start.clone())
502추가: },
364503 })
365504 .err();
366505 let started = send_error.is_none();
@@ -374,6 +513,8 @@ impl Model {
374513 }
375514 self.next_id = id;
376515 self.terminal = None;
516추가: self.retry_start = None;
517추가: self.resource = None;
377518 self.challenge = None;
378519 self.progress = None;
379520 self.outputs.clear();
@@ -396,6 +537,10 @@ impl Model {
396537 stderr_eof: false,
397538 exit: None,
398539 cancel_sequence: None,
540추가: expanded,
541추가: granted: ResourceScope::default(),
542추가: last_challenge: 0,
543추가: estimated,
399544 });
400545 started
401546 }
@@ -443,6 +588,7 @@ impl Model {
443588 .is_some()
444589 {
445590 self.challenge = None;
591추가: self.resource = None;
446592 self.input_error = None;
447593 true
448594 } else {
@@ -483,6 +629,7 @@ impl Model {
483629 if let Some(seq) = self.send(Command::Cancel) {
484630 self.running.as_mut().unwrap().cancel_sequence = Some(seq);
485631 self.challenge = None;
632추가: self.resource = None;
486633 self.input_error = None;
487634 }
488635 }
@@ -564,7 +711,25 @@ impl Model {
564711 self.list_id = None;
565712 self.selected.clear();
566713 }
714추가: self.retry_start = if !run.expanded
715추가: && run.cancel_sequence.is_none()
716추가: && self.confirmed
717추가: && self.terminal.as_ref().is_some_and(|t| {
718추가: t.outcome == Outcome::Failed
719추가: && t.error == Some(ErrorCode::Limit)
720추가: && t.publication == Publication::None
721추가: && t.created_count == 0
722추가: && t.retained_partial_count == 0
723추가: && t.cleanup == Cleanup::Complete
724추가: })
725추가: && self.outputs.iter().all(|(_, d)| *d == Disposition::Removed)
726추가: {
727추가: Some(run.start.clone())
728추가: } else {
729추가: None
730추가: };
567731 self.challenge = None;
732추가: self.resource = None;
568733 self.input_error = None;
569734 if matches!(self.close, Close::Waiting | Close::Confirm) {
570735 self.close = Close::Review;
@@ -611,7 +776,12 @@ impl Model {
611776 || run.list_end.is_some()
612777 || entry.id as usize != run.entries.len()
613778 || entry.name.len() > 4096
614삭제: || run.entries.len() >= 100_000
779추가: || run.entries.len()
780추가: >= if run.granted.entries {
781추가: 200_000
782추가: } else {
783추가: 100_000
784추가: }
615785 {
616786 self.error = Some("목록 응답이 유효하지 않습니다".into());
617787 } else {
@@ -636,12 +806,55 @@ impl Model {
636806 attempt,
637807 encrypt,
638808 } => {
639삭제: if self.challenge.is_some() || challenge_id == 0 {
809추가: if run.cancel_sequence.is_some() {
810추가: return;
811추가: }
812추가: if self.challenge.is_some()
813추가: || self.resource.is_some()
814추가: || challenge_id <= run.last_challenge
815추가: {
640816 self.error = Some("암호 요청이 유효하지 않습니다".into());
641817 } else {
818추가: run.last_challenge = challenge_id;
642819 self.challenge = Some((challenge_id, attempt, encrypt));
643820 }
644821 }
822추가: Event::ResourceRequired(question) => {
823추가: if run.cancel_sequence.is_some() {
824추가: return;
825추가: }
826추가: let expected = match run.start {
827추가: Start::List { .. } => ActionKind::List,
828추가: Start::Extract { .. } => ActionKind::Extract,
829추가: Start::CreateZip { .. } => ActionKind::CreateZip,
830추가: };
831추가: let hard = Limits {
832추가: input: u64::MAX,
833추가: output: 64 * 1024 * 1024 * 1024,
834추가: entries: 200_000,
835추가: };
836추가: let ceiling = if run.expanded {
837추가: hard
838추가: } else {
839추가: Limits::default()
840추가: };
841추가: if self.challenge.is_some()
842추가: || self.resource.is_some()
843추가: || question.id <= run.last_challenge
844추가: || question.action != expected
845추가: || !question.scope.any()
846추가: || question.soft_limits != Limits::default()
847추가: || question.ceiling != ceiling
848추가: || (question.scope.output && (!run.expanded || run.granted.output))
849추가: || (question.scope.entries && (!run.expanded || run.granted.entries))
850추가: || (question.scope.ratio && run.granted.ratio)
851추가: {
852추가: self.error = Some("자원 승인 요청이 유효하지 않습니다".into());
853추가: } else {
854추가: run.last_challenge = question.id;
855추가: self.resource = Some(question);
856추가: }
857추가: }
645858 Event::Progress {
646859 stage,
647860 processed,
@@ -653,7 +866,14 @@ impl Model {
653866 disposition,
654867 ..
655868 } => {
656삭제: if self.outputs.len() < 100_000 && relative_name.len() <= 4096 {
869추가: if self.outputs.len()
870추가: < if run.granted.entries {
871추가: 200_000
872추가: } else {
873추가: 100_000
874추가: }
875추가: && relative_name.len() <= 4096
876추가: {
657877 self.outputs.push((relative_name, disposition));
658878 } else {
659879 self.error = Some("출력 보고 한도 초과".into());
@@ -685,6 +905,9 @@ impl Model {
685905 if self.terminal.is_some() {
686906 return "작업 결과 수신 / 프로세스 종료 확인 중".into();
687907 }
908추가: if self.resource.is_some() {
909추가: return "사용자 허용 대기".into();
910추가: }
688911 if self.challenge.is_some() {
689912 return "암호를 입력하세요".into();
690913 }
수정tests/rust-app-real-worker/flows.rs+2-0
@@ -690,3 +690,5 @@ fn cancel_racing_exit_without_terminal_remains_unconfirmed() {
690690 assert!(model.error.is_some());
691691 assert_eq!(model.close, Close::Review);
692692}
693추가:
694추가: mod guarded_flows;
추가tests/rust-app-real-worker/guarded_flows.rs+112-0
@@ -0,0 +1,112 @@
1추가: use super::*;
2추가: use std::collections::VecDeque;
3추가: struct FirstLimit {
4추가: first: bool,
5추가: process: ProcessFactory,
6추가: }
7추가: struct Failed {
8추가: job: u64,
9추가: events: VecDeque<HostEvent>,
10추가: }
11추가: impl Connection for Failed {
12추가: fn send(&mut self, request: Request) -> Result<(), String> {
13추가: assert!(matches!(request.command, Command::Start(_)));
14추가: self.events.extend([
15추가: HostEvent::Frame {
16추가: job_id: self.job,
17추가: sequence: 0,
18추가: event: Event::Accepted { encryption: true },
19추가: },
20추가: HostEvent::Frame {
21추가: job_id: self.job,
22추가: sequence: 1,
23추가: event: Event::Terminal(Terminal {
24추가: outcome: Outcome::Failed,
25추가: error: Some(ErrorCode::Limit),
26추가: publication: Publication::None,
27추가: created_count: 0,
28추가: retained_partial_count: 0,
29추가: durability: Durability::NotApplicable,
30추가: cleanup: Cleanup::Complete,
31추가: }),
32추가: },
33추가: HostEvent::StdoutEof,
34추가: HostEvent::StderrEof,
35추가: HostEvent::Exited { success: true },
36추가: ]);
37추가: Ok(())
38추가: }
39추가: fn poll(&mut self) -> Option<HostEvent> {
40추가: self.events.pop_front()
41추가: }
42추가: }
43추가: impl Factory for FirstLimit {
44추가: fn connect(&mut self, job: u64) -> Result<Box<dyn Connection>, String> {
45추가: if self.first {
46추가: self.first = false;
47추가: Ok(Box::new(Failed {
48추가: job,
49추가: events: VecDeque::new(),
50추가: }))
51추가: } else {
52추가: self.process.connect(job)
53추가: }
54추가: }
55추가: }
56추가: #[test]
57추가: fn model_retry_uses_real_guarded_codec_and_requires_a_new_job_approval() {
58추가: for mode in 0..3 {
59추가: let scratch = Scratch::new();
60추가: let archive = scratch.path("sample.zip");
61추가: fs::write(&archive, include_bytes!("fixtures/sample.zip")).unwrap();
62추가: let mut factory = FirstLimit {
63추가: first: true,
64추가: process: ProcessFactory::new(binary("zipelo-archive-worker")),
65추가: };
66추가: let mut model = Model::default();
67추가: assert!(model.begin(Start::List { archive }, &mut factory));
68추가: let first_job = model.job_id().unwrap();
69추가: wait(&mut model);
70추가: assert!(model.can_retry_expanded());
71추가: assert!(model.retry_expanded(&mut factory));
72추가: let job = model.job_id().unwrap();
73추가: assert_ne!(first_job, job);
74추가: let deadline = Instant::now() + Duration::from_secs(10);
75추가: while model.resource.is_none() {
76추가: model.poll();
77추가: assert!(model.error.is_none(), "{:?}", model.error);
78추가: assert!(Instant::now() < deadline);
79추가: std::thread::sleep(Duration::from_millis(1));
80추가: }
81추가: let q = model.resource.clone().unwrap();
82추가: assert_eq!(
83추가: q.scope,
84추가: ResourceScope {
85추가: output: true,
86추가: entries: true,
87추가: ratio: false
88추가: }
89추가: );
90추가: assert_eq!(q.usage.actual_bytes, None);
91추가: assert!(q.usage.available_bytes.is_some());
92추가: assert!(model.entries.is_empty());
93추가: assert!(!model.resource_reply(first_job, q.id, true));
94추가: if mode == 2 {
95추가: model.cancel();
96추가: } else {
97추가: assert!(model.resource_reply(job, q.id, mode == 0));
98추가: }
99추가: wait(&mut model);
100추가: assert!(model.confirmed, "{:?}", model.error);
101추가: assert_eq!(
102추가: model.terminal.as_ref().unwrap().outcome,
103추가: if mode == 0 {
104추가: Outcome::Completed
105추가: } else {
106추가: Outcome::Cancelled
107추가: }
108추가: );
109추가: assert_eq!(model.list_id.is_some(), mode == 0);
110추가: assert!(model.resource.is_none());
111추가: }
112추가: }
수정tests/rust-app-ui/capture.rs+2-1
@@ -181,7 +181,7 @@ impl Factory for CaptureFactory {
181181impl Connection for CaptureConnection {
182182 fn send(&mut self, request: Request) -> Result<(), String> {
183183 match request.command {
184삭제: Command::Start(start) => {
184추가: Command::Start(start) | Command::StartExpanded(start) => {
185185 self.event(Event::Accepted { encryption: true });
186186 match start {
187187 Start::List { .. } => {
@@ -247,6 +247,7 @@ impl Connection for CaptureConnection {
247247 }
248248 }
249249 Command::Password { .. } => self.finish(false),
250추가: Command::ResourceReply { .. } => {}
250251 Command::Cancel => {
251252 self.event(Event::CancelAck {
252253 request_sequence: request.sequence,
수정tests/rust-app-ui/fake.rs+13-1
@@ -6,6 +6,8 @@ pub struct State {
66 pub requests: Vec<(u64, &'static str)>,
77 pub starts: Vec<Start>,
88 pub password_seen: bool,
9추가: pub expanded: bool,
10추가: pub resources: Vec<(u64, ResourceScope, bool)>,
911 /// 마지막으로 받은 암호 원문. 화면에서 입력한 암호가 그대로 전달됐는지 확인할 때 씀.
1012 pub password: Vec<u8>,
1113 pub job: u64,
@@ -130,8 +132,11 @@ impl Connection for FakeConnection {
130132 fn send(&mut self, request: Request) -> Result<(), String> {
131133 let mut s = self.state.borrow_mut();
132134 assert_eq!(s.job, request.job_id);
135추가: if matches!(&request.command, Command::StartExpanded(_)) {
136추가: s.expanded = true;
137추가: }
133138 match request.command {
134삭제: Command::Start(start) => {
139추가: Command::Start(start) | Command::StartExpanded(start) => {
135140 if let Start::Extract {
136141 list_id,
137142 gzip_output_name,
@@ -184,6 +189,13 @@ impl Connection for FakeConnection {
184189 s.complete_action();
185190 }
186191 }
192추가: Command::ResourceReply {
193추가: challenge_id,
194추가: scope,
195추가: allow,
196추가: } => {
197추가: s.resources.push((challenge_id, scope, allow));
198추가: }
187199 Command::Cancel => {
188200 s.requests.push((request.sequence, "cancel"));
189201 if !s.manual {
추가tests/rust-app-ui/guarded.rs+267-0
@@ -0,0 +1,267 @@
1추가: use super::*;
2추가:
3추가: fn waiting() -> (Model, FakeFactory) {
4추가: let mut f = FakeFactory::manual();
5추가: let mut m = Model::default();
6추가: assert!(m.begin(
7추가: Start::List {
8추가: archive: path("large.zip")
9추가: },
10추가: &mut f
11추가: ));
12추가: f.state
13추가: .borrow_mut()
14추가: .frame(Event::Accepted { encryption: true });
15추가: for _ in 0..4 {
16추가: m.poll();
17추가: }
18추가: (m, f)
19추가: }
20추가: fn question(id: u64) -> ResourceChallenge {
21추가: ResourceChallenge {
22추가: id,
23추가: action: ActionKind::List,
24추가: scope: ResourceScope {
25추가: ratio: true,
26추가: ..Default::default()
27추가: },
28추가: usage: ResourceUsage::default(),
29추가: soft_limits: Limits::default(),
30추가: ceiling: Limits::default(),
31추가: }
32추가: }
33추가: fn receive(m: &mut Model, f: &FakeFactory, event: Event) {
34추가: f.state.borrow_mut().frame(event);
35추가: for _ in 0..4 {
36추가: m.poll();
37추가: }
38추가: }
39추가: fn fail(
40추가: m: &mut Model,
41추가: f: &FakeFactory,
42추가: publication: Publication,
43추가: created: u64,
44추가: partial: u64,
45추가: cleanup: Cleanup,
46추가: ) {
47추가: let mut s = f.state.borrow_mut();
48추가: s.frame(Event::Terminal(Terminal {
49추가: outcome: Outcome::Failed,
50추가: error: Some(ErrorCode::Limit),
51추가: publication,
52추가: created_count: created,
53추가: retained_partial_count: partial,
54추가: durability: Durability::NotApplicable,
55추가: cleanup,
56추가: }));
57추가: s.queue.extend([
58추가: HostEvent::StdoutEof,
59추가: HostEvent::StderrEof,
60추가: HostEvent::Exited { success: true },
61추가: ]);
62추가: drop(s);
63추가: pump(m);
64추가: }
65추가: #[test]
66추가: fn reply_is_bound_to_job_question_scope_and_once_only() {
67추가: let (mut m, f) = waiting();
68추가: receive(&mut m, &f, Event::ResourceRequired(question(1)));
69추가: assert!(!m.resource_reply(99, 1, true));
70추가: assert!(!m.resource_reply(m.job_id().unwrap(), 2, true));
71추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true));
72추가: assert!(!m.resource_reply(m.job_id().unwrap(), 1, true));
73추가: assert_eq!(f.state.borrow().resources, [(1, question(1).scope, true)]);
74추가: }
75추가: #[test]
76추가: fn cancel_during_question_never_grants_and_clears_prompt() {
77추가: let (mut m, f) = waiting();
78추가: receive(&mut m, &f, Event::ResourceRequired(question(1)));
79추가: let job = m.job_id().unwrap();
80추가: m.cancel();
81추가: assert!(m.resource.is_none());
82추가: assert!(!m.resource_reply(job, 1, true));
83추가: f.state
84추가: .borrow_mut()
85추가: .finish(Outcome::Cancelled, Publication::None);
86추가: pump(&mut m);
87추가: assert!(f.state.borrow().resources.is_empty());
88추가: assert!(m.confirmed);
89추가: }
90추가: #[test]
91추가: fn queued_question_after_cancel_does_not_turn_cancel_into_transport_failure() {
92추가: let (mut m, f) = waiting();
93추가: m.cancel();
94추가: receive(&mut m, &f, Event::ResourceRequired(question(1)));
95추가: assert!(m.resource.is_none());
96추가: assert!(m.error.is_none());
97추가: }
98추가: #[test]
99추가: fn wrong_action_limits_empty_scope_and_overlapping_questions_are_rejected() {
100추가: for mode in 0..6 {
101추가: let (mut m, f) = waiting();
102추가: let mut q = question(1);
103추가: match mode {
104추가: 0 => q.action = ActionKind::Extract,
105추가: 1 => q.ceiling.output += 1,
106추가: 2 => q.scope = ResourceScope::default(),
107추가: 3 => q.id = 0,
108추가: 4 => receive(
109추가: &mut m,
110추가: &f,
111추가: Event::PasswordRequired {
112추가: challenge_id: 1,
113추가: attempt: 1,
114추가: encrypt: false,
115추가: },
116추가: ),
117추가: _ => receive(&mut m, &f, Event::ResourceRequired(q.clone())),
118추가: }
119추가: receive(&mut m, &f, Event::ResourceRequired(q));
120추가: assert!(m.error.is_some(), "{mode}");
121추가: }
122추가: }
123추가: #[test]
124추가: fn old_challenge_and_repeated_scope_are_rejected_after_reply() {
125추가: for reused_id in [true, false] {
126추가: let (mut m, f) = waiting();
127추가: receive(&mut m, &f, Event::ResourceRequired(question(1)));
128추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true));
129추가: receive(
130추가: &mut m,
131추가: &f,
132추가: Event::ResourceRequired(question(if reused_id { 1 } else { 2 })),
133추가: );
134추가: assert!(m.error.is_some());
135추가: }
136추가: }
137추가: #[test]
138추가: fn only_confirmed_clean_empty_failure_offers_expanded_retry_once() {
139추가: for (publication, count, partial, cleanup, retry) in [
140추가: (Publication::None, 0, 0, Cleanup::Complete, true),
141추가: (Publication::None, 1, 0, Cleanup::Complete, false),
142추가: (Publication::Partial, 1, 0, Cleanup::Complete, false),
143추가: (Publication::Uncertain, 0, 0, Cleanup::Complete, false),
144추가: (Publication::None, 0, 1, Cleanup::Complete, false),
145추가: (Publication::None, 0, 0, Cleanup::Unconfirmed, false),
146추가: ] {
147추가: let (mut m, mut f) = waiting();
148추가: fail(&mut m, &f, publication, count, partial, cleanup);
149추가: assert_eq!(m.can_retry_expanded(), retry);
150추가: assert_eq!(m.retry_expanded(&mut f), retry);
151추가: if retry {
152추가: assert!(f.state.borrow().expanded);
153추가: receive(&mut m, &f, Event::Accepted { encryption: true });
154추가: fail(&mut m, &f, Publication::None, 0, 0, Cleanup::Complete);
155추가: assert!(!m.can_retry_expanded());
156추가: }
157추가: }
158추가: }
159추가: #[test]
160추가: fn known_extract_size_requests_expansion_before_processing_and_estimates_unknown_separately() {
161추가: let mut m = Model::default();
162추가: let mut f = FakeFactory::default();
163추가: list(&mut m, &mut f);
164추가: m.entries[0].bytes = Some(Limits::default().output + 1);
165추가: f.state.borrow_mut().manual = true;
166추가: assert!(m.extract(path("out"), false, None, &mut f));
167추가: assert!(f.state.borrow().expanded);
168추가: assert_eq!(
169추가: m.estimated_usage().estimated_bytes,
170추가: Some(Limits::default().output + 1)
171추가: );
172추가: assert_eq!(m.estimated_usage().actual_bytes, None);
173추가: }
174추가: #[test]
175추가: fn entries_over_one_hundred_thousand_are_accepted_only_after_entry_approval() {
176추가: for approved in [false, true] {
177추가: let (mut m, f) = waiting();
178추가: if approved {
179추가: fail(&mut m, &f, Publication::None, 0, 0, Cleanup::Complete);
180추가: let mut factory = f.clone();
181추가: assert!(m.retry_expanded(&mut factory));
182추가: receive(&mut m, &f, Event::Accepted { encryption: true });
183추가: let mut q = question(1);
184추가: q.scope = ResourceScope {
185추가: output: true,
186추가: entries: true,
187추가: ratio: false,
188추가: };
189추가: q.ceiling = Limits {
190추가: input: u64::MAX,
191추가: output: 64 * 1024 * 1024 * 1024,
192추가: entries: 200_000,
193추가: };
194추가: receive(&mut m, &f, Event::ResourceRequired(q));
195추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true));
196추가: }
197추가: let cap = if approved { 200_000 } else { 100_000 };
198추가: for id in 0..=cap {
199추가: assert!(m.error.is_none(), "{id}");
200추가: receive(
201추가: &mut m,
202추가: &f,
203추가: Event::Entry(Entry {
204추가: id,
205추가: name: format!("{id}"),
206추가: kind: Kind::File,
207추가: bytes: Some(0),
208추가: packed: Some(0),
209추가: encrypted: false,
210추가: }),
211추가: );
212추가: }
213추가: assert!(m.error.is_some());
214추가: }
215추가: }
216추가:
217추가: #[test]
218추가: fn output_history_ceiling_expands_only_after_entry_permission() {
219추가: for approved in [false, true] {
220추가: let mut m = Model::default();
221추가: let mut f = FakeFactory::manual();
222추가: assert!(m.begin(
223추가: Start::CreateZip {
224추가: sources: vec![(path("source"), "source".into())],
225추가: output_file: path("new.zip"),
226추가: method: Method::Store,
227추가: aes256: false
228추가: },
229추가: &mut f
230추가: ));
231추가: receive(&mut m, &f, Event::Accepted { encryption: true });
232추가: if approved {
233추가: fail(&mut m, &f, Publication::None, 0, 0, Cleanup::Complete);
234추가: assert!(m.retry_expanded(&mut f));
235추가: receive(&mut m, &f, Event::Accepted { encryption: true });
236추가: let mut q = question(1);
237추가: q.action = ActionKind::CreateZip;
238추가: q.scope = ResourceScope {
239추가: output: true,
240추가: entries: true,
241추가: ratio: false,
242추가: };
243추가: q.ceiling = Limits {
244추가: input: u64::MAX,
245추가: output: 64 * 1024 * 1024 * 1024,
246추가: entries: 200_000,
247추가: };
248추가: receive(&mut m, &f, Event::ResourceRequired(q));
249추가: assert!(m.resource_reply(m.job_id().unwrap(), 1, true));
250추가: }
251추가: let cap = if approved { 200_000 } else { 100_000 };
252추가: for n in 0..=cap {
253추가: assert!(m.error.is_none(), "{n}");
254추가: receive(
255추가: &mut m,
256추가: &f,
257추가: Event::Output {
258추가: entry_id: None,
259추가: relative_name: format!("{n}"),
260추가: disposition: Disposition::Created,
261추가: },
262추가: );
263추가: }
264추가: assert_eq!(m.outputs.len(), cap);
265추가: assert!(m.error.is_some());
266추가: }
267추가: }
수정tests/rust-app-ui/regressions.rs+2-0
@@ -870,3 +870,5 @@ fn password_validation_and_retry_do_not_erase_transport_failure() {
870870mod presentation;
871871
872872mod windows_paths;
873추가:
874추가: mod guarded;
수정tests/rust-app-ui/scenario_tests.rs+112-0
@@ -96,6 +96,10 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
9696 );
9797 assert!(app.model.input_error.is_none(), "{}", scenario.name);
9898 let expected = match scenario.name {
99추가: "resource-approval" => "큰 작업을 허용할까요?",
100추가: "resource-ratio" => "압축률이 매우 높습니다",
101추가: "resource-retry" => "한도를 늘려 다시 시도",
102추가: "resource-partial" => "저장 위치를 확인하세요",
99103 "empty" => "TAR.BZ2, TAR.XZ",
100104 "tar-bz2" | "tar-xz" => "읽어주세요.txt",
101105 "folder-empty" => "이 폴더는 비어 있습니다",
@@ -197,3 +201,111 @@ fn preview_ignores_password_submission() {
197201 assert_eq!(preview.0.model.challenge, Some((17, 1, false)));
198202 assert!(preview.0.model.busy());
199203}
204추가:
205추가: fn resource_frame(
206추가: app: &mut zipelo_ui_memory_app::archive_screen::ArchiveApp,
207추가: ctx: &egui::Context,
208추가: events: Vec<egui::Event>,
209추가: ) -> Vec<egui::epaint::ClippedShape> {
210추가: let mut out = ctx.run_ui(
211추가: egui::RawInput {
212추가: screen_rect: Some(egui::Rect::from_min_size(
213추가: egui::Pos2::ZERO,
214추가: egui::vec2(760.0, 540.0),
215추가: )),
216추가: events,
217추가: ..Default::default()
218추가: },
219추가: |ui| app.show(ui),
220추가: );
221추가: out.textures_delta.clear();
222추가: out.shapes
223추가: }
224추가: fn find_resource_action(shapes: &[egui::epaint::ClippedShape], label: &str) -> egui::Pos2 {
225추가: fn find(s: &egui::Shape, label: &str) -> Option<egui::Pos2> {
226추가: match s {
227추가: egui::Shape::Text(t) if t.galley.text() == label => {
228추가: Some(t.pos + t.galley.rect.size() / 2.0)
229추가: }
230추가: egui::Shape::Vec(shapes) => shapes.iter().find_map(|s| find(s, label)),
231추가: _ => None,
232추가: }
233추가: }
234추가: shapes.iter().find_map(|s| find(&s.shape, label)).unwrap()
235추가: }
236추가: #[test]
237추가: fn resource_dialog_requires_explicit_click_and_escape_cancels() {
238추가: for allow in [false, true] {
239추가: let ctx = egui::Context::default();
240추가: let mut app = scenarios::parse("resource-ratio").unwrap().build();
241추가: let mut shapes = Vec::new();
242추가: for _ in 0..3 {
243추가: shapes = resource_frame(&mut app, &ctx, vec![]);
244추가: }
245추가: assert!(text(&shapes).contains("미확인"));
246추가: resource_frame(
247추가: &mut app,
248추가: &ctx,
249추가: vec![egui::Event::Key {
250추가: key: egui::Key::Enter,
251추가: physical_key: None,
252추가: pressed: true,
253추가: repeat: false,
254추가: modifiers: Default::default(),
255추가: }],
256추가: );
257추가: assert!(app.model.resource.is_some());
258추가: if allow {
259추가: let point = find_resource_action(&shapes, "이 작업 허용");
260추가: resource_frame(
261추가: &mut app,
262추가: &ctx,
263추가: vec![
264추가: egui::Event::PointerMoved(point),
265추가: egui::Event::PointerButton {
266추가: pos: point,
267추가: button: egui::PointerButton::Primary,
268추가: pressed: true,
269추가: modifiers: Default::default(),
270추가: },
271추가: ],
272추가: );
273추가: resource_frame(
274추가: &mut app,
275추가: &ctx,
276추가: vec![egui::Event::PointerButton {
277추가: pos: point,
278추가: button: egui::PointerButton::Primary,
279추가: pressed: false,
280추가: modifiers: Default::default(),
281추가: }],
282추가: );
283추가: assert!(!app.model.cancellation_requested());
284추가: } else {
285추가: resource_frame(
286추가: &mut app,
287추가: &ctx,
288추가: vec![egui::Event::Key {
289추가: key: egui::Key::Escape,
290추가: physical_key: None,
291추가: pressed: true,
292추가: repeat: false,
293추가: modifiers: Default::default(),
294추가: }],
295추가: );
296추가: assert!(app.model.cancellation_requested());
297추가: }
298추가: assert!(app.model.resource.is_none());
299추가: }
300추가: }
301추가: #[test]
302추가: fn partial_limit_result_never_offers_expanded_retry() {
303추가: let ctx = egui::Context::default();
304추가: let mut app = scenarios::parse("resource-partial").unwrap().build();
305추가: let mut shapes = Vec::new();
306추가: for _ in 0..3 {
307추가: shapes = resource_frame(&mut app, &ctx, vec![]);
308추가: }
309추가: assert!(!text(&shapes).contains("한도를 늘려 다시 시도"));
310추가: assert!(text(&shapes).contains("풀린 자료"));
311추가: }
수정tests/rust-app-ui/scenarios.rs+64-0
@@ -21,6 +21,10 @@ macro_rules! catalog {
2121}
2222
2323catalog! {
24추가: "resource-approval" => "처리 전 큰 작업 승인",
25추가: "resource-ratio" => "고압축 작업 경고와 미확인 값",
26추가: "resource-retry" => "출력 없는 한도 실패 후 확대 재시도",
27추가: "resource-partial" => "일부 출력 후 한도 중단",
2428 "empty" => "빈 첫 화면",
2529 "archive" => "폴더와 파일이 있는 압축파일",
2630 "tar-bz2" => "TAR.BZ2 목록과 자동 해제 폴더",
@@ -285,11 +289,71 @@ impl Scenario {
285289 "사진/풍경.jpg".into(),
286290 ])
287291 });
292추가: if self.name == "resource-approval" {
293추가: app.model.entries[1].bytes = Some(17 * 1024 * 1024 * 1024);
294추가: }
288295 assert!(app.start(request));
289296 {
290297 let mut state = state.borrow_mut();
291298 state.frame(Event::Accepted { encryption: true });
292299 match self.name {
300추가: "resource-approval" | "resource-ratio" => {
301추가: let expanded = self.name == "resource-approval";
302추가: state.frame(Event::ResourceRequired(ResourceChallenge {
303추가: id: 1,
304추가: action: ActionKind::Extract,
305추가: scope: ResourceScope {
306추가: output: expanded,
307추가: entries: expanded,
308추가: ratio: !expanded,
309추가: },
310추가: usage: ResourceUsage {
311추가: available_bytes: Some(90 * 1024 * 1024 * 1024),
312추가: actual_bytes: (!expanded).then_some(300 * 1024 * 1024),
313추가: ratio_output_bytes: (!expanded).then_some(300 * 1024 * 1024),
314추가: compressed_bytes: (!expanded).then_some(4096),
315추가: ..ResourceUsage::default()
316추가: },
317추가: soft_limits: Limits::default(),
318추가: ceiling: if expanded {
319추가: Limits {
320추가: input: u64::MAX,
321추가: output: 64 * 1024 * 1024 * 1024,
322추가: entries: 200_000,
323추가: }
324추가: } else {
325추가: Limits::default()
326추가: },
327추가: }));
328추가: }
329추가: "resource-retry" | "resource-partial" => {
330추가: let partial = self.name == "resource-partial";
331추가: if partial {
332추가: state.frame(Event::Output {
333추가: entry_id: Some(1),
334추가: relative_name: "읽어주세요.txt".into(),
335추가: disposition: Disposition::Created,
336추가: });
337추가: }
338추가: state.frame(Event::Terminal(Terminal {
339추가: outcome: Outcome::Failed,
340추가: error: Some(ErrorCode::Limit),
341추가: publication: if partial {
342추가: Publication::Partial
343추가: } else {
344추가: Publication::None
345추가: },
346추가: created_count: u64::from(partial),
347추가: retained_partial_count: 0,
348추가: durability: Durability::Synced,
349추가: cleanup: Cleanup::Complete,
350추가: }));
351추가: state.queue.extend([
352추가: HostEvent::StdoutEof,
353추가: HostEvent::StderrEof,
354추가: HostEvent::Exited { success: true },
355추가: ]);
356추가: }
293357 "password" | "password-retry" | "password-create" => {
294358 state.frame(Event::PasswordRequired {
295359 challenge_id: 17,
수정tests/rust-app-ui/work_window.rs+102-0
@@ -598,3 +598,105 @@ fn unanswered_close_confirmation_does_not_close_when_work_finishes() {
598598 policy_render(&ctx, &mut app, vec![]);
599599 assert_eq!(app.model.close, Close::Allowed);
600600}
601추가:
602추가: #[test]
603추가: fn resource_prompt_is_not_covered_by_separate_work_window() {
604추가: let factory = FakeFactory::manual();
605추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false);
606추가: assert!(app.model.begin(
607추가: Start::List {
608추가: archive: std::env::current_dir().unwrap().join("large.zip")
609추가: },
610추가: &mut factory.clone()
611추가: ));
612추가: {
613추가: let mut worker = factory.state.borrow_mut();
614추가: worker.frame(Event::Accepted { encryption: true });
615추가: worker.frame(Event::ResourceRequired(ResourceChallenge {
616추가: id: 17,
617추가: action: ActionKind::List,
618추가: scope: ResourceScope {
619추가: ratio: true,
620추가: ..Default::default()
621추가: },
622추가: usage: ResourceUsage::default(),
623추가: soft_limits: Limits::default(),
624추가: ceiling: Limits::default(),
625추가: }));
626추가: }
627추가: let ctx = egui::Context::default();
628추가: ctx.set_embed_viewports(false);
629추가: install_work_child_renderer();
630추가: for _ in 0..12 {
631추가: policy_render(&ctx, &mut app, vec![]);
632추가: }
633추가: assert!(app.model.resource.is_some());
634추가: WORK_CHILD.with(|child| child.borrow_mut().rendered = 0);
635추가: for _ in 0..3 {
636추가: policy_render(&ctx, &mut app, vec![]);
637추가: }
638추가: assert_eq!(work_rendered(), 0);
639추가: }
640추가:
641추가: #[test]
642추가: fn expanded_retry_action_fits_native_work_window_and_starts_a_new_job() {
643추가: let factory = FakeFactory::manual();
644추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), None, false);
645추가: app.open_path(std::env::current_dir().unwrap().join("large.zip"));
646추가: let old_job = app.model.job_id().unwrap();
647추가: {
648추가: let mut worker = factory.state.borrow_mut();
649추가: worker.frame(Event::Accepted { encryption: true });
650추가: worker.frame(Event::Terminal(Terminal {
651추가: outcome: Outcome::Failed,
652추가: error: Some(ErrorCode::Limit),
653추가: publication: Publication::None,
654추가: created_count: 0,
655추가: retained_partial_count: 0,
656추가: durability: Durability::NotApplicable,
657추가: cleanup: Cleanup::Complete,
658추가: }));
659추가: worker.queue.extend([
660추가: HostEvent::StdoutEof,
661추가: HostEvent::StderrEof,
662추가: HostEvent::Exited { success: true },
663추가: ]);
664추가: }
665추가: let ctx = egui::Context::default();
666추가: ctx.set_embed_viewports(false);
667추가: install_work_child_renderer();
668추가: for _ in 0..12 {
669추가: policy_render(&ctx, &mut app, vec![]);
670추가: }
671추가: assert!(app.model.can_retry_expanded());
672추가: let point = work_child_label("한도를 늘려 다시 시도").unwrap();
673추가: let width = WORK_CHILD.with(|child| {
674추가: child
675추가: .borrow()
676추가: .builders
677추가: .last()
678추가: .unwrap()
679추가: .1
680추가: .inner_size
681추가: .unwrap()
682추가: .x
683추가: });
684추가: let text_width = ctx.fonts_mut(|fonts| {
685추가: fonts
686추가: .layout_no_wrap(
687추가: "한도를 늘려 다시 시도".into(),
688추가: egui::FontId::proportional(16.0),
689추가: egui::Color32::BLACK,
690추가: )
691추가: .size()
692추가: .x
693추가: });
694추가: assert!(
695추가: point.x + text_width / 2.0 <= width - 16.0,
696추가: "버튼 글자가 창을 벗어남: {point:?} / {text_width} / {width}"
697추가: );
698추가: work_child_click(&ctx, &mut app, point);
699추가: assert!(app.model.busy());
700추가: assert_ne!(app.model.job_id(), Some(old_job));
701추가: assert!(factory.state.borrow().expanded);
702추가: }