Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Offirmo committed Sep 30, 2024
1 parent 867e5bd commit b14c76c
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bot detection
browsing contexts = such as several windows, iframes or even workers
cache https://csswizardry.com/2024/08/cache-grab-how-much-are-you-leaving-on-the-table/
CDN
CDN -- quality = hot/cold potato routing https://vercel.com/blog/latency-numbers-every-web-developer-should-know
chrome = the graphical framework and elements surrounding the content. means different things depending on the context: In the context of a web browser it is the navigation, toolbar etc. In the context of a website it is navigation, ad-space and other fixed aspects of the design https://stackoverflow.com/a/5072092/587407
Chrome is not the standard https://v4.chriskrycho.com/2017/chrome-is-not-the-standard.html
client/server -- multi-tier architecture -- 01 presentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ kafka = pub/sub + store + process
lambdalith https://rehanvdm.com/blog/should-you-use-a-lambda-monolith-lambdalith-for-the-api
latency = the time that passes between an action and the resulting response
latency https://www.a10networks.com/glossary/osi-network-model-and-types-of-load-balancers/
latency numbers -- frontend -- duration of time perceived by humans as sluggish = 200ms. a reaction response slower than this value will be perceived as having to wait
latency numbers -- frontend -- shortest duration of time perceived by humans as time having passed = 40-80ms. response below this duration means that your user will perceive the response as instant
latency numbers -- frontend https://vercel.com/blog/latency-numbers-every-web-developer-should-know
latency numbers https://brenocon.com/dean_perf.html
limiting -- content limiting = ex. only X Gb of storage
Expand Down
1 change: 1 addition & 0 deletions stack--current/5-incubator/active/view--chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"demo": "node ./dist/src.es2023.esm/loop/demo.js"
},
"devDependencies": {
"@offirmo/deferred": "*",
"npm-run-all": "^4",
"tslib": "^2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CHAT_CONSOLE: ChatPrimitives<string> = {

display_task: ({
msg_before,
progress_promise,
promise,
msg_after,
}) => {
throw new Error(`NO UI display_task!`)
Expand Down
Empty file.
36 changes: 23 additions & 13 deletions stack--current/5-incubator/active/view--chat/src/__fixtures/tour.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { type Step, StepType } from '../types/types.js'
import { type StepsGenerator } from '../loop/types.js'
import Deferred from '@offirmo/deferred'

export default function* get_next_step(skip_to_index: number = 0) {
console.log('get_next_step()', { skip_to_index })

const state = {
mode: 'main',
name: undefined,
city: undefined,
}

const STEPS: Array<Step> = [
const warmup_promise = new Deferred<void>()
setTimeout(() => warmup_promise.reject(new Error('Failed!')), 3000)

const STEPS: Array<Step<string>> = [

{
type: StepType.perceived_labor,
Expand All @@ -22,17 +28,18 @@ export default function* get_next_step(skip_to_index: number = 0) {
type: StepType.progress,

msg_before: 'Warming up...',
task_promise: (new Promise((resolve, reject) => setTimeout(() => reject(new Error('Demo step 2 rejection!')), 2000))),
promise: warmup_promise,
msg_after: success => success ? '✔ Ready!' : '❌ Warm up unsuccessful.',

callback: success => console.log(`[callback called: ${success}]`),
},

/*
{
type: 'simple_message',
msg_main: 'Welcome. I’ll have a few questions…',
type: StepType.simple_message,
msg: 'Welcome. I’ll have a few questions…',
},

/*
{
type: 'ask_for_string',
msg_main: 'What’s your name?',
Expand All @@ -48,15 +55,18 @@ export default function* get_next_step(skip_to_index: number = 0) {
msgg_acknowledge: value => `${value}, a fine city indeed!`,
callback: value => { state.city = value },
},
*/

{
type: 'simple_message',
msg_main: 'Please wait for a moment...',
type: StepType.simple_message,
msg: 'Please wait for a moment...',
},
{
type: 'progress',
type: StepType.perceived_labor,
msg_before: 'Calling server...',
duration_ms: 1000,
msg_main: 'Calling server...',
},
/*
{
msg_main: 'Please choose between 1 and 2?',
callback: value => { state.mode = value },
Expand All @@ -70,11 +80,11 @@ export default function* get_next_step(skip_to_index: number = 0) {
value: 2,
},
],
},
{
type: 'simple_message',
msg_main: 'Thanks, good bye.',
},*/
{
type: StepType.simple_message,
msg: 'Thanks, good bye.',
},
]

yield* STEPS.slice(skip_to_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,37 @@ import { Enum } from 'typescript-string-enums'
import { PProgress as PromiseWithProgress } from 'p-progress'
import { type Immutable } from '@offirmo-private/ts-types'

import { type TaskProgressStep } from '../types/types.js'

/////////////////////////////////////////////////

// primitives should always accept string = common lowest denominator
// up to it to convert to rich text if needed
interface ChatPrimitives<ContentType> {
setup(): Promise<void>

// core primitives
display_message(p: {msg: ContentType, choices?: ContentType[]}): Promise<void>
display_message(p: {
msg: ContentType | string,
choices?: Array<ContentType | string>
}): Promise<void>

// a staple of chat interfaces
// to be used between steps
pretend_to_think(p: {duration_ms: number}): Promise<void>

pretend_to_work(p: {
msg_before: ContentType,
msg_before: ContentType | string,
duration_ms: number,
msg_after: ContentType,
msg_after: ContentType | string,
}): Promise<void>

//read_answer(step) TODO clarify

display_task(p: {
msg_before: ContentType,
progress_promise: PromiseWithProgress<any>,
msg_after: ContentType,
msg_before: TaskProgressStep<ContentType>['msg_before'],
promise: TaskProgressStep<ContentType>['promise'],
msg_after: TaskProgressStep<ContentType>['msg_after'],
}): Promise<void>

// while we wait for the next step.
Expand Down
Loading

0 comments on commit b14c76c

Please sign in to comment.