summaryrefslogtreecommitdiffhomepage
path: root/debug-me.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-17 16:30:22 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-17 16:30:22 -0400
commitdd2de93701cc2ee9350cac0e3751435425f7d98e (patch)
treeab521689196331dea7f30e15eac739b2b062f12e /debug-me.hs
parent74499ceb9decf47709304c5923cefab6b0b99cef (diff)
downloaddebug-me-dd2de93701cc2ee9350cac0e3751435425f7d98e.tar.gz
minor cleanupd
Diffstat (limited to 'debug-me.hs')
-rw-r--r--debug-me.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/debug-me.hs b/debug-me.hs
index 2625ecc..53ee545 100644
--- a/debug-me.hs
+++ b/debug-me.hs
@@ -87,9 +87,14 @@ sendTtyInput ichan devstate = go
send b = do
atomically $ do
ds <- readTVar devstate
+ let ed = if lastActivity ds == lastSeen ds
+ then B.concat $ sentSince ds
+ else case reverse (sentSince ds) of
+ [] -> mempty
+ (lb:_) -> lb
let entered = Entered
{ enteredData = Val b
- , echoData = Val $ B.concat $ sentSince ds
+ , echoData = Val ed
}
let act = Activity (Proto entered) (Just $ lastActivity ds) dummySignature
writeTChan ichan act
@@ -153,10 +158,10 @@ isLegalSeen act@(Activity p (Just hp) sig) ds
then (drop n ss, drop n es)
else (mempty, mempty)
in yes $ DeveloperState
- { lastSeen = h
+ { lastSeen = acth
, sentSince = ss'
, enteredSince = es'
- , lastActivity = h
+ , lastActivity = acth
}
-- Does it chain to something we've entered since the last Seen
-- value? Eg, user sent A, we replied B C, and the user has
@@ -173,19 +178,19 @@ isLegalSeen act@(Activity p (Just hp) sig) ds
ss' = drop (i+1) ss
es' = drop (i+1) es
in yes $ DeveloperState
- { lastSeen = h
+ { lastSeen = acth
, sentSince = ss'
, enteredSince = es'
- , lastActivity = h
+ , lastActivity = acth
}
where
- h = hash act
+ acth = hash act
yes ds' = (True, ds')
-- When they rejected a message we sent, anything we sent
-- subsequently will also be rejected, so forget about it.
yesrej = yes $ ds
- { lastSeen = h
- , lastActivity = h
+ { lastSeen = acth
+ , lastActivity = acth
}
isLegalSeen (Activity _ Nothing _) ds = (False, ds)
@@ -288,7 +293,7 @@ truncateBacklog (Backlog (b :| l)) (Activity _ hp _)
-- the current state of the system before manipulating it.
--
-- To support typeahead on slow links, some echoData may be provided
--- in the Entered activity. If the prevActivity points
+-- in the Entered activity. If the Entered activity points
-- to an older Seen activity, then the echoData must match the
-- concatenation of all Seen activities after that one, up to the
-- most recent Seen activity.