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
This commit is contained in:
Mike Sawka 2024-03-08 10:33:10 -08:00 committed by GitHub
parent c5d4a0e1f3
commit a2795fb74d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -11,9 +11,9 @@
.openai-role { .openai-role {
color: var(--term-bright-green); color: var(--term-bright-green);
font-weight: bold;
width: 100px; width: 100px;
flex-shrink: 0; flex-shrink: 0;
font: var(--base-font);
} }
.openai-role.openai-role-assistant { .openai-role.openai-role-assistant {
@ -24,6 +24,7 @@
color: var(--app-text-color); color: var(--app-text-color);
font-family: var(--markdown-font); font-family: var(--markdown-font);
font-weight: normal; font-weight: normal;
font-size: var(--markdown-font-size);
} }
.openai-content-assistant { .openai-content-assistant {

View File

@ -2858,10 +2858,13 @@ func OpenAICommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus
if promptStr == "" { if promptStr == "" {
return nil, fmt.Errorf("openai error, prompt string is blank") 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) line, err := sstore.AddOpenAILine(ctx, ids.ScreenId, DefaultUserId, cmd)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot add new line: %v", err) return nil, fmt.Errorf("cannot add new line: %v", err)
} }
if resolveBool(pk.Kwargs["stream"], true) { if resolveBool(pk.Kwargs["stream"], true) {
go doOpenAIStreamCompletion(cmd, clientData.ClientId, opts, prompt) go doOpenAIStreamCompletion(cmd, clientData.ClientId, opts, prompt)
} else { } else {
@ -2876,7 +2879,6 @@ func OpenAICommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus
// ignore error again (nothing to do) // ignore error again (nothing to do)
log.Printf("openai error updating screen selected line: %v\n", err) log.Printf("openai error updating screen selected line: %v\n", err)
} }
update := scbus.MakeUpdatePacket()
sstore.AddLineUpdate(update, line, cmd) sstore.AddLineUpdate(update, line, cmd)
update.AddUpdate(*screen) update.AddUpdate(*screen)
return update, nil return update, nil
@ -3011,7 +3013,9 @@ func addLineForCmd(ctx context.Context, metaCmd string, shouldFocus bool, ids re
update := scbus.MakeUpdatePacket() update := scbus.MakeUpdatePacket()
sstore.AddLineUpdate(update, rtnLine, cmd) sstore.AddLineUpdate(update, rtnLine, cmd)
update.AddUpdate(*screen) 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) updateHistoryContext(ctx, rtnLine, cmd, cmd.FeState)
return update, nil return update, nil
} }