~williewillus/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 3

[PATCH r16] Add typing indicator for trick evaluations

Details
Message ID
<20210228012549.681920-1-wenming.yi@gmail.com>
DKIM signature
pass
Download raw message
Patch: +31 -9
From: Alwinfy <20421383+Alwinfy@users.noreply.github.com>

---
 r16.rkt | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/r16.rkt b/r16.rkt
index 5cd74a5..1c982c9 100755
--- a/r16.rkt
+++ b/r16.rkt
@@ -85,6 +85,25 @@
                (http:delete-message client (rc:message-channel-id message) (rc:message-id message)))
              (loop))))))

(define typing-thread
  (thread
   (thunk
    (let loop ([data #hash()])
      (match-let ([(list val client channel) (thread-receive)])
        (let* ([key (cons (rc:user-id (rc:client-user client)) channel)]
               [newval (+ val (hash-ref data key 0))])
          (displayln (~a newval " " key))
          (unless (zero? newval)
            (http:trigger-typing-indicator client channel))
          (loop (hash-set data key newval))))))))

(define (with-typing-indicator client message thunk)
  (let ([payload (list client (rc:message-channel-id message))])
    (thread-send typing-thread (cons 1 payload))
    (let ([result (call-with-values thunk list)])
      (thread-send typing-thread (cons -1 payload))
      (apply values result))))


(define (make-trick body message parent)
  (trick (if parent (trick-author parent) (message-author-id message))
@@ -95,7 +114,8 @@
(define (run-snippet client db message code)
  (let ([code (strip-backticks code)]
        [text (rc:message-content message)])
    (ev:run code (evaluation-ctx client message (db:get-trick-context db message) "" #f))))
    (with-typing-indicator client message
      (thunk (ev:run code (evaluation-ctx client message (db:get-trick-context db message) "" #f))))))

(define (register-trick client db message text)
  (check-trick-prereqs
@@ -115,14 +135,15 @@
      (if trick
        (begin
          (db:update-trick! context name (lambda (t) (set-trick-invocations! t (add1 (trick-invocations t))) t) (const #t))
          (ev:run
            (trick-body trick)
            (evaluation-ctx
              client
              message
              context
              (or body "")
              #f)))
          (with-typing-indicator client message
            (thunk (ev:run
              (trick-body trick)
              (evaluation-ctx
                client
                message
                context
                (or body "")
                #f)))))
        (~a "Trick " name " doesn't exist!")))))

(define (update-trick client db message text)
@@ -283,6 +304,7 @@
    (placeholder-set! placeholder (make-hash ctx))
    (make-reader-graph ctx)))


(define command-table
  `(("eval"     . ,run-snippet)
    ("register" . ,register-trick)
-- 
2.25.1

[r16/patches/linux_buildtest.yml] build failed

builds.sr.ht
Details
Message ID
<C9KRU4NLXK3S.3KQ8435B6W8S@cirno2>
In-Reply-To
<20210228012549.681920-1-wenming.yi@gmail.com> (view parent)
DKIM signature
missing
Download raw message
r16/patches/linux_buildtest.yml: FAILED in 48s

[Add typing indicator for trick evaluations][0] from [][1]

[0]: https://lists.sr.ht/~williewillus/public-inbox/patches/20669
[1]: mailto:wenming.yi@gmail.com

✗ #442934 FAILED r16/patches/linux_buildtest.yml https://builds.sr.ht/~williewillus/job/442934

[PATCH r16] Remove a debug print lmao

Details
Message ID
<20210228012854.682322-1-wenming.yi@gmail.com>
In-Reply-To
<20210228012549.681920-1-wenming.yi@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +0 -1
From: Alwinfy <20421383+Alwinfy@users.noreply.github.com>


---
 r16.rkt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/r16.rkt b/r16.rkt
index 1c982c9..2608816 100755
--- a/r16.rkt
+++ b/r16.rkt
@@ -92,7 +92,6 @@
      (match-let ([(list val client channel) (thread-receive)])
        (let* ([key (cons (rc:user-id (rc:client-user client)) channel)]
               [newval (+ val (hash-ref data key 0))])
          (displayln (~a newval " " key))
          (unless (zero? newval)
            (http:trigger-typing-indicator client channel))
          (loop (hash-set data key newval))))))))
-- 
2.25.1
Details
Message ID
<87sg5ht06z.fsf@vincent-lee.net>
In-Reply-To
<20210228012549.681920-1-wenming.yi@gmail.com> (view parent)
DKIM signature
pass
Download raw message
A couple comments. Also, please specify what patches your patch should
be applied on top of/depends on, or base them off of current master if possible.

wenming.yi@gmail.com writes:

> From: Alwinfy <20421383+Alwinfy@users.noreply.github.com>
>
> ---
>  r16.rkt | 40 +++++++++++++++++++++++++++++++---------
>  1 file changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/r16.rkt b/r16.rkt
> index 5cd74a5..1c982c9 100755
> --- a/r16.rkt
> +++ b/r16.rkt
> @@ -85,6 +85,25 @@
>                  (http:delete-message client (rc:message-channel-id message) (rc:message-id message)))
>                (loop))))))
>  
> +(define typing-thread
> +  (thread
> +   (thunk
> +    (let loop ([data #hash()])
> +      (match-let ([(list val client channel) (thread-receive)])
> +        (let* ([key (cons (rc:user-id (rc:client-user client)) channel)]
> +               [newval (+ val (hash-ref data key 0))])
> +          (displayln (~a newval " " key))
> +          (unless (zero? newval)
> +            (http:trigger-typing-indicator client channel))
> +          (loop (hash-set data key newval))))))))
How long does this indicator last? Do you have to send a signal to turn
it off? Also, this needs error handling lest a throw from the http
method crash the entire thread.
> +
> +(define (with-typing-indicator client message thunk)
> +  (let ([payload (list client (rc:message-channel-id message))])
> +    (thread-send typing-thread (cons 1 payload))
> +    (let ([result (call-with-values thunk list)])
> +      (thread-send typing-thread (cons -1 payload))
> +      (apply values result))))
> +
What happens if the thunk throws? Would we be stuck permanently typing?
(see above)

[PATCH] Wrap http call in a catch

Details
Message ID
<20210228021557.685976-1-wenming.yi@gmail.com>
In-Reply-To
<20210228012549.681920-1-wenming.yi@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +1 -1
From: Alwinfy <20421383+Alwinfy@users.noreply.github.com>



---

> please specify what patches your patch should be applied on top
> of/depends on, or base them off of current master if possible.  
Sorry, I've just been piling them on top of my other patches, so I guess
just merge in order?

> How long does this indicator last? Do you have to send a signal to
> turn it off?
Typing indicators last about ten seconds or until the next message is
sent, hence why we send it twice.

> What happens if the thunk throws?
I'm pretty sure there's a with-handlers block in an earlier patch of
mine, upstream in ev:run

> Also, this needs error handling lest a throw from the http
> method crash the entire thread.
See below:

 r16.rkt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/r16.rkt b/r16.rkt
index 2608816..7cbe603 100755
--- a/r16.rkt
+++ b/r16.rkt
@@ -93,7 +93,7 @@
        (let* ([key (cons (rc:user-id (rc:client-user client)) channel)]
               [newval (+ val (hash-ref data key 0))])
          (unless (zero? newval)
            (http:trigger-typing-indicator client channel))
            (with-handlers ([exn:fail? (const #f)]) (http:trigger-typing-indicator client channel)))
          (loop (hash-set data key newval))))))))

(define (with-typing-indicator client message thunk)
-- 
2.25.1
Reply to thread Export thread (mbox)