feat(feedback): warn on long github issue urls (#140)

This commit is contained in:
Nexmoe
2026-01-17 12:52:30 +08:00
committed by GitHub
parent 4b561cef38
commit 73af211bef
14 changed files with 49 additions and 25 deletions

View File

@@ -3,6 +3,7 @@ import { ipcServices } from '@renderer/lib/ipc'
import { Github, MessageCircle, Twitter } from 'lucide-react' import { Github, MessageCircle, Twitter } from 'lucide-react'
import { type MouseEvent, useEffect, useMemo, useState } from 'react' import { type MouseEvent, useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
type AppInfo = { type AppInfo = {
appVersion: string appVersion: string
@@ -17,6 +18,7 @@ const FEEDBACK_UNKNOWN_VALUE = 'Unknown'
const FEEDBACK_SOURCE_LABEL = 'Source URL' const FEEDBACK_SOURCE_LABEL = 'Source URL'
const FEEDBACK_ERROR_LABEL = 'Error' const FEEDBACK_ERROR_LABEL = 'Error'
const FEEDBACK_COMMAND_LABEL = 'yt-dlp command' const FEEDBACK_COMMAND_LABEL = 'yt-dlp command'
const FEEDBACK_MAX_GITHUB_URL_LENGTH = 7000
let cachedAppInfo: AppInfo | null = null let cachedAppInfo: AppInfo | null = null
let appInfoPromise: Promise<AppInfo> | null = null let appInfoPromise: Promise<AppInfo> | null = null
@@ -140,21 +142,18 @@ export const FeedbackLinkButtons = ({
const tweetText = encodeURIComponent( const tweetText = encodeURIComponent(
tweetError ? `${tweetPrefix} - ${tweetError}` : tweetPrefix tweetError ? `${tweetPrefix} - ${tweetError}` : tweetPrefix
) )
const issueError = compactError ? clampText(compactError, 800) : FEEDBACK_UNKNOWN_ERROR const issueError = compactError || FEEDBACK_UNKNOWN_ERROR
const resolvedSourceUrl = sourceUrl?.trim() || undefined const resolvedSourceUrl = sourceUrl?.trim() || undefined
const normalizedCommand = ytDlpCommand?.trim() || undefined const normalizedCommand = ytDlpCommand?.trim() || undefined
const shouldIncludeLogs = Boolean(compactError || resolvedSourceUrl || normalizedCommand) const shouldIncludeLogs = Boolean(compactError || resolvedSourceUrl || normalizedCommand)
const issueLogs = shouldIncludeLogs const issueLogs = shouldIncludeLogs
? clampText( ? buildIssueLogs(
buildIssueLogs( issueError,
issueError, resolvedSourceUrl,
resolvedSourceUrl, normalizedCommand,
normalizedCommand, FEEDBACK_SOURCE_LABEL,
FEEDBACK_SOURCE_LABEL, FEEDBACK_ERROR_LABEL,
FEEDBACK_ERROR_LABEL, FEEDBACK_COMMAND_LABEL
FEEDBACK_COMMAND_LABEL
),
800
) )
: null : null
const appVersionValue = appVersion ? `VidBee v${appVersion}` : FEEDBACK_UNKNOWN_VALUE const appVersionValue = appVersion ? `VidBee v${appVersion}` : FEEDBACK_UNKNOWN_VALUE
@@ -209,6 +208,13 @@ export const FeedbackLinkButtons = ({
useSimpleGithubUrl useSimpleGithubUrl
]) ])
const handleLinkClick = (event: MouseEvent<HTMLAnchorElement>, href: string) => {
if (href.startsWith('https://github.com') && href.length >= FEEDBACK_MAX_GITHUB_URL_LENGTH) {
toast.info(t('download.feedback.githubUrlTooLong'))
}
onLinkClick?.(event)
}
return ( return (
<> <>
{links.map((resource) => { {links.map((resource) => {
@@ -221,7 +227,12 @@ export const FeedbackLinkButtons = ({
className={buttonClassName} className={buttonClassName}
asChild asChild
> >
<a href={resource.href} target="_blank" rel="noreferrer" onClick={onLinkClick}> <a
href={resource.href}
target="_blank"
rel="noreferrer"
onClick={(event) => handleLinkClick(event, resource.href)}
>
<Icon className={iconClassName} /> <Icon className={iconClassName} />
{resource.label} {resource.label}
</a> </a>

View File

@@ -197,7 +197,8 @@
"subscription": "الاشتراك" "subscription": "الاشتراك"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "رابط GitHub هذا طويل جدًا. إذا لم يفتح، فالرجاء فتح صفحة المشكلة ولصق السجلات يدويًا."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "Abonnement" "subscription": "Abonnement"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Dieser GitHub-Link ist sehr lang. Wenn er sich nicht öffnet, öffnen Sie bitte die Issue-Seite und fügen Sie die Logs manuell ein."
} }
}, },
"error": { "error": {

View File

@@ -131,7 +131,8 @@
"fetch": "Fetch", "fetch": "Fetch",
"fetchingVideoInfo": "Fetching video info...", "fetchingVideoInfo": "Fetching video info...",
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "This GitHub link is very long. If it fails to open, please open the issue page and paste the logs manually."
}, },
"history": "History", "history": "History",
"imageLoadError": "Image failed to load", "imageLoadError": "Image failed to load",

View File

@@ -197,7 +197,8 @@
"subscription": "Suscripción" "subscription": "Suscripción"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Este enlace de GitHub es muy largo. Si no se abre, abre la página de la incidencia y pega los registros manualmente."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "Abonnement" "subscription": "Abonnement"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Ce lien GitHub est très long. S'il ne s'ouvre pas, ouvrez la page de l'issue et collez les logs manuellement."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "Berlangganan" "subscription": "Berlangganan"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Tautan GitHub ini sangat panjang. Jika tidak terbuka, buka halaman issue dan tempel log secara manual."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "Sottoscrizione" "subscription": "Sottoscrizione"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Questo link GitHub è molto lungo. Se non si apre, apri la pagina dell'issue e incolla i log manualmente."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "サブスクリプション" "subscription": "サブスクリプション"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "このGitHubリンクは非常に長いです。開けない場合は、issueページを開いてログを手動で貼り付けてください。"
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "신청" "subscription": "신청"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "이 GitHub 링크가 매우 깁니다. 열리지 않으면 이슈 페이지를 열고 로그를 수동으로 붙여 넣어 주세요."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "Subscrição" "subscription": "Subscrição"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Este link do GitHub é muito longo. Se não abrir, abra a página da issue e cole os logs manualmente."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "Подписка" "subscription": "Подписка"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "Эта ссылка GitHub очень длинная. Если она не открывается, откройте страницу issue и вставьте логи вручную."
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "訂閱" "subscription": "訂閱"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "這個 GitHub 連結很長。如果無法開啟,請開啟 issue 頁面並手動貼上日誌。"
} }
}, },
"error": { "error": {

View File

@@ -197,7 +197,8 @@
"subscription": "订阅" "subscription": "订阅"
}, },
"feedback": { "feedback": {
"title": "Report this error:" "title": "Report this error:",
"githubUrlTooLong": "这个 GitHub 链接很长。如果无法打开,请打开 issue 页面并手动粘贴日志。"
} }
}, },
"error": { "error": {