Kcl in coredump (#3434)
* add kcl code to coredump Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix ts Signed-off-by: Jess Frazelle <github@jessfraz.com> * new images Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
@ -13,7 +13,7 @@ import { PATHS } from 'lib/paths'
|
||||
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||
import { onboardingPaths } from 'routes/Onboarding/paths'
|
||||
import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions'
|
||||
import { engineCommandManager } from 'lib/singletons'
|
||||
import { codeManager, engineCommandManager } from 'lib/singletons'
|
||||
import { useModelingContext } from 'hooks/useModelingContext'
|
||||
import { useAbsoluteFilePath } from 'hooks/useAbsoluteFilePath'
|
||||
import { isTauri } from 'lib/isTauri'
|
||||
@ -50,7 +50,7 @@ export function App() {
|
||||
const token = auth?.context?.token
|
||||
|
||||
const coreDumpManager = useMemo(
|
||||
() => new CoreDumpManager(engineCommandManager, token),
|
||||
() => new CoreDumpManager(engineCommandManager, codeManager, token),
|
||||
[]
|
||||
)
|
||||
|
||||
|
@ -34,7 +34,7 @@ import { KclContextProvider } from 'lang/KclProvider'
|
||||
import { BROWSER_PROJECT_NAME } from 'lib/constants'
|
||||
import { getState, setState } from 'lib/tauri'
|
||||
import { CoreDumpManager } from 'lib/coredump'
|
||||
import { engineCommandManager } from 'lib/singletons'
|
||||
import { codeManager, engineCommandManager } from 'lib/singletons'
|
||||
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
|
||||
import useHotkeyWrapper from 'lib/hotkeyWrapper'
|
||||
import toast from 'react-hot-toast'
|
||||
@ -181,7 +181,7 @@ function CoreDump() {
|
||||
const { auth } = useSettingsAuthContext()
|
||||
const token = auth?.context?.token
|
||||
const coreDumpManager = useMemo(
|
||||
() => new CoreDumpManager(engineCommandManager, token),
|
||||
() => new CoreDumpManager(engineCommandManager, codeManager, token),
|
||||
[]
|
||||
)
|
||||
useHotkeyWrapper(['meta + shift + .'], () => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { coreDump } from 'lang/wasm'
|
||||
import { CoreDumpManager } from 'lib/coredump'
|
||||
import { CustomIcon } from './CustomIcon'
|
||||
import { engineCommandManager } from 'lib/singletons'
|
||||
import { codeManager, engineCommandManager } from 'lib/singletons'
|
||||
import React, { useMemo } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import Tooltip from './Tooltip'
|
||||
@ -11,7 +11,7 @@ export const RefreshButton = ({ children }: React.PropsWithChildren) => {
|
||||
const { auth } = useSettingsAuthContext()
|
||||
const token = auth?.context?.token
|
||||
const coreDumpManager = useMemo(
|
||||
() => new CoreDumpManager(engineCommandManager, token),
|
||||
() => new CoreDumpManager(engineCommandManager, codeManager, token),
|
||||
[]
|
||||
)
|
||||
|
||||
|
@ -11,6 +11,7 @@ import { APP_VERSION } from 'routes/Settings'
|
||||
import { UAParser } from 'ua-parser-js'
|
||||
import screenshot from 'lib/screenshot'
|
||||
import { VITE_KC_API_BASE_URL } from 'env'
|
||||
import CodeManager from 'lang/codeManager'
|
||||
|
||||
/* eslint-disable suggest-no-throw/suggest-no-throw --
|
||||
* All the throws in CoreDumpManager are intentional and should be caught and handled properly
|
||||
@ -32,14 +33,17 @@ import { VITE_KC_API_BASE_URL } from 'env'
|
||||
// TODO: Throw more
|
||||
export class CoreDumpManager {
|
||||
engineCommandManager: EngineCommandManager
|
||||
codeManager: CodeManager
|
||||
token: string | undefined
|
||||
baseUrl: string = VITE_KC_API_BASE_URL
|
||||
|
||||
constructor(
|
||||
engineCommandManager: EngineCommandManager,
|
||||
codeManager: CodeManager,
|
||||
token: string | undefined
|
||||
) {
|
||||
this.engineCommandManager = engineCommandManager
|
||||
this.codeManager = codeManager
|
||||
this.token = token
|
||||
}
|
||||
|
||||
@ -61,6 +65,10 @@ export class CoreDumpManager {
|
||||
return APP_VERSION
|
||||
}
|
||||
|
||||
kclCode(): string {
|
||||
return this.codeManager.code
|
||||
}
|
||||
|
||||
// Get the backend pool we've requested.
|
||||
pool(): string {
|
||||
return this.engineCommandManager.settings.pool || ''
|
||||
|
@ -34,6 +34,10 @@ impl CoreDump for CoreDumper {
|
||||
Ok(env!("CARGO_PKG_VERSION").to_string())
|
||||
}
|
||||
|
||||
fn kcl_code(&self) -> Result<String> {
|
||||
Ok("".to_owned())
|
||||
}
|
||||
|
||||
fn pool(&self) -> Result<String> {
|
||||
Ok("".to_owned())
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ pub trait CoreDump: Clone {
|
||||
|
||||
fn version(&self) -> Result<String>;
|
||||
|
||||
fn kcl_code(&self) -> Result<String>;
|
||||
|
||||
fn pool(&self) -> Result<String>;
|
||||
|
||||
async fn os(&self) -> Result<OsInfo>;
|
||||
@ -82,6 +84,7 @@ pub trait CoreDump: Clone {
|
||||
git_rev: git_rev::try_revision_string!().map_or_else(|| "unknown".to_string(), |s| s.to_string()),
|
||||
timestamp: chrono::Utc::now(),
|
||||
tauri: self.is_tauri()?,
|
||||
kcl_code: self.kcl_code()?,
|
||||
os,
|
||||
webrtc_stats,
|
||||
github_issue_url: None,
|
||||
@ -140,6 +143,8 @@ pub struct CoreDumpInfo {
|
||||
/// A GitHub issue url to report the core dump.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub github_issue_url: Option<String>,
|
||||
/// The kcl code the user is using.
|
||||
pub kcl_code: String,
|
||||
/// Engine pool the client is connected to.
|
||||
pub pool: String,
|
||||
/// The client state (singletons and xstate).
|
||||
@ -152,7 +157,7 @@ impl CoreDumpInfo {
|
||||
let coredump_filename = Path::new(coredump_url).file_name().unwrap().to_str().unwrap();
|
||||
let tauri_or_browser_label = if self.tauri { "tauri" } else { "browser" };
|
||||
let labels = ["coredump", "bug", tauri_or_browser_label];
|
||||
let body = format!(
|
||||
let mut body = format!(
|
||||
r#"[Add a title above and insert a description of the issue here]
|
||||
|
||||

|
||||
@ -166,6 +171,23 @@ Reference ID: {coredump_id}
|
||||
</details>
|
||||
"#
|
||||
);
|
||||
|
||||
// Add the kcl code if it exists.
|
||||
if !self.kcl_code.trim().is_empty() {
|
||||
body.push_str(&format!(
|
||||
r#"
|
||||
<details>
|
||||
<summary><b>KCL Code</b></summary>
|
||||
|
||||
```kcl
|
||||
{}
|
||||
```
|
||||
</details>
|
||||
"#,
|
||||
self.kcl_code
|
||||
));
|
||||
}
|
||||
|
||||
let urlencoded: String = form_urlencoded::byte_serialize(body.as_bytes()).collect();
|
||||
|
||||
// Note that `github_issue_url` is not included in the coredump file.
|
||||
|
@ -23,6 +23,9 @@ extern "C" {
|
||||
#[wasm_bindgen(method, js_name = version, catch)]
|
||||
fn version(this: &CoreDumpManager) -> Result<String, js_sys::Error>;
|
||||
|
||||
#[wasm_bindgen(method, js_name = kclCode, catch)]
|
||||
fn kcl_code(this: &CoreDumpManager) -> Result<String, js_sys::Error>;
|
||||
|
||||
#[wasm_bindgen(method, js_name = getOsInfo, catch)]
|
||||
fn get_os_info(this: &CoreDumpManager) -> Result<js_sys::Promise, js_sys::Error>;
|
||||
|
||||
@ -73,6 +76,12 @@ impl CoreDump for CoreDumper {
|
||||
.map_err(|e| anyhow::anyhow!("Failed to get response from version: {:?}", e))
|
||||
}
|
||||
|
||||
fn kcl_code(&self) -> Result<String> {
|
||||
self.manager
|
||||
.kcl_code()
|
||||
.map_err(|e| anyhow::anyhow!("Failed to get response from kcl code: {:?}", e))
|
||||
}
|
||||
|
||||
fn pool(&self) -> Result<String> {
|
||||
self.manager
|
||||
.pool()
|
||||
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 19 KiB |