wip chat sessions 2

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 14:24:42 -04:00
1 parent 1367525c12
commit 85b41f6435
92 files changed
+3692 -22

No files matched your search

+8 -7
View File
@@ -19,7 +19,7 @@ type SystemPromptEditorOptions struct {
Default string
// Saved is the text last saved; a different value shows as unsaved.
Saved string
// MaxLength caps the characters; zero is no cap.
// MaxLength is the character limit; over it, Save is blocked. Zero is none.
MaxLength int
// Saving shows the caller's save in progress and blocks editing.
Saving bool
@@ -47,6 +47,7 @@ func SystemPromptEditor(c *ui.Context, value *string, opts SystemPromptEditorOpt
col := ui.Column(c).Gap(d.Unit() * 2).Disabled(blocked)
v := SystemPromptEditorView{Element: col}
dirty := *value != opts.Saved
over := opts.MaxLength > 0 && utf8.RuneCountInString(*value) > opts.MaxLength
col.Children(func() {
ui.Row(c).Gap(d.Unit() * 2).AlignItems(ui.Center).Children(func() {
ui.Text(c, msg(c, "system_prompt_editor.title")).Font(theme.SerifFont).FontSize(FontSize(c, theme.H3Size)).TextColor(k.Text).Grow(1)
@@ -62,24 +63,24 @@ func SystemPromptEditor(c *ui.Context, value *string, opts SystemPromptEditorOpt
TextArea(c, value, TextAreaOptions{Label: msg(c, "system_prompt_editor.title"), MinHeight: 120, MaxHeight: 320,
MaxLength: opts.MaxLength, Disabled: blocked})
ui.Row(c).Gap(d.Unit() * 2).AlignItems(ui.Center).Children(func() {
n := utf8.RuneCountInString(*value)
count := fmt.Sprintf(msg(c, "system_prompt_editor.count"), n)
if opts.MaxLength > 0 {
count = fmt.Sprintf(msg(c, "system_prompt_editor.count_of"), n, opts.MaxLength)
// With MaxLength the TextArea shows "n / max" itself.
count := ""
if opts.MaxLength == 0 {
count = fmt.Sprintf(msg(c, "system_prompt_editor.count"), utf8.RuneCountInString(*value))
}
ui.Text(c, count).FontSize(FontSize(c, theme.CaptionSize)).TextColor(k.TextMuted).Grow(1)
if Button(c, msg(c, "system_prompt_editor.restore"), ButtonOptions{Variant: Ghost, Icon: icons.Must("refresh-cw"),
Disabled: blocked || *value == opts.Default}).Clicked() && !col.IsDisabled() {
*value, v.Restored = opts.Default, true
}
v.Save = Button(c, msg(c, "system_prompt_editor.save"), ButtonOptions{Loading: opts.Saving, Disabled: opts.Disabled || !dirty}).Clicked()
v.Save = Button(c, msg(c, "system_prompt_editor.save"), ButtonOptions{Loading: opts.Saving, Disabled: opts.Disabled || !dirty || over}).Clicked()
})
})
mods := ui.Ctrl
if runtime.GOOS == "darwin" {
mods = ui.Cmd
}
if col.Shortcut(mods, ui.KeyS) && dirty {
if col.Shortcut(mods, ui.KeyS) && dirty && !over {
v.Save = true
}
if col.IsDisabled() {