Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

feat(github): add automated issue validation and triage workflows

Samir Hossains2105132de437
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 997dbce..a503136 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -1,50 +1,94 @@
name: Bug report
-description: Something is broken or not working as expected.
+description: Report an issue or unexpected behavior in MovieBox-Tui.
title: "bug: "
labels: ["bug"]
body:
+ - type: markdown
+ attributes:
+ value: |
+ Please verify the issue occurs on the latest release before submitting.
+ For general setup questions, use [GitHub Discussions](https://github.com/mesamirh/MovieBox-Tui/discussions).
+
+ - type: checkboxes
+ id: checklist
+ attributes:
+ label: Pre-submission Checklist
+ options:
+ - label: I am running the latest release of MovieBox-Tui.
+ required: true
+ - label: I searched existing issues and confirmed this is not already reported.
+ required: true
+
- type: textarea
id: description
attributes:
- label: What happened?
- description: Describe the bug and what you expected instead.
+ label: Description
+ description: Describe what happened and what you expected instead.
+ placeholder: Provide a clear description of the problem.
validations:
required: true
- type: textarea
id: reproduction
attributes:
- label: Steps to reproduce
+ label: Steps to Reproduce
+ description: List the exact steps to reproduce the issue.
placeholder: |
- 1. Run `moviebox-tui`
- 2. ...
+ 1. Launch `moviebox-tui`
+ 2. Search for ...
+ 3. Select ...
+ 4. See error ...
validations:
required: true
- - type: input
- id: version
+ - type: textarea
+ id: error_output
attributes:
- label: Version
- description: Find it with `moviebox-tui --version`.
- placeholder: "0.1.2"
+ label: Error Output or Screenshot
+ description: Paste any error status text displayed on screen, terminal output, or attach a screenshot.
+ placeholder: Paste error messages or drag and drop screenshots here.
validations:
- required: true
+ required: false
- type: dropdown
id: os
attributes:
- label: Operating system
+ label: Operating System
options:
- - macOS
+ - Android (Termux)
- Linux
+ - macOS
- Windows
validations:
required: true
+ - type: dropdown
+ id: player
+ attributes:
+ label: Media Player
+ description: The media player configured in Settings (/settings) or launched.
+ options:
+ - Android Player (Intent Chooser)
+ - mpv
+ - IINA
+ - VLC
+ - None / Other
+ validations:
+ required: true
+
- type: input
- id: terminal
+ id: version
attributes:
- label: Terminal
- placeholder: "Ghostty, iTerm2, Kitty, WezTerm, Alacritty, ..."
+ label: Version
+ description: Found via `moviebox-tui --version`.
+ placeholder: "0.1.20"
validations:
required: true
+
+ - type: input
+ id: terminal
+ attributes:
+ label: Terminal Emulator
+ placeholder: "Ghostty, Kitty, Alacritty, iTerm2, WezTerm, Termux, Windows Terminal, ..."
+ validations:
+ required: false
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 3ba13e0..cea5b5d 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1 +1,11 @@
blank_issues_enabled: false
+contact_links:
+ - name: Documentation & Known Issues
+ url: https://github.com/mesamirh/MovieBox-Tui/blob/main/docs/known-issues.md
+ about: Review documented workarounds, requirements, and known issues.
+ - name: Android / Termux Setup Guide
+ url: https://github.com/mesamirh/MovieBox-Tui/blob/main/docs/cross-platform.md
+ about: Read requirements for running on Android via Termux.
+ - name: GitHub Discussions
+ url: https://github.com/mesamirh/MovieBox-Tui/discussions
+ about: Ask questions, request setup assistance, or discuss configurations.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
index c7aed51..2f089ba 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -1,20 +1,35 @@
name: Feature request
-description: Suggest a new feature or improvement.
+description: Suggest a new feature, improvement, or provider for MovieBox-Tui.
title: "feat: "
labels: ["enhancement"]
body:
+ - type: markdown
+ attributes:
+ value: |
+ Please verify your idea has not already been proposed in existing issues or discussions.
+
- type: textarea
id: problem
attributes:
- label: What problem does this solve?
- description: What are you trying to do that MovieBox-Tui makes hard or impossible?
+ label: Problem Statement
+ description: Explain the problem or limitation you are trying to solve.
+ placeholder: Describe the current limitation or use case.
+ validations:
+ required: true
+
+ - type: textarea
+ id: proposal
+ attributes:
+ label: Proposed Solution
+ description: Describe the desired behavior or implementation.
+ placeholder: Describe how the feature should behave.
validations:
required: true
- type: textarea
- id: solution
+ id: alternatives
attributes:
- label: Proposed solution
- description: Optional. How could it work?
+ label: Alternative Solutions
+ description: Any alternative solutions or workarounds you considered.
validations:
required: false
diff --git a/.github/workflows/duplicate-detector.yml b/.github/workflows/duplicate-detector.yml
new file mode 100644
index 0000000..485fe29
--- /dev/null
+++ b/.github/workflows/duplicate-detector.yml
@@ -0,0 +1,25 @@
+name: Duplicate Issue Detection
+
+on:
+ issues:
+ types: [opened, edited]
+
+permissions:
+ issues: write
+
+jobs:
+ similarity:
+ runs-on: ubuntu-latest
+ if: "!github.event.issue.pull_request"
+ steps:
+ - name: Check issue similarity
+ uses: actions-cool/issues-similarity@v1
+ with:
+ filter-threshold: 0.75
+ title-threshold: 0.85
+ comment: |
+ Potential duplicate detected: #{number}.
+
+ Please review that issue to check if your problem or suggestion has already been addressed.
+ labels: duplicate
+ close-issue: false
diff --git a/.github/workflows/incomplete-issue.yml b/.github/workflows/incomplete-issue.yml
new file mode 100644
index 0000000..b18776b
--- /dev/null
+++ b/.github/workflows/incomplete-issue.yml
@@ -0,0 +1,172 @@
+name: Issue Intake & Quality Guard
+
+on:
+ issues:
+ types: [opened, edited]
+ issue_comment:
+ types: [created]
+
+permissions:
+ issues: write
+ contents: read
+
+jobs:
+ triage:
+ runs-on: ubuntu-latest
+ if: "!github.event.issue.pull_request"
+ steps:
+ - name: Validate and triage issue
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const issue = context.payload.issue;
+ const eventName = context.eventName;
+
+ function parseSemver(v) {
+ const cleaned = (v || '').replace(/^[vV]/, '').trim();
+ const parts = cleaned.split('.').map(n => parseInt(n, 10));
+ if (parts.length >= 3 && parts.every(n => !isNaN(n))) {
+ return parts.slice(0, 3);
+ }
+ return null;
+ }
+
+ function isOlder(current, latest) {
+ for (let i = 0; i < 3; i++) {
+ if (current[i] < latest[i]) return true;
+ if (current[i] > latest[i]) return false;
+ }
+ return false;
+ }
+
+ if (eventName === 'issue_comment') {
+ const comment = context.payload.comment;
+ const isAuthor = comment.user && issue.user && comment.user.login === issue.user.login;
+ const hasNeedsInfo = (issue.labels || []).some(l => l.name === 'needs-info' || l.name === 'stale');
+
+ if (isAuthor && hasNeedsInfo) {
+ const labelsToRemove = ['needs-info', 'stale'];
+ for (const label of labelsToRemove) {
+ try {
+ await github.rest.issues.removeLabel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: issue.number,
+ name: label
+ });
+ } catch (_) {}
+ }
+ }
+ return;
+ }
+
+ const body = (issue.body || '').trim();
+ if (!body) return;
+
+ const isBugReport = (issue.labels || []).some(l => l.name === 'bug') ||
+ (issue.title || '').toLowerCase().startsWith('bug:');
+
+ if (!isBugReport) return;
+
+ function extractSection(headerName) {
+ const regex = new RegExp(`###\\s*${headerName}[\\r\\n]+([\\s\\S]*?)(?=###|$)`, 'i');
+ const match = body.match(regex);
+ return match ? match[1].trim() : '';
+ }
+
+ const description = extractSection('Description');
+ const steps = extractSection('Steps to Reproduce');
+ const userVersionRaw = extractSection('Version');
+ const osRaw = extractSection('Operating System');
+ const playerRaw = extractSection('Media Player');
+
+ const labelsToAdd = new Set();
+ const feedbackPoints = [];
+
+ if (osRaw.includes('Android')) labelsToAdd.add('os: android');
+ else if (osRaw.includes('Linux')) labelsToAdd.add('os: linux');
+ else if (osRaw.includes('macOS')) labelsToAdd.add('os: macos');
+ else if (osRaw.includes('Windows')) labelsToAdd.add('os: windows');
+
+ const titleAfterPrefix = (issue.title || '')
+ .replace(/^(bug|feat|fix|refactor|chore|docs|perf)(\([^)]+\))?:\s*/i, '')
+ .trim();
+ const genericTitlePattern = /^(none|na|n\/a|error|bug|issue|help|not working|broken|its show error|please fix)$/i;
+ const isTitleGeneric = titleAfterPrefix.length < 5 || genericTitlePattern.test(titleAfterPrefix);
+
+ const isTooShort = (text) => {
+ const stripped = text.replace(/[`*_\s\r\n-]/g, '');
+ return stripped.length < 15;
+ };
+ const placeholderPattern = /^(none|na|n\/a|nil|error|not working|broken|please fix|please resolved?|v?\d+(\.\d+)*)$/i;
+
+ const descriptionIncomplete = isTooShort(description) || placeholderPattern.test(description);
+ const stepsIncomplete = isTooShort(steps) || placeholderPattern.test(steps);
+
+ if (isTitleGeneric || descriptionIncomplete || stepsIncomplete) {
+ labelsToAdd.add('needs-info');
+ feedbackPoints.push('**Incomplete Details**: Please provide a descriptive issue title, concrete description of what failed, and exact numbered steps to reproduce.');
+ }
+
+ let latestVersionStr = null;
+ try {
+ const release = await github.rest.repos.getLatestRelease({
+ owner: context.repo.owner,
+ repo: context.repo.repo
+ });
+ latestVersionStr = release.data.tag_name || release.data.name;
+ } catch (_) {}
+
+ if (latestVersionStr) {
+ const latestParsed = parseSemver(latestVersionStr);
+ const userParsed = parseSemver(userVersionRaw);
+
+ if (latestParsed && userParsed && isOlder(userParsed, latestParsed)) {
+ labelsToAdd.add('outdated-version');
+ const latestClean = latestParsed.join('.');
+ const userClean = userParsed.join('.');
+
+ let upgradeCmd = 'curl -fsSL https://raw.githubusercontent.com/mesamirh/MovieBox-Tui/main/install.sh | bash';
+ if (osRaw.includes('macOS')) {
+ upgradeCmd = 'brew upgrade moviebox-tui (or re-run install.sh)';
+ } else if (osRaw.includes('Windows')) {
+ upgradeCmd = 'irm https://raw.githubusercontent.com/mesamirh/MovieBox-Tui/main/install.ps1 | iex';
+ }
+
+ feedbackPoints.push(`**Outdated Version**: This report specifies version \`${userClean}\`, but the latest release is \`${latestClean}\`.\nPlease update to the latest release and verify if the issue persists:\n\`\`\`sh\n${upgradeCmd}\n\`\`\``);
+ }
+ }
+
+ if (osRaw.includes('Android') && (playerRaw.includes('None') || playerRaw.includes('Other'))) {
+ feedbackPoints.push('**Android / Termux Playback**: Video playback on Android requires external video player dispatch. Ensure `termux-tools` and `termux-am` are installed:\n```sh\npkg update && pkg install -y termux-tools termux-am\n```');
+ }
+
+ if (labelsToAdd.size > 0) {
+ const currentLabels = (issue.labels || []).map(l => l.name);
+ const newLabels = Array.from(labelsToAdd).filter(l => !currentLabels.includes(l));
+ if (newLabels.length > 0) {
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: issue.number,
+ labels: newLabels
+ });
+ }
+ }
+
+ if (feedbackPoints.length > 0 && context.payload.action === 'opened') {
+ const commentBody = [
+ 'Thank you for opening an issue.',
+ '',
+ ...feedbackPoints,
+ '',
+ 'Issues flagged with `needs-info` are closed automatically after 7 days of inactivity.'
+ ].join('\n\n');
+
+ await github.rest.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: issue.number,
+ body: commentBody
+ });
+ }
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 0000000..ff4b6f0
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,31 @@
+name: Stale Issue Lifecycle
+
+on:
+ schedule:
+ - cron: "0 0 * * *"
+ workflow_dispatch:
+
+permissions:
+ issues: write
+
+jobs:
+ stale:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Close stale needs-info issues
+ uses: actions/stale@v9
+ with:
+ only-labels: "needs-info"
+ days-before-issue-stale: 7
+ days-before-issue-close: 2
+ stale-issue-label: "stale"
+ stale-issue-message: >
+ This issue has been marked as stale because it has been awaiting required
+ information for 7 days without a response. It will be closed in 2 days if
+ no update is provided.
+ close-issue-message: >
+ This issue was closed due to inactivity and missing reproduction details.
+ If the problem persists, please submit a new issue with complete reproduction steps.
+ exempt-issue-labels: "pinned,security"
+ days-before-pr-stale: -1
+ days-before-pr-close: -1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5daaf0..1a2af35 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Changelog
+## [Unreleased]
+
+### Added
+- **Automated Issue Quality, Version Validation, and Duplicate Management**:
+ - Modernized GitHub issue templates (`.github/ISSUE_TEMPLATE/`) with pre-submission checklists, target OS options (including Android Termux), and media player selector.
+ - Added `.github/workflows/incomplete-issue.yml` with semver release validation checking user versions against latest GitHub releases and printing platform upgrade commands.
+ - Implemented automated OS labeling (`os: android`, `os: linux`, `os: macos`, `os: windows`), title sanity validation, and Termux player setup guidance.
+ - Added automatic removal of `needs-info` and `stale` labels when the issue author provides responses.
+ - Added `.github/workflows/duplicate-detector.yml` using `actions-cool/issues-similarity` to flag and cross-reference duplicate issue submissions.
+ - Added `.github/workflows/stale.yml` to automatically close abandoned `needs-info` issues after 7 days of inactivity.
+
+### Fixed
+- **Update Modal Geometry & Symmetrical Border Padding**:
+ - Eliminated unnecessary dead vertical gap below action buttons in "Update Available" dialog by calculating exact rendered line heights (`update_modal_layout_with_env`) accounting for installation environment notices.
+ - Symmetrized vertical padding with balanced 1-row margins above the version header and below the action button row, eliminating bottom-heavy content displacement.
+ - Aligned inner horizontal margins to a uniform 2-column padding on both left and right borders, preventing premature right-side text truncation.
+ - Synchronized mouse click hitbox (`button_row_y`) with rendered action buttons across all package environments (DirectReplace, Homebrew, Termux, Flatpak, Snap).
+
## [0.1.20] - 2026-09-14
### Added
diff --git a/src/tui/app/run.rs b/src/tui/app/run.rs
index b0fc107..cd2feb5 100644
--- a/src/tui/app/run.rs
+++ b/src/tui/app/run.rs
@@ -1084,7 +1084,11 @@ impl App {
.map(|p| crate::updater::apply::detect_environment(&p))
.unwrap_or(crate::updater::apply::InstallationEnvironment::DirectReplace);
- let layout = crate::tui::overlay::update_modal_layout(area, notes);
+ let layout = crate::tui::overlay::update_modal_layout_with_env(
+ area,
+ notes,
+ env.has_managed_notice(),
+ );
let popup_area = layout.popup_area;
let display_count = layout.display_count;
let _ = layout.has_more;
@@ -1115,6 +1119,7 @@ impl App {
let divider_str = divider_char.repeat(inner_area.width as usize);
let mut text = vec![
+ Line::from(""),
Line::from(vec![
Span::styled("Installed: ", self.theme.text_dim),
Span::styled(
@@ -1203,94 +1208,110 @@ impl App {
]));
let basic = self.state.basic_terminal;
- for line in note_lines.iter().take(display_count) {
- let trimmed = line.trim();
- let mut spans = Vec::new();
+ if note_lines.is_empty() {
+ text.push(Line::from(vec![
+ Span::raw(" "),
+ Span::styled("No release notes provided.", self.theme.text_dim),
+ ]));
+ } else {
+ for line in note_lines.iter().take(display_count) {
+ let trimmed = line.trim();
+ let mut spans = Vec::new();
- if trimmed.starts_with("### ")
- || trimmed.starts_with("## ")
- || trimmed.starts_with("# ")
- {
- let title = trimmed.trim_start_matches('#').trim();
- spans.push(Span::raw(" "));
- if title.eq_ignore_ascii_case("Added") {
- spans.push(Span::styled(
- "[Added]",
- self.theme.teal.add_modifier(ratatui::style::Modifier::BOLD),
- ));
- } else if title.eq_ignore_ascii_case("Fixed") {
- spans.push(Span::styled(
- "[Fixed]",
- self.theme
- .rating
- .add_modifier(ratatui::style::Modifier::BOLD),
- ));
- } else if title.eq_ignore_ascii_case("Changed") {
- spans.push(Span::styled(
- "[Changed]",
- self.theme
- .sapphire
- .add_modifier(ratatui::style::Modifier::BOLD),
- ));
- } else if title.eq_ignore_ascii_case("Performance")
- || title.eq_ignore_ascii_case("Perf")
+ if trimmed.starts_with("### ")
+ || trimmed.starts_with("## ")
+ || trimmed.starts_with("# ")
{
- spans.push(Span::styled(
- "[Performance]",
- self.theme
- .accent
- .add_modifier(ratatui::style::Modifier::BOLD),
- ));
- } else if title.eq_ignore_ascii_case("Security") {
- spans.push(Span::styled(
- "[Security]",
- self.theme
- .error
- .add_modifier(ratatui::style::Modifier::BOLD),
- ));
- } else {
- spans.push(Span::styled(
- title,
- self.theme
- .highlight
- .add_modifier(ratatui::style::Modifier::BOLD),
- ));
- }
- } else if trimmed.starts_with("- ") || trimmed.starts_with("* ") {
- let bullet = trimmed[2..].trim();
- spans.push(Span::raw(" "));
- spans.push(Span::styled(
- if basic { "- " } else { "• " },
- self.theme.accent,
- ));
- if let Some(rest) = bullet.strip_prefix("**") {
- if let Some(end) = rest.find("**") {
- let title = &rest[..end];
- let after = &rest[end + 2..];
- let (colon, rest) = if let Some(stripped) = after.strip_prefix(':') {
- (": ", stripped.trim())
- } else {
- ("", after.trim())
- };
- let clean_rest = rest.replace('`', "");
+ let title = trimmed.trim_start_matches('#').trim();
+ spans.push(Span::raw(" "));
+ if title.eq_ignore_ascii_case("Added") {
+ spans.push(Span::styled(
+ "[Added]",
+ self.theme.teal.add_modifier(ratatui::style::Modifier::BOLD),
+ ));
+ } else if title.eq_ignore_ascii_case("Fixed") {
+ spans.push(Span::styled(
+ "[Fixed]",
+ self.theme
+ .rating
+ .add_modifier(ratatui::style::Modifier::BOLD),
+ ));
+ } else if title.eq_ignore_ascii_case("Changed") {
+ spans.push(Span::styled(
+ "[Changed]",
+ self.theme
+ .sapphire
+ .add_modifier(ratatui::style::Modifier::BOLD),
+ ));
+ } else if title.eq_ignore_ascii_case("Performance")
+ || title.eq_ignore_ascii_case("Perf")
+ {
+ spans.push(Span::styled(
+ "[Performance]",
+ self.theme
+ .accent
+ .add_modifier(ratatui::style::Modifier::BOLD),
+ ));
+ } else if title.eq_ignore_ascii_case("Security") {
+ spans.push(Span::styled(
+ "[Security]",
+ self.theme
+ .error
+ .add_modifier(ratatui::style::Modifier::BOLD),
+ ));
+ } else {
spans.push(Span::styled(
title,
- self.theme.text.add_modifier(ratatui::style::Modifier::BOLD),
+ self.theme
+ .highlight
+ .add_modifier(ratatui::style::Modifier::BOLD),
));
- if !colon.is_empty() {
- spans.push(Span::styled(colon, self.theme.subtext1));
- }
- if !clean_rest.is_empty() {
- let prefix_w = 4 + 2 + crate::tui::text::width(title) + colon.len();
- let budget =
- (inner_area.width as usize).saturating_sub(prefix_w + 2);
- if budget > 0 {
- spans.push(Span::styled(
- crate::tui::text::truncate_width(&clean_rest, budget)
- .into_owned(),
- self.theme.text_dim,
- ));
+ }
+ } else if trimmed.starts_with("- ") || trimmed.starts_with("* ") {
+ let bullet = trimmed[2..].trim();
+ spans.push(Span::raw(" "));
+ spans.push(Span::styled(
+ if basic { "- " } else { "• " },
+ self.theme.accent,
+ ));
+ if let Some(rest) = bullet.strip_prefix("**") {
+ if let Some(end) = rest.find("**") {
+ let title = &rest[..end];
+ let after = &rest[end + 2..];
+ let (colon, rest) = if let Some(stripped) = after.strip_prefix(':')
+ {
+ (": ", stripped.trim())
+ } else {
+ ("", after.trim())
+ };
+ let clean_rest = rest.replace('`', "");
+ spans.push(Span::styled(
+ title,
+ self.theme.text.add_modifier(ratatui::style::Modifier::BOLD),
+ ));
+ if !colon.is_empty() {
+ spans.push(Span::styled(colon, self.theme.subtext1));
+ }
+ if !clean_rest.is_empty() {
+ let prefix_w =
+ 4 + 2 + crate::tui::text::width(title) + colon.len();
+ let budget =
+ (inner_area.width as usize).saturating_sub(prefix_w + 2);
+ if budget > 0 {
+ spans.push(Span::styled(
+ crate::tui::text::truncate_width(&clean_rest, budget)
+ .into_owned(),
+ self.theme.text_dim,
+ ));
+ }
}
+ } else {
+ let clean = bullet.replace('`', "");
+ let budget = (inner_area.width as usize).saturating_sub(4 + 2 + 2);
+ spans.push(Span::styled(
+ crate::tui::text::truncate_width(&clean, budget).into_owned(),
+ self.theme.text,
+ ));
}
} else {
let clean = bullet.replace('`', "");
@@ -1301,23 +1322,16 @@ impl App {
));
}
} else {
- let clean = bullet.replace('`', "");
- let budget = (inner_area.width as usize).saturating_sub(4 + 2 + 2);
+ let clean = trimmed.replace('`', "");
+ let budget = (inner_area.width as usize).saturating_sub(4 + 2);
+ spans.push(Span::raw(" "));
spans.push(Span::styled(
crate::tui::text::truncate_width(&clean, budget).into_owned(),
- self.theme.text,
+ self.theme.text_dim,
));
}
- } else {
- let clean = trimmed.replace('`', "");
- let budget = (inner_area.width as usize).saturating_sub(4 + 2);
- spans.push(Span::raw(" "));
- spans.push(Span::styled(
- crate::tui::text::truncate_width(&clean, budget).into_owned(),
- self.theme.text_dim,
- ));
+ text.push(Line::from(spans));
}
- text.push(Line::from(spans));
}
text.push(Line::from(Span::styled(divider_str, self.theme.surface1)));
diff --git a/src/tui/overlay.rs b/src/tui/overlay.rs
index 97c55e9..7d22376 100644
--- a/src/tui/overlay.rs
+++ b/src/tui/overlay.rs
@@ -705,6 +705,18 @@ pub struct UpdateModalLayout {
}
pub fn update_modal_layout(area: Rect, notes: &str) -> UpdateModalLayout {
+ let has_managed_notice = std::env::current_exe()
+ .ok()
+ .map(|p| crate::updater::apply::detect_environment(&p).has_managed_notice())
+ .unwrap_or(false);
+ update_modal_layout_with_env(area, notes, has_managed_notice)
+}
+
+pub fn update_modal_layout_with_env(
+ area: Rect,
+ notes: &str,
+ has_managed_notice: bool,
+) -> UpdateModalLayout {
let note_lines_count = notes
.lines()
.map(|l| l.trim())
@@ -715,18 +727,19 @@ pub fn update_modal_layout(area: Rect, notes: &str) -> UpdateModalLayout {
&& !lower.contains("press [o]")
&& !lower.contains("press o to")
})
- .count();
+ .count()
+ .max(1);
let min_w: u16 = 50;
let max_w: u16 = 76;
let available_w = area.width.saturating_sub(4);
let desired_w = max_w.min(available_w).max(min_w.min(available_w));
- let header_rows: u16 = 3;
+ let header_rows: u16 = if has_managed_notice { 5 } else { 4 };
let footer_rows: u16 = 3;
let available_height = area.height.saturating_sub(4);
let available_note_rows =
- (available_height.saturating_sub(header_rows + footer_rows + 2) as usize).clamp(3, 16);
+ (available_height.saturating_sub(header_rows + footer_rows + 2) as usize).clamp(1, 16);
let display_count = note_lines_count.min(available_note_rows);
let has_more = note_lines_count > display_count;
@@ -775,10 +788,10 @@ mod tests {
assert_eq!(layout.popup_area.width, 76);
assert_eq!(layout.display_count, 4);
assert!(!layout.has_more);
- assert_eq!(layout.popup_area.height, 12);
+ assert_eq!(layout.popup_area.height, 13);
assert_eq!(layout.popup_area.x, (80 - 76) / 2);
- assert_eq!(layout.popup_area.y, (24 - 12) / 2);
- assert_eq!(layout.button_row_y, layout.popup_area.y + 9);
+ assert_eq!(layout.popup_area.y, (24 - 13) / 2);
+ assert_eq!(layout.button_row_y, layout.popup_area.y + 10);
let footer_start = layout.popup_area.x + 1 + (74 - 58) / 2;
assert_eq!(layout.update_btn_end_x, footer_start + 18);
assert_eq!(layout.open_btn_end_x, layout.update_btn_end_x + 26);
diff --git a/src/updater/apply.rs b/src/updater/apply.rs
index 1d68e3d..ffb9578 100644
--- a/src/updater/apply.rs
+++ b/src/updater/apply.rs
@@ -21,6 +21,12 @@ pub enum InstallationEnvironment {
WindowsHelper,
}
+impl InstallationEnvironment {
+ pub fn has_managed_notice(&self) -> bool {
+ !matches!(self, Self::DirectReplace | Self::WindowsHelper)
+ }
+}
+
pub fn detect_environment(exe_path: &Path) -> InstallationEnvironment {
if std::env::var_os("FLATPAK_ID").is_some() || Path::new("/.flatpak-info").exists() {
return InstallationEnvironment::Flatpak;
diff --git a/tests/update_lifecycle.rs b/tests/update_lifecycle.rs
index 02f0160..740b85c 100644
--- a/tests/update_lifecycle.rs
+++ b/tests/update_lifecycle.rs
@@ -426,9 +426,113 @@ async fn test_update_progress_message_tracking() {
"Downloading binary...".to_string(),
))
.await;
-
assert_eq!(
app.state().update_progress_msg.as_deref(),
Some("Downloading binary...")
);
}
+
+#[tokio::test]
+async fn test_update_modal_rendered_symmetry_and_exact_height() {
+ use ratatui::Terminal;
+ use ratatui::backend::TestBackend;
+
+ let mut app = App::new();
+ let notes = "### Highlights\n- Feature One\n- Feature Two\n- Feature Three";
+ app.state_mut().update_available = Some(("0.1.21".to_string(), notes.to_string()));
+
+ for (w, h) in [(80, 24), (85, 26), (120, 30)] {
+ let backend = TestBackend::new(w, h);
+ let mut terminal = Terminal::new(backend).unwrap();
+ terminal
+ .draw(|frame| {
+ app.draw(frame);
+ })
+ .unwrap();
+
+ let area = Rect::new(0, 0, w, h);
+ let layout = update_modal_layout(area, notes);
+ let buffer = terminal.backend().buffer();
+
+ let top_border_y = layout.popup_area.y;
+ let bottom_border_y = layout.popup_area.y + layout.popup_area.height - 1;
+
+ let top_cell = &buffer[(layout.popup_area.x, top_border_y)];
+ assert!(
+ top_cell.symbol() == "╭" || top_cell.symbol() == "+" || top_cell.symbol() == "┌",
+ "expected top corner, got {:?} at ({}, {}) in {}x{}",
+ top_cell.symbol(),
+ layout.popup_area.x,
+ top_border_y,
+ w,
+ h
+ );
+
+ let bottom_cell = &buffer[(layout.popup_area.x, bottom_border_y)];
+ assert!(
+ bottom_cell.symbol() == "╰"
+ || bottom_cell.symbol() == "+"
+ || bottom_cell.symbol() == "└",
+ "expected bottom corner, got {:?} at ({}, {}) in {}x{}",
+ bottom_cell.symbol(),
+ layout.popup_area.x,
+ bottom_border_y,
+ w,
+ h
+ );
+
+ let button_row = layout.button_row_y;
+ assert_eq!(button_row, bottom_border_y - 2);
+
+ let mut btn_line = String::new();
+ for x in layout.popup_area.x + 1..layout.popup_area.x + layout.popup_area.width - 1 {
+ btn_line.push(
+ buffer[(x, button_row)]
+ .symbol()
+ .chars()
+ .next()
+ .unwrap_or(' '),
+ );
+ }
+ assert!(btn_line.contains("[u] Update") || btn_line.contains("[b] Copy"));
+
+ let padding_below_buttons_y = bottom_border_y - 1;
+ let mut pad_bottom_line = String::new();
+ for x in layout.popup_area.x + 1..layout.popup_area.x + layout.popup_area.width - 1 {
+ pad_bottom_line.push(
+ buffer[(x, padding_below_buttons_y)]
+ .symbol()
+ .chars()
+ .next()
+ .unwrap_or(' '),
+ );
+ }
+ assert!(pad_bottom_line.trim().is_empty());
+
+ let padding_above_installed_y = top_border_y + 1;
+ let mut pad_top_line = String::new();
+ for x in layout.popup_area.x + 1..layout.popup_area.x + layout.popup_area.width - 1 {
+ pad_top_line.push(
+ buffer[(x, padding_above_installed_y)]
+ .symbol()
+ .chars()
+ .next()
+ .unwrap_or(' '),
+ );
+ }
+ assert!(pad_top_line.trim().is_empty());
+
+ let installed_y = top_border_y + 2;
+ let mut installed_line = String::new();
+ for x in layout.popup_area.x + 1..layout.popup_area.x + layout.popup_area.width - 1 {
+ installed_line.push(
+ buffer[(x, installed_y)]
+ .symbol()
+ .chars()
+ .next()
+ .unwrap_or(' '),
+ );
+ }
+ assert!(installed_line.contains("Installed:") && installed_line.contains("Latest:"));
+ }
+}