Skip to content

Commit dd883ea

Browse files
mobile & debug info fixups (#179)
1 parent 5b5e3e4 commit dd883ea

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

src/app/Flash.jsx

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const originalConsole = { log: console.log, warn: console.warn, error: console.e
5151
})
5252

5353
// Debug info component for error reporting
54-
function DebugInfo({ error, step, selectedDevice, serial, message }) {
54+
function DebugInfo({ error, step, selectedDevice, serial, message, onClose }) {
5555
const [copied, setCopied] = useState(false)
5656

5757
const getDebugReport = () => {
@@ -117,14 +117,27 @@ ${consoleLogs.slice(-30).map(l => `[${l.time}] [${l.level}] ${l.message}`).join(
117117
}
118118

119119
return (
120-
<div className="mt-6 w-full max-w-xl p-4 bg-gray-100 rounded-lg text-left text-sm">
121-
<p className="text-gray-600 mb-3">
122-
Copy this debug info and paste it in{' '}
123-
<a href="https://discord.comma.ai" target="_blank" rel="noopener noreferrer" className="text-blue-500 hover:underline">Discord</a>
124-
{' '}or{' '}
125-
<a href="https://github.com/commaai/flash/issues/new" target="_blank" rel="noopener noreferrer" className="text-blue-500 hover:underline">GitHub Issues</a>.
126-
</p>
127-
<pre className="bg-gray-900 text-gray-100 p-3 rounded text-xs overflow-auto max-h-48 font-mono debug-scrollbar">
120+
<div className="mt-6 w-full max-w-xl mx-4 p-4 bg-gray-100 rounded-lg text-left text-sm overflow-hidden">
121+
<div className="flex justify-between items-start mb-3 gap-2">
122+
<p className="text-gray-600 text-sm">
123+
Copy this debug info and paste it in{' '}
124+
<a href="https://discord.comma.ai" target="_blank" rel="noopener noreferrer" className="text-blue-500 hover:underline">Discord</a>
125+
{' '}or{' '}
126+
<a href="https://github.com/commaai/flash/issues/new" target="_blank" rel="noopener noreferrer" className="text-blue-500 hover:underline">GitHub Issues</a>.
127+
</p>
128+
{onClose && (
129+
<button
130+
onClick={onClose}
131+
className="text-gray-400 hover:text-gray-600 flex-shrink-0"
132+
title="Hide debug info"
133+
>
134+
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
135+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
136+
</svg>
137+
</button>
138+
)}
139+
</div>
140+
<pre className="bg-gray-900 text-gray-100 p-3 rounded text-xs overflow-x-auto max-h-32 sm:max-h-48 font-mono debug-scrollbar whitespace-pre-wrap break-all">
128141
{getDebugReport()}
129142
</pre>
130143
<button
@@ -604,6 +617,7 @@ export default function Flash() {
604617
const [message, setMessage] = useState('')
605618
const [progress, setProgress] = useState(-1)
606619
const [error, setError] = useState(ErrorCode.NONE)
620+
const [showDebugInfo, setShowDebugInfo] = useState(false)
607621
const [connected, setConnected] = useState(false)
608622
const [serial, setSerial] = useState(null)
609623
const [selectedDevice, setSelectedDevice] = useState(null)
@@ -785,6 +799,7 @@ export default function Flash() {
785799
<> If the problem persists, join <a href="https://discord.comma.ai" target="_blank" rel="noopener noreferrer" className="text-blue-500 hover:underline font-semibold">#{discordChannel}</a> on Discord for help.</>
786800
)
787801

802+
788803
let title
789804
if (message && !error) {
790805
title = message + '...'
@@ -808,7 +823,7 @@ export default function Flash() {
808823
const canGoBack = step === StepCode.CONNECTING && !connected
809824

810825
return (
811-
<div id="flash" className="wizard-screen relative flex flex-col gap-8 justify-center items-center h-full">
826+
<div id="flash" className="wizard-screen relative flex flex-col gap-8 justify-center items-center h-full pt-16 pb-12 overflow-y-auto overflow-x-hidden">
812827
{wizardStep >= 0 && (
813828
<Stepper
814829
steps={wizardSteps}
@@ -829,7 +844,17 @@ export default function Flash() {
829844
<LinearProgress value={progress * 100} barColor={bgColor} />
830845
</div>
831846
<span className="text-3xl font-mono font-light">{title}</span>
832-
<span className="text-xl px-8 max-w-xl text-center">{description}{discordLink}</span>
847+
<span className="text-xl px-8 max-w-xl text-center">
848+
{description}{discordLink}
849+
{error !== ErrorCode.NONE && hideRetry && !showDebugInfo && (
850+
<button
851+
onClick={() => setShowDebugInfo(true)}
852+
className="block mx-auto mt-2 text-sm text-gray-500 hover:text-gray-700 underline"
853+
>
854+
show debug info
855+
</button>
856+
)}
857+
</span>
833858
{error !== ErrorCode.NONE && !hideRetry && (
834859
<button
835860
className="px-8 py-3 text-xl font-semibold rounded-full bg-[#51ff00] hover:bg-[#45e000] active:bg-[#3acc00] text-black transition-colors"
@@ -839,8 +864,15 @@ export default function Flash() {
839864
</button>
840865
)}
841866
{connected && <DeviceState serial={serial} />}
842-
{error !== ErrorCode.NONE && (
843-
<DebugInfo error={error} step={step} selectedDevice={selectedDevice} serial={serial} message={message} />
867+
{error !== ErrorCode.NONE && (!hideRetry || showDebugInfo) && (
868+
<DebugInfo
869+
error={error}
870+
step={step}
871+
selectedDevice={selectedDevice}
872+
serial={serial}
873+
message={message}
874+
onClose={hideRetry ? () => setShowDebugInfo(false) : undefined}
875+
/>
844876
)}
845877
</div>
846878
)

0 commit comments

Comments
 (0)