From a2795fb74de15b23fd7c8a46fa227ceb2eccb23d Mon Sep 17 00:00:00 2001 From: Mike Sawka Date: Fri, 8 Mar 2024 10:33:10 -0800 Subject: [PATCH] indicator fixup (mismatch of increments/decrements) (#411) * addLineForCmd should only increment for running commands. also openai lines should increment * small fix for openai chat styles --- src/plugins/openai/openai.less | 3 ++- wavesrv/pkg/cmdrunner/cmdrunner.go | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/openai/openai.less b/src/plugins/openai/openai.less index 01071aa5..f717182b 100644 --- a/src/plugins/openai/openai.less +++ b/src/plugins/openai/openai.less @@ -11,9 +11,9 @@ .openai-role { color: var(--term-bright-green); - font-weight: bold; width: 100px; flex-shrink: 0; + font: var(--base-font); } .openai-role.openai-role-assistant { @@ -24,6 +24,7 @@ color: var(--app-text-color); font-family: var(--markdown-font); font-weight: normal; + font-size: var(--markdown-font-size); } .openai-content-assistant { diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index 3af7379b..5d4bd471 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -2858,10 +2858,13 @@ func OpenAICommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus if promptStr == "" { return nil, fmt.Errorf("openai error, prompt string is blank") } + update := scbus.MakeUpdatePacket() + sstore.IncrementNumRunningCmds_Update(update, cmd.ScreenId, 1) line, err := sstore.AddOpenAILine(ctx, ids.ScreenId, DefaultUserId, cmd) if err != nil { return nil, fmt.Errorf("cannot add new line: %v", err) } + if resolveBool(pk.Kwargs["stream"], true) { go doOpenAIStreamCompletion(cmd, clientData.ClientId, opts, prompt) } else { @@ -2876,7 +2879,6 @@ func OpenAICommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus // ignore error again (nothing to do) log.Printf("openai error updating screen selected line: %v\n", err) } - update := scbus.MakeUpdatePacket() sstore.AddLineUpdate(update, line, cmd) update.AddUpdate(*screen) return update, nil @@ -3011,7 +3013,9 @@ func addLineForCmd(ctx context.Context, metaCmd string, shouldFocus bool, ids re update := scbus.MakeUpdatePacket() sstore.AddLineUpdate(update, rtnLine, cmd) update.AddUpdate(*screen) - sstore.IncrementNumRunningCmds_Update(update, cmd.ScreenId, 1) + if cmd.Status == sstore.CmdStatusRunning { + sstore.IncrementNumRunningCmds_Update(update, cmd.ScreenId, 1) + } updateHistoryContext(ctx, rtnLine, cmd, cmd.FeState) return update, nil }