feat: remove the debug window since log files are too large to render effectively

lets just save to the users computer so that they can view it themselves
pull/3145/head
yougotwill 8 months ago
parent e22d044913
commit 01948b9088

@ -1,28 +0,0 @@
<html>
<head>
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
child-src 'self';
connect-src 'self' https: wss:;
font-src 'self';
form-action 'self';
frame-src 'none';
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline';"
/>
<!-- Load first to prevent font swapping on start -->
<link href="stylesheets/fonts.css" rel="stylesheet" type="text/css" />
<link href="stylesheets/dist/manifest.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="root"></div>
</body>
<script type="text/javascript">
require('./ts/mains/debug_log_start.js');
</script>
</html>

@ -1,35 +0,0 @@
/* global window */
/* eslint-disable @typescript-eslint/no-var-requires */
const { ipcRenderer } = require('electron');
const url = require('url');
const os = require('os');
const i18n = require('./ts/util/i18n');
const config = url.parse(window.location.toString(), true).query;
const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data');
window._ = require('lodash');
window.getVersion = () => config.version;
window.theme = config.theme;
window.i18n = i18n.setupi18n(locale, localeMessages);
// got.js appears to need this to successfully submit debug logs to the cloud
window.nodeSetImmediate = setImmediate;
window.getNodeVersion = () => config.node_version;
window.getEnvironment = () => config.environment;
require('./ts/util/logging');
window.getOSRelease = () =>
`${os.type()} ${os.release()}, Node.js ${config.node_version} ${os.platform()} ${os.arch()}`;
window.getCommitHash = () => config.commitHash;
window.closeDebugLog = () => ipcRenderer.send('close-debug-log');
window.saveLog = logText => ipcRenderer.send('save-debug-log', logText);

@ -295,7 +295,6 @@
"background.html",
"about.html",
"password.html",
"debug_log.html",
"_locales/**",
"mnemonic_languages/**",
"protos/*",
@ -309,7 +308,6 @@
"preload.js",
"about_preload.js",
"settings_preload.js",
"debug_log_preload.js",
"password_preload.js",
"images/**",
"fonts/*",

@ -1,128 +0,0 @@
import { useEffect, useState } from 'react';
import styled from 'styled-components';
import { SessionTheme } from '../themes/SessionTheme';
import { switchThemeTo } from '../themes/switchTheme';
import { fetchNodeLog } from '../util/logging';
import { SessionButton, SessionButtonType } from './basic/SessionButton';
import { SessionIconButton } from './icon';
const StyledContent = styled.div`
background-color: var(--modal-background-content-color);
color: var(--modal-text-color);
font-family: var(--font-default);
display: flex;
flex-direction: column;
padding: 20px;
height: 100%;
.session-button {
margin: 1rem auto 1rem 0;
padding: 1rem;
width: fit-content;
}
.session-icon-button {
float: right;
}
h1 {
color: var(--modal-text-color);
}
textarea {
flex-grow: 1;
width: 100%;
box-sizing: border-box;
padding: var(--margins-md);
background-color: var(--input-background-color);
color: var(--input-text-color);
border: 2px solid var(--border-color);
border-radius: 4px;
resize: none;
min-height: 100px;
font-family: var(--font-debug);
font-size: 12px;
line-height: 18px;
}
`;
const DebugLogTextArea = (props: { content: string }) => {
return <textarea spellCheck="false" rows={10} value={props.content} style={{ height: '100%' }} />;
};
const DebugLogButtons = (props: { content: string }) => {
return (
<div className="buttons">
<SessionButton
text={window.i18n('saveLogToDesktop')}
buttonType={SessionButtonType.Simple}
onClick={() => {
if (props.content.length <= 20) {
// loading
return;
}
(window as any).saveLog(props.content);
}}
/>
</div>
);
};
const DebugLogViewAndSave = () => {
const [content, setContent] = useState(window.i18n('loading'));
useEffect(() => {
const operatingSystemInfo = `Operating System ${window.getOSRelease()}`;
const commitHashInfo = window.getCommitHash() ? `Commit ${window.getCommitHash()}` : '';
// eslint-disable-next-line more/no-then
fetchNodeLog()
.then((text: any) => {
const debugLogWithSystemInfo = `${operatingSystemInfo} ${commitHashInfo} ${text}`;
setContent(debugLogWithSystemInfo);
})
// eslint-disable-next-line no-console
.catch(console.error);
}, []);
return (
<>
<DebugLogTextArea content={content} />
<DebugLogButtons content={content} />
</>
);
};
export const DebugLogView = () => {
useEffect(() => {
if (window.theme) {
void switchThemeTo({
theme: window.theme,
usePrimaryColor: true,
});
}
}, []);
return (
<SessionTheme>
<StyledContent>
<div>
<SessionIconButton
aria-label="close debug log"
iconType="exit"
iconSize="medium"
onClick={() => {
window.closeDebugLog();
}}
/>
<h1> {window.i18n('debugLog')} </h1>
<p> {window.i18n('debugLogExplanation')}</p>
</div>
<DebugLogViewAndSave />
</StyledContent>
</SessionTheme>
);
};

@ -1,6 +0,0 @@
import { createRoot } from 'react-dom/client';
import { DebugLogView } from '../components/DebugLogView';
const container = document.getElementById('root');
const root = createRoot(container!);
root.render(<DebugLogView />);

@ -648,62 +648,13 @@ async function showAbout() {
aboutWindow?.show();
}
let debugLogWindow: BrowserWindow | null = null;
async function showDebugLogWindow() {
if (debugLogWindow) {
debugLogWindow.show();
return;
}
if (!mainWindow) {
console.info('debug log needs mainwindow size to open');
return;
}
const theme = await getThemeFromMainWindow();
const size = mainWindow.getSize();
const options = {
width: Math.max(size[0] - 100, getDefaultWindowSize().minWidth),
height: Math.max(size[1] - 100, getDefaultWindowSize().minHeight),
resizable: true,
title: locale.messages.debugLog,
autoHideMenuBar: true,
backgroundColor: classicDark['--background-primary-color'],
shadow: true,
show: false,
modal: true,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: path.join(getAppRootPath(), 'debug_log_preload.js'),
nativeWindowOpen: true,
},
parent: mainWindow,
};
debugLogWindow = new BrowserWindow(options);
captureClicks(debugLogWindow);
await debugLogWindow.loadURL(prepareURL([getAppRootPath(), 'debug_log.html'], { theme }));
debugLogWindow.on('closed', () => {
debugLogWindow = null;
});
debugLogWindow.once('ready-to-show', () => {
debugLogWindow?.setBackgroundColor(classicDark['--background-primary-color']);
});
// see above: looks like sometimes ready-to-show is not fired by electron
debugLogWindow?.show();
}
async function saveDebugLog(_event: any, logText: any) {
const options: Electron.SaveDialogOptions = {
title: 'Save debug log',
defaultPath: path.join(app.getPath('desktop'), `session_debug_${Date.now()}.txt`),
defaultPath: path.join(
app.getPath('desktop'),
`session_debug_${new Date().toISOString().replace(/:/g, '_')}.txt`
),
properties: ['createDirectory'],
};
@ -840,7 +791,6 @@ function setupMenu() {
const { platform } = process;
const menuOptions = {
development,
showDebugLog: showDebugLogWindow,
showWindow,
showAbout,
openReleaseNotes,
@ -1080,13 +1030,6 @@ ipc.on('set-password', async (event, passPhrase, oldPhrase) => {
});
// Debug Log-related IPC calls
ipc.on('show-debug-log', showDebugLogWindow);
ipc.on('close-debug-log', () => {
if (debugLogWindow) {
debugLogWindow.close();
}
});
ipc.on('save-debug-log', saveDebugLog);
ipc.on('load-maxmind-data', async (event: IpcMainEvent) => {
try {

@ -7,7 +7,6 @@ export const createTemplate = (
openSupportPage: () => void;
platform: string;
showAbout: () => void;
showDebugLog: () => void;
showWindow: () => void;
},
messages: LocaleMessagesType
@ -16,8 +15,7 @@ export const createTemplate = (
throw new TypeError('`options.platform` must be a string');
}
const { openReleaseNotes, openSupportPage, platform, showAbout, showDebugLog, showWindow } =
options;
const { openReleaseNotes, openSupportPage, platform, showAbout, showWindow } = options;
const template = [
{
@ -94,13 +92,6 @@ export const createTemplate = (
{
type: 'separator',
},
{
label: messages.debugLog,
click: showDebugLog,
},
{
type: 'separator',
},
{
role: 'toggledevtools',
label: messages.viewMenuToggleDevTools,
@ -125,9 +116,6 @@ export const createTemplate = (
label: messages.goToReleaseNotes,
click: openReleaseNotes,
},
{
type: 'separator',
},
{
label: messages.goToSupportPage,
click: openSupportPage,

@ -21,7 +21,6 @@ type ThemeGlobals = {
'--font-default': string;
'--font-accent': string;
'--font-mono': string;
'--font-debug': string;
'--font-size-xl': string;
'--font-size-lg': string;
@ -160,7 +159,6 @@ export const THEME_GLOBALS: ThemeGlobals = {
'--font-default': 'Roboto',
'--font-accent': 'Loor',
'--font-mono': 'SpaceMono',
'--font-debug': "Monaco, Consolas, 'Courier New', Courier, monospace",
'--font-size-xl': '19px',
'--font-size-lg': '17px',

Loading…
Cancel
Save