Skip to content

Commit 90f315e

Browse files
committed
Improve login wording + add cancel option.
Fixes #205
1 parent dbdf726 commit 90f315e

File tree

6 files changed

+49
-32
lines changed

6 files changed

+49
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Fix Gemini (OpenAI compatible). #247
6+
- Improve login wording + add cancel option. #205
67

78
## 0.91.2
89

src/eca/features/commands.clj

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,21 @@
254254
:content (merge {:type :usage}
255255
usage)})))
256256
:prompt (f.prompt/compact-prompt (string/join " " args) all-tools config db)})
257-
"login" (do (f.login/handle-step {:message (or (first args) "")
258-
:chat-id chat-id}
259-
db*
260-
messenger
261-
config
262-
metrics)
263-
{:type :new-chat-status
264-
:status :login})
257+
"login" (do
258+
(messenger/chat-content-received
259+
messenger
260+
{:chat-id chat-id
261+
:role "system"
262+
:content {:type :text
263+
:text "Login started, type 'cancel' anytime to exit login."}})
264+
(f.login/handle-step {:message (or (first args) "")
265+
:chat-id chat-id}
266+
db*
267+
messenger
268+
config
269+
metrics)
270+
{:type :new-chat-status
271+
:status :login})
265272
"resume" (let [chats (into {}
266273
(filter #(not= chat-id (first %)))
267274
(:chats db))

src/eca/features/login.clj

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,26 @@
2222
(send-msg! (reduce
2323
(fn [s provider]
2424
(str s "- " provider "\n"))
25-
"Choose a provider:\n"
25+
"Inform the provider:\n\n"
2626
providers)))))
2727

2828
(defn handle-step [{:keys [message chat-id]} db* messenger config metrics]
2929
(let [provider (get-in @db* [:chats chat-id :login-provider])
3030
step (get-in @db* [:auth provider :step] :login/start)
3131
input (string/trim message)
32+
send-msg! (fn [msg]
33+
(messenger/chat-content-received
34+
messenger
35+
{:chat-id chat-id
36+
:role "system"
37+
:content {:type :text
38+
:text msg}})
39+
(messenger/chat-content-received
40+
messenger
41+
{:chat-id chat-id
42+
:role "system"
43+
:content {:type :progress
44+
:state :finished}}))
3245
ctx {:chat-id chat-id
3346
:step step
3447
:input input
@@ -37,28 +50,24 @@
3750
:messenger messenger
3851
:metrics metrics
3952
:provider provider
40-
:send-msg! (fn [msg]
41-
(messenger/chat-content-received
42-
messenger
43-
{:chat-id chat-id
44-
:role "system"
45-
:content {:type :text
46-
:text msg}})
47-
(messenger/chat-content-received
48-
messenger
49-
{:chat-id chat-id
50-
:role "system"
51-
:content {:type :progress
52-
:state :finished}}))}]
53+
:send-msg! send-msg!}]
5354
(messenger/chat-content-received
5455
messenger
5556
{:chat-id chat-id
5657
:role "user"
5758
:content {:type :text
5859
:text (str input "\n")}})
59-
(login-step ctx)
60-
{:chat-id chat-id
61-
:status :login}))
60+
(if (= "cancel" input)
61+
(do
62+
(send-msg! "Login cancelled")
63+
(swap! db* assoc-in [:chats chat-id :login-provider] nil)
64+
(swap! db* assoc-in [:chats chat-id :status] :idle)
65+
{:chat-id chat-id
66+
:status :idle})
67+
(do
68+
(login-step ctx)
69+
{:chat-id chat-id
70+
:status :login}))))
6271

6372
(defn ^:private renew-auth!
6473
[provider

src/eca/llm_providers/anthropic.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@
363363
(swap! db* assoc-in [:auth provider] {:step :login/waiting-login-method})
364364
(send-msg! (multi-str "Now, inform the login method:"
365365
""
366-
"max: Claude Pro/Max"
367-
"console: Create API Key"
368-
"manual: Manually enter API Key")))
366+
"- max: Claude Pro/Max"
367+
"- console: Automatically create API Key and use it"
368+
"- manual: Manually enter API Key")))
369369

370370
(defmethod f.login/login-step ["anthropic" :login/waiting-login-method] [{:keys [db* input provider send-msg!]}]
371371
(case input

src/eca/llm_providers/openai.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@
337337
(swap! db* assoc-in [:auth provider] {:step :login/waiting-login-method})
338338
(send-msg! (multi-str "Now, inform the login method:"
339339
""
340-
"pro: GPT Plus/Pro (subscription)"
341-
"manual: Manually enter API Key")))
340+
"- pro: GPT Plus/Pro (subscription)"
341+
"- manual: Manually enter API Key")))
342342

343343
(defmethod f.login/login-step ["openai" :login/waiting-login-method] [{:keys [db* input provider send-msg!] :as ctx}]
344344
(case input

test/eca/features/login_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
:send-msg! send-msg!})
2323

2424
(testing "should ask to choose a provider"
25-
(is (= "Choose a provider:\n- github-copilot\n- google\n"
25+
(is (= "Inform the provider:\n\n- github-copilot\n- google\n"
2626
(last @msg-log)))))
2727

2828
(testing "user is confused"
@@ -34,7 +34,7 @@
3434
:send-msg! send-msg!})
3535

3636
(testing "should ask to choose a provider and provide instructions"
37-
(is (= "Choose a provider:\n- github-copilot\n- google\n"
37+
(is (= "Inform the provider:\n\n- github-copilot\n- google\n"
3838
(last @msg-log)))
3939

4040
(testing "state didn't change"

0 commit comments

Comments
 (0)