Skip to content

Commit

Permalink
Send telemetry (#1702)
Browse files Browse the repository at this point in the history
* restart on auth

Signed-off-by: Jess Frazelle <[email protected]>

* fix deps

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* fix

Signed-off-by: Jess Frazelle <[email protected]>

* hash the iuser

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* add comment;

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* zip up the contents

Signed-off-by: Jess Frazelle <[email protected]>

* fix logic

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* add tests

Signed-off-by: Jess Frazelle <[email protected]>

* more code coverage

Signed-off-by: Jess Frazelle <[email protected]>

* u[dates

Signed-off-by: Jess Frazelle <[email protected]>

* u[dates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* fixes

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* up[dates

Signed-off-by: Jess Frazelle <[email protected]>

* more tests

Signed-off-by: Jess Frazelle <[email protected]>

* more coverage

Signed-off-by: Jess Frazelle <[email protected]>

* more coverage

Signed-off-by: Jess Frazelle <[email protected]>

* add tests

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* updates

Signed-off-by: Jess Frazelle <[email protected]>

* more tests

Signed-off-by: Jess Frazelle <[email protected]>

* cleanup dead code

Signed-off-by: Jess Frazelle <[email protected]>

* start of accept / reject

Signed-off-by: Jess Frazelle <[email protected]>

* accept/reject

Signed-off-by: Jess Frazelle <[email protected]>

* cleanup

Signed-off-by: Jess Frazelle <[email protected]>

---------

Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz authored Mar 13, 2024
1 parent dfc51e6 commit 2d979b5
Show file tree
Hide file tree
Showing 17 changed files with 1,723 additions and 152 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/cargo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ jobs:
shell: bash
run: |-
cd "${{ matrix.dir }}"
cargo nextest run --workspace --no-fail-fast -P ci 2>&1 | tee /tmp/github-actions.log
cargo llvm-cov nextest --all --lcov --output-path lcov.info --test-threads=1 --no-fail-fast -P ci 2>&1 | tee /tmp/github-actions.log
env:
KITTYCAD_API_TOKEN: ${{secrets.KITTYCAD_API_TOKEN}}
RUST_MIN_STACK: 10485760000
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true
flags: wasm-lib
verbose: true
files: lcov.info

6 changes: 4 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ export function App() {
const filePath = useAbsoluteFilePath()
const { onProjectOpen } = useLspContext()

const projectName = project?.name || null
const projectPath = project?.path || null
useEffect(() => {
onProjectOpen(project || null, file || null)
}, [])
onProjectOpen({ name: projectName, path: projectPath }, file || null)
}, [projectName, projectPath])

useHotKeyListener()
const {
Expand Down
12 changes: 5 additions & 7 deletions src/components/LspProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { LanguageSupport } from '@codemirror/language'
import { useNavigate } from 'react-router-dom'
import { paths } from 'lib/paths'
import { FileEntry } from '@tauri-apps/api/fs'
import { ProjectWithEntryPointMetadata } from 'lib/types'

const DEFAULT_FILE_NAME: string = 'main.kcl'

Expand All @@ -40,7 +39,7 @@ type LspContext = {
redirect: boolean
) => void
onProjectOpen: (
project: ProjectWithEntryPointMetadata | null,
project: { name: string | null; path: string | null } | null,
file: FileEntry | null
) => void
onFileOpen: (filePath: string | null, projectPath: string | null) => void
Expand Down Expand Up @@ -69,6 +68,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
}))

const { auth } = useSettingsAuthContext()
const token = auth?.context?.token
const navigate = useNavigate()

// So this is a bit weird, we need to initialize the lsp server and client.
Expand All @@ -80,15 +80,14 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
const client = new Client(fromServer, intoServer)
if (!TEST) {
Server.initialize(intoServer, fromServer).then((lspServer) => {
const token = auth?.context?.token
lspServer.start('kcl', token)
setIsKclLspServerReady(true)
})
}

const lspClient = new LanguageServerClient({ client, name: 'kcl' })
return { lspClient }
}, [setIsKclLspServerReady])
}, [setIsKclLspServerReady, token])

// Here we initialize the plugin which will start the client.
// Now that we have multi-file support the name of the file is a dep of
Expand Down Expand Up @@ -116,15 +115,14 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
const client = new Client(fromServer, intoServer)
if (!TEST) {
Server.initialize(intoServer, fromServer).then((lspServer) => {
const token = auth?.context?.token
lspServer.start('copilot', token)
setIsCopilotLspServerReady(true)
})
}

const lspClient = new LanguageServerClient({ client, name: 'copilot' })
return { lspClient }
}, [setIsCopilotLspServerReady])
}, [setIsCopilotLspServerReady, token])

// Here we initialize the plugin which will start the client.
// When we have multi-file support the name of the file will be a dep of
Expand Down Expand Up @@ -172,7 +170,7 @@ export const LspProvider = ({ children }: { children: React.ReactNode }) => {
}

const onProjectOpen = (
project: ProjectWithEntryPointMetadata | null,
project: { name: string | null; path: string | null } | null,
file: FileEntry | null
) => {
const projectName = project?.name || 'ProjectRoot'
Expand Down
69 changes: 6 additions & 63 deletions src/editor/plugins/lsp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,10 @@ import type * as LSP from 'vscode-languageserver-protocol'
import Client from './client'
import { SemanticToken, deserializeTokens } from './kcl/semantic_tokens'
import { LanguageServerPlugin } from 'editor/plugins/lsp/plugin'

export interface CopilotGetCompletionsParams {
doc: {
source: string
tabSize: number
indentSize: number
insertSpaces: boolean
path: string
uri: string
relativePath: string
languageId: string
position: {
line: number
character: number
}
}
}

interface CopilotGetCompletionsResult {
completions: {
text: string
position: {
line: number
character: number
}
uuid: string
range: {
start: {
line: number
character: number
}
end: {
line: number
character: number
}
}
displayText: string
point: {
line: number
character: number
}
region: {
start: {
line: number
character: number
}
end: {
line: number
character: number
}
}
}[]
}

interface CopilotAcceptCompletionParams {
uuid: string
}

interface CopilotRejectCompletionParams {
uuids: string[]
}
import { CopilotLspCompletionParams } from 'wasm-lib/kcl/bindings/CopilotLspCompletionParams'
import { CopilotCompletionResponse } from 'wasm-lib/kcl/bindings/CopilotCompletionResponse'
import { CopilotAcceptCompletionParams } from 'wasm-lib/kcl/bindings/CopilotAcceptCompletionParams'
import { CopilotRejectCompletionParams } from 'wasm-lib/kcl/bindings/CopilotRejectCompletionParams'

// https://microsoft.github.io/language-server-protocol/specifications/specification-current/

Expand All @@ -78,7 +21,7 @@ interface LSPRequestMap {
LSP.SemanticTokensParams,
LSP.SemanticTokens
]
getCompletions: [CopilotGetCompletionsParams, CopilotGetCompletionsResult]
getCompletions: [CopilotLspCompletionParams, CopilotCompletionResponse]
notifyAccepted: [CopilotAcceptCompletionParams, any]
notifyRejected: [CopilotRejectCompletionParams, any]
}
Expand Down Expand Up @@ -271,7 +214,7 @@ export class LanguageServerClient {
return this.client.notify(method, params)
}

async getCompletion(params: CopilotGetCompletionsParams) {
async getCompletion(params: CopilotLspCompletionParams) {
const response = await this.request('getCompletions', params)
//
this.queuedUids = [...response.completions.map((c) => c.uuid)]
Expand Down
16 changes: 11 additions & 5 deletions src/routes/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { homeCommandBarConfig } from 'lib/commandBarConfigs/homeCommandConfig'
import { useHotkeys } from 'react-hotkeys-hook'
import { isTauri } from 'lib/isTauri'
import { kclManager } from 'lang/KclSingleton'
import { useLspContext } from 'components/LspProvider'

// This route only opens in the Tauri desktop context for now,
// as defined in Router.tsx, so we can use the Tauri APIs and types.
Expand All @@ -51,6 +52,7 @@ const Home = () => {
send: sendToSettings,
},
} = useSettingsAuthContext()
const { onProjectOpen } = useLspContext()

// Set the default directory if it's been updated
// during the loading of the home page. This is wrapped
Expand Down Expand Up @@ -84,12 +86,16 @@ const Home = () => {
event: EventFrom<typeof homeMachine>
) => {
if (event.data && 'name' in event.data) {
commandBarSend({ type: 'Close' })
navigate(
`${paths.FILE}/${encodeURIComponent(
context.defaultDirectory + sep + event.data.name
)}`
let projectPath = context.defaultDirectory + sep + event.data.name
onProjectOpen(
{
name: event.data.name,
path: projectPath,
},
null
)
commandBarSend({ type: 'Close' })
navigate(`${paths.FILE}/${encodeURIComponent(projectPath)}`)
}
},
toastSuccess: (_, event) => toast.success((event.data || '') + ''),
Expand Down
38 changes: 27 additions & 11 deletions src/wasm-lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/wasm-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ members = [
]

[workspace.dependencies]
kittycad = { version = "0.2.59", default-features = false, features = ["js", "requests"] }
kittycad = { version = "0.2.60", default-features = false, features = ["js", "requests"] }
kittycad-execution-plan = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" }
kittycad-execution-plan-macros = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" }
kittycad-execution-plan-traits = { git = "https://github.com/KittyCAD/modeling-api", branch = "main" }
Expand Down
Loading

0 comments on commit 2d979b5

Please sign in to comment.