Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/book/src/misc/environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ for many of the flags, we expect "1" to enable them
1. `CODETRACER_SHELL_ADDRESS` - this sets the address for sending events to the CI integration from `ct record`(or eventually `ct shell`)
1. `CODETRACER_SHELL_EXPORT` - this enables export mode for `ct record` on: exporting the traces into zip files in the folder that is the value of this env variables; (similarly to the `ct record -e=<zippath>` option, but for all records while the variable is enabled). The trace archives try to use a globally unique id in their filenames, from `std/oids` in the nim stdlib: https://nim-lang.org/docs/oids.html
1. `CODETRACER_DEBUG_CURL` - if "1", print debug output for the raw objects sent with curl for the CI integration from `ct record`(or eventually `ct shell`)
1. `CODETRACER_DEBUG_CT_REMOTE` - if "1", print debug output(for now process command name and arguments) for the trace sharing code and commands that call `ct-remote`(desktopclient), e.g. `ct upload`, `ct download`, `ct login`, `ct set-default-org`

## CodeTracer Shell
These are generally not functional right now, since they affect CodeTracer Shell, which is currently not stable/in very prototypical state:
Expand Down
4 changes: 2 additions & 2 deletions nix/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@

ctRemote = stdenv.mkDerivation rec {
pname = "ct-remote";
version = "102d2c8";
version = "83d7053";

src = pkgs.fetchurl {
url =
"https://downloads.codetracer.com/DesktopClient.App/DesktopClient.App-linux-x64-${version}.tar.gz";
sha256 = "sha256-8eJubZI677ZeIHum9jK4wouFt14Ocez+w5uZLHMo4Bw=";
sha256 = "sha256-qRja6e+uaM+vfYPXnHIa2L7xTeQvuTqoBIHGP7bexnY=";
};

dontUnpack = true;
Expand Down
60 changes: 30 additions & 30 deletions src/ct/codetracerconf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ type
noCommand,
replay,
run,
# remote,
remote,
install,
upload,
# download,
# login,
# `update-default-org`,
download,
login,
`set-default-org`,
# cmdDelete,
build,
record,
Expand Down Expand Up @@ -338,12 +338,12 @@ type
defaultValue: @[]
desc: "Arguments to forward to trace run command"
.} : seq[string]
# of remote:
# remoteArgs* {.
# restOfArgs
# defaultValue: @[]
# desc: "Trace sharing utilities"
# .}: seq[string]
of remote:
remoteArgs* {.
restOfArgs
defaultValue: @[]
desc: "Trace sharing utilities"
.}: seq[string]
of upload:
# same args as replay
uploadTraceId* {.
Expand All @@ -368,26 +368,26 @@ type
name: "org",
desc: "organization to upload to"
.}: Option[string]
# of download:
# traceDownloadUrl* {.
# argument,
# desc: "an url for an uploaded trace"
# .}: string
# # for now not needed: we directly import it and delete the zip as a temp artifact currently
# # traceDownloadOutput* {.
# # name: "output",
# # desc: "output path for the archive. if not passed: storing to an autogenerated path"
# # .}: Option[string]
# of login:
# loginDefaultOrg* {.
# name: "default-org",
# desc: "set a default organization for uploads",
# .}: Option[string]
# of `update-default-org`:
# updateDefaultOrgName* {.
# argument,
# desc: "the name of an organization to be updated as default"
# .}: string
of download:
traceDownloadUrl* {.
argument,
desc: "an url for an uploaded trace"
.}: string
# for now not needed: we directly import it and delete the zip as a temp artifact currently
# traceDownloadOutput* {.
# name: "output",
# desc: "output path for the archive. if not passed: storing to an autogenerated path"
# .}: Option[string]
of login:
loginDefaultOrg* {.
name: "default-org",
desc: "set a default organization for uploads",
.}: Option[string]
of `set-default-org`:
setDefaultOrgName* {.
argument,
desc: "the name of an organization to be updated as default"
.}: string
# of cmdDelete:
# traceId* {.
# name: "trace-id"
Expand Down
16 changes: 8 additions & 8 deletions src/ct/launch/launch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ proc runInitial*(conf: CodetracerConf) =
conf.uploadTraceFolder,
replayInteractive,
conf.uploadOrg)
# of StartupCommand.download:
# downloadTraceCommand(conf.traceDownloadUrl)
# of StartupCommand.login:
# loginCommand(conf.loginDefaultOrg)
# of StartupCommand.`update-default-org`:
# updateDefaultOrg(conf.updateDefaultOrgName)
of StartupCommand.download:
downloadTraceCommand(conf.traceDownloadUrl)
of StartupCommand.login:
loginCommand(conf.loginDefaultOrg)
of StartupCommand.`set-default-org`:
setDefaultOrg(conf.setDefaultOrgName)
# of StartupCommand.cmdDelete:
# deleteTraceCommand(conf.traceId, conf.controlId)
# # eventually enable?
Expand All @@ -153,8 +153,8 @@ proc runInitial*(conf: CodetracerConf) =
conf.recordProgram, conf.recordArgs)
of StartupCommand.run:
run(conf.runTracePathOrId, conf.runArgs)
# of StartupCommand.remote:
# quit(runCtRemote(conf.remoteArgs))
of StartupCommand.remote:
quit(runCtRemote(conf.remoteArgs))
of StartupCommand.arb:
case conf.arbCommand:
of ArbCommand.noCommand:
Expand Down
2 changes: 1 addition & 1 deletion src/ct/online_sharing/download.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ../trace/storage_and_import, ../globals
import remote

proc downloadFile(url: string, outputPath: string): int =
runCtRemote(@["download", url, "--output", outputPath])
runCtRemote(@["download", "--url", url, "--output", outputPath])

proc downloadTrace*(url: string): int =
let traceId = trace_index.newID(false)
Expand Down
14 changes: 9 additions & 5 deletions src/ct/online_sharing/remote.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/[ json, os, osproc, strutils, options ],
std/[ json, os, osproc, strutils, options, sequtils ],
../../common/[ paths ],
../cli/[ logging, list, help, build]

Expand All @@ -13,7 +13,11 @@ proc runCtRemote*(args: seq[string]): int =
return 1

try:
let process = startProcess(execPath, args = args, options = {poEchoCmd, poParentStreams})
let fullArgs = args.concat(@["--binary-name", "ct remote"])
var options = {poParentStreams}
if getEnv("CODETRACER_DEBUG_CT_REMOTE", "0") == "1":
options.incl(poEchoCmd)
let process = startProcess(execPath, args = fullArgs, options = options)
result = waitForExit(process)
except CatchableError as err:
echo "Failed to launch ct-remote (" & execPath & "): " & err.msg
Expand All @@ -22,9 +26,9 @@ proc runCtRemote*(args: seq[string]): int =
proc loginCommand*(defaultOrg: Option[string]) =
var args = @["login"]
if defaultOrg.isSome:
args.add("--default-org")
args.add("-org")
args.add(defaultOrg.get)
quit(runCtRemote(args))

proc updateDefaultOrg*(newOrg: string) =
quit(runCtRemote(@["update-default-org", newOrg]))
proc setDefaultOrg*(newOrg: string) =
quit(runCtRemote(@["set-default-org", "-org", newOrg]))
10 changes: 1 addition & 9 deletions src/ct/online_sharing/upload.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ proc uploadFile(
org: Option[string],
): UploadedInfo {.raises: [KeyError, Exception].} =

# TODO: remove when ready
echo "\nERROR: uploading files not functional yet"
quit(1)

result = UploadedInfo(exitCode: 0)
try:
var args = @["upload", traceZipPath]
if org.isSome:
args.add("--org")
args.add("-org")
args.add(org.get)
result.exitCode = runCtRemote(args)
except CatchableError as e:
Expand Down Expand Up @@ -90,10 +86,6 @@ proc uploadCommand*(
interactive: bool,
uploadOrg: Option[string],
) =
# TODO: re-enable when ready
echo "command not functional yet"
quit(1)

let config: Config = loadConfig(folder=getCurrentDir(), inTest=false)

if not config.traceSharing.enabled:
Expand Down
1 change: 1 addition & 0 deletions src/frontend/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ type
infoMessageActive*: JsAssoc[int, bool]
errorMessageActive*: JsAssoc[int, MessageKind]
isUploading*: JsAssoc[int, bool]
showTraceSharing*: bool

ReplComponent* = ref object of Component
history*: seq[DebugInteraction]
Expand Down
16 changes: 13 additions & 3 deletions src/frontend/ui/welcome_screen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ proc recentTransactionView(self: WelcomeScreenComponent, tx: StylusTransaction,
self.data.ipc.send "CODETRACER::load-recent-transaction", js{ txHash: tx.txHash }
)


proc recentProjectView(self: WelcomeScreenComponent, trace: Trace, position: int): VNode =
let featureFlag = data.config.traceSharing.enabled
let tooltipTopPosition = (position + 1) * 36 - self.recentTracesScroll
let activeClass = if self.copyMessageActive.hasKey(trace.id) and self.copyMessageActive[trace.id]: "welcome-path-active" else: ""
let infoActive = if self.infoMessageActive.hasKey(trace.id) and self.infoMessageActive[trace.id]: "welcome-path-active" else: ""
Expand Down Expand Up @@ -151,7 +151,7 @@ proc recentProjectView(self: WelcomeScreenComponent, trace: Trace, position: int
separateBar()
span(class = "recent-trace-title-content"):
text limitedProgramName # TODO: tippy
if featureFlag:
if self.showTraceSharing:
tdiv(class = "online-functionality-buttons"):
if self.isUploading[trace.id]:
tdiv(class = "recent-trace-buttons", id = "progress-bar"):
Expand Down Expand Up @@ -681,7 +681,7 @@ proc loadInitialOptions(self: WelcomeScreenComponent) =
),
WelcomeScreenOption(
name: "Open online trace",
inactive: false,
inactive: not self.showTraceSharing,
command: proc =
self.openOnlineTrace = true
self.welcomeScreen = false
Expand Down Expand Up @@ -729,9 +729,19 @@ proc loadingOverlay(self: WelcomeScreenComponent): VNode =
tdiv(class = "welcome-screen-loading-overlay-text"):
tdiv(): text "Loading trace..."

# TODO: adapt or change for newer uploading api; for now hiddden
# available only from CLI:
const TRACE_SHARING_HIDDEN_FOR_WELCOME_SCREEN = true

method render*(self: WelcomeScreenComponent): VNode =
if self.data.ui.welcomeScreen.isNil:
return

self.showTraceSharing = when TRACE_SHARING_HIDDEN_FOR_WELCOME_SCREEN:
false
else:
self.data.config.traceSharing.enabled

if self.options.len == 0:
self.loadInitialOptions()

Expand Down
Loading