Skip to content
Merged
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
12 changes: 11 additions & 1 deletion commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

var InitCommand *cli.Command = &cli.Command{
Name: "init",
Usage: "Initialize shelltime: authenticate, install hooks, and start daemon",
Usage: "Initialize shelltime: authenticate, install hooks, start daemon, and configure AI code integrations",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "token",
Expand Down Expand Up @@ -37,6 +37,16 @@ func commandInit(c *cli.Context) error {
return err
}

// Step 4: Install Claude Code OTEL configuration
if err := commandCCInstall(c); err != nil {
color.Red.Printf("Failed to install Claude Code OTEL config: %v\n", err)
}

// Step 5: Install Codex OTEL configuration
if err := commandCodexInstall(c); err != nil {
color.Red.Printf("Failed to install Codex OTEL config: %v\n", err)
}
Comment on lines +46 to +48

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Duplicate error message printed when Codex OTEL install fails during init

When commandCodexInstall fails during shelltime init, the user sees the same error message printed twice.

Root Cause

commandCodexInstall at commands/codex.go:37-39 already prints the error and then returns it:

if err := service.Install(); err != nil {
    color.Red.Printf("Failed to install Codex OTEL config: %v\n", err)
    return err
}

Then commandInit at commands/init.go:46-48 catches the returned error and prints it again:

if err := commandCodexInstall(c); err != nil {
    color.Red.Printf("Failed to install Codex OTEL config: %v\n", err)
}

This is inconsistent with how commandCCInstall works — that function handles errors internally for each shell and always returns nil (commands/cc.go:57), so the error handler in init.go:41-43 never triggers.

Impact: When Codex OTEL config installation fails during shelltime init, the user sees two nearly identical red error lines, which is confusing.

Prompt for agents
There are two reasonable approaches to fix the duplicate error message:

Option A (preferred): Make commandCodexInstall consistent with commandCCInstall by not returning the error after printing it. In commands/codex.go, lines 37-39, remove the `return err` so the function always returns nil (matching the pattern used in commandCCInstall). This way init.go's error handler won't trigger.

Option B: In commands/init.go lines 46-48, don't print the error since commandCodexInstall already prints it. Change to just: `_ = commandCodexInstall(c)` or `commandCodexInstall(c) //nolint:errcheck`. But this loses the ability to detect failure from the caller side.

Option A is cleaner as it makes both CC and Codex install functions behave the same way.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +40 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error handling for the new installation steps is inconsistent. commandCCInstall always returns nil (making the error check on line 41 dead code), while commandCodexInstall logs an error and also returns it (leading to duplicate logging on line 47).

A better long-term solution would be to refactor commandCCInstall to return errors and commandCodexInstall to not log them, letting commandInit handle all logging centrally.

For an immediate improvement within this file, you can adjust the calls to reflect the current behavior of the sub-commands. This avoids the dead code and duplicate logging issues.

	// Step 4: Install Claude Code OTEL configuration
	// commandCCInstall handles its own logging and does not return errors.
	commandCCInstall(c)

	// Step 5: Install Codex OTEL configuration
	// commandCodexInstall handles its own error logging, so we ignore the returned error here to avoid duplicate logs.
	_ = commandCodexInstall(c)


color.Green.Println("ShellTime is fully initialized and ready to use!")
return nil
}