From a68c13adf6d9da4420739a5218e9f8732577719f Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Wed, 6 Sep 2023 10:15:09 -0500 Subject: [PATCH 1/7] :we wq fix: lsdv-5044 add queue total to the app store and pull into current task --- src/components/BottomBar/CurrentTask.js | 2 +- src/components/TopBar/CurrentTask.js | 2 +- src/stores/AppStore.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/BottomBar/CurrentTask.js b/src/components/BottomBar/CurrentTask.js index b62b386431..6e5b5df7d1 100644 --- a/src/components/BottomBar/CurrentTask.js +++ b/src/components/BottomBar/CurrentTask.js @@ -26,7 +26,7 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && ( - {currentIndex} of {store.taskHistory.length} + {currentIndex} of {store.queueTotal} )} diff --git a/src/components/TopBar/CurrentTask.js b/src/components/TopBar/CurrentTask.js index 8ceb9f8076..d9fae96e1e 100644 --- a/src/components/TopBar/CurrentTask.js +++ b/src/components/TopBar/CurrentTask.js @@ -62,7 +62,7 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && showCounter && ( - {currentIndex} of {store.taskHistory.length} + {currentIndex} of {store.queueTotal} )} diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 18d043b4ea..88d09bf42a 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -154,6 +154,8 @@ export default types users: types.optional(types.array(UserExtended), []), userLabels: isFF(FF_DEV_1536) ? types.optional(UserLabels, { controls: {} }) : types.undefined, + + queueTotal: types.optional(types.number, 0), }) .preProcessSnapshot((sn) => { // This should only be handled if the sn.user value is an object, and converted to a reference id for other @@ -759,11 +761,13 @@ export default types } function nextTask() { + if (self.canGoNextTask) { const { taskId, annotationId } = self.taskHistory[self.taskHistory.findIndex((x) => x.taskId === self.task.id) + 1]; getEnv(self).events.invoke('nextTask', taskId, annotationId); } + } function prevTask(e, shouldGoBack = false) { From 53ccdaf92cea9fbbb5567739289ada69e46721b4 Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Thu, 14 Sep 2023 16:35:42 -0500 Subject: [PATCH 2/7] impliement queposition with increment function --- src/components/BottomBar/CurrentTask.js | 6 +----- src/components/TopBar/CurrentTask.js | 6 +----- src/stores/AppStore.js | 9 +++++++++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/BottomBar/CurrentTask.js b/src/components/BottomBar/CurrentTask.js index 6e5b5df7d1..c3f58d4d24 100644 --- a/src/components/BottomBar/CurrentTask.js +++ b/src/components/BottomBar/CurrentTask.js @@ -1,5 +1,4 @@ import { observer } from 'mobx-react'; -import { useMemo } from 'react'; import { Button } from '../../common/Button/Button'; import { Block, Elem } from '../../utils/bem'; import { guidGenerator } from '../../utils/unique'; @@ -8,9 +7,6 @@ import './CurrentTask.styl'; export const CurrentTask = observer(({ store }) => { - const currentIndex = useMemo(() => { - return store.taskHistory.findIndex((x) => x.taskId === store.task.id) + 1; - }, [store.taskHistory]); const historyEnabled = store.hasInterface('topbar:prevnext'); // @todo some interface? @@ -26,7 +22,7 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && ( - {currentIndex} of {store.queueTotal} + {store.queuePosition} of {store.queueTotal} )} diff --git a/src/components/TopBar/CurrentTask.js b/src/components/TopBar/CurrentTask.js index d9fae96e1e..40f6fdd773 100644 --- a/src/components/TopBar/CurrentTask.js +++ b/src/components/TopBar/CurrentTask.js @@ -28,10 +28,6 @@ export const CurrentTask = observer(({ store }) => { }; }, []); - const currentIndex = useMemo(() => { - return store.taskHistory.findIndex((x) => x.taskId === store.task.id) + 1; - }, [store.taskHistory]); - useEffect(() => { if (store.commentStore.addedCommentThisSession) { setInitialCommentLength(visibleComments); @@ -62,7 +58,7 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && showCounter && ( - {currentIndex} of {store.queueTotal} + {store.queuePosition} of {store.queueTotal} )} diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 88d09bf42a..21a60a1e4a 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -156,6 +156,8 @@ export default types userLabels: isFF(FF_DEV_1536) ? types.optional(UserLabels, { controls: {} }) : types.undefined, queueTotal: types.optional(types.number, 0), + + queuePosition: types.optional(types.number, 0), }) .preProcessSnapshot((sn) => { // This should only be handled if the sn.user value is an object, and converted to a reference id for other @@ -533,6 +535,9 @@ export default types }) .then(() => self.setFlags({ isSubmitting: false })); } + function incrementQueuePosition() { + self.queuePosition++; + } function submitAnnotation() { if (self.isSubmitting) return; @@ -547,6 +552,7 @@ export default types entity.sendUserGenerate(); handleSubmittingFlag(async () => { await getEnv(self).events.invoke(event, self, entity); + self.incrementQueuePosition(); }); entity.dropDraft(); } @@ -562,6 +568,7 @@ export default types handleSubmittingFlag(async () => { await getEnv(self).events.invoke('updateAnnotation', self, entity, extraData); + self.incrementQueuePosition(); }); entity.dropDraft(); !entity.sentUserGenerate && entity.sendUserGenerate(); @@ -594,6 +601,7 @@ export default types entity.dropDraft(); await getEnv(self).events.invoke('acceptAnnotation', self, { isDirty, entity }); + self.incrementQueuePosition(); }, 'Error during accept, try again'); } @@ -832,6 +840,7 @@ export default types nextTask, prevTask, postponeTask, + incrementQueuePosition, beforeDestroy() { ToolsManager.removeAllTools(); appControls = null; From 4c5add4b4dcb4837709bac82ac6d9da1902c3656 Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Fri, 15 Sep 2023 13:54:22 -0500 Subject: [PATCH 3/7] add tooltip to task counter --- src/components/BottomBar/CurrentTask.js | 11 +++++++---- src/components/TopBar/CurrentTask.js | 12 +++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/BottomBar/CurrentTask.js b/src/components/BottomBar/CurrentTask.js index c3f58d4d24..f8589e3391 100644 --- a/src/components/BottomBar/CurrentTask.js +++ b/src/components/BottomBar/CurrentTask.js @@ -3,6 +3,7 @@ import { Button } from '../../common/Button/Button'; import { Block, Elem } from '../../utils/bem'; import { guidGenerator } from '../../utils/unique'; import { isDefined } from '../../utils/utilities'; +import { Tooltip } from '../../common/Tooltip/Tooltip'; import './CurrentTask.styl'; @@ -14,16 +15,18 @@ export const CurrentTask = observer(({ store }) => { && !store.canGoNextTask && !store.hasInterface('review') && store.hasInterface('postpone'); - + return ( {store.task.id ?? guidGenerator()} {historyEnabled && ( - - {store.queuePosition} of {store.queueTotal} - + + + {store.queuePosition} of {store.queueTotal} + + )} {historyEnabled && ( diff --git a/src/components/TopBar/CurrentTask.js b/src/components/TopBar/CurrentTask.js index 40f6fdd773..4e976b67e1 100644 --- a/src/components/TopBar/CurrentTask.js +++ b/src/components/TopBar/CurrentTask.js @@ -1,5 +1,5 @@ import { observer } from 'mobx-react'; -import { useEffect, useMemo, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Button } from '../../common/Button/Button'; import { Block, Elem } from '../../utils/bem'; import { FF_DEV_3873, FF_DEV_4174, isFF } from '../../utils/feature-flags'; @@ -7,7 +7,7 @@ import { guidGenerator } from '../../utils/unique'; import { isDefined } from '../../utils/utilities'; import './CurrentTask.styl'; import { reaction } from 'mobx'; - +import { Tooltip } from '../../common/Tooltip/Tooltip'; export const CurrentTask = observer(({ store }) => { const [initialCommentLength, setInitialCommentLength] = useState(0); @@ -57,9 +57,11 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && showCounter && ( - - {store.queuePosition} of {store.queueTotal} - + + + {store.queuePosition} of {store.queueTotal} + + )} {historyEnabled && ( From ff4b24f29c4d028e5dc761ff053ea4e2c03904bd Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Sun, 17 Sep 2023 13:49:28 -0500 Subject: [PATCH 4/7] task count incriments on skip,forward, back --- src/components/TopBar/CurrentTask.js | 9 +++------ src/stores/AppStore.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/TopBar/CurrentTask.js b/src/components/TopBar/CurrentTask.js index 4e976b67e1..b03c907831 100644 --- a/src/components/TopBar/CurrentTask.js +++ b/src/components/TopBar/CurrentTask.js @@ -7,7 +7,6 @@ import { guidGenerator } from '../../utils/unique'; import { isDefined } from '../../utils/utilities'; import './CurrentTask.styl'; import { reaction } from 'mobx'; -import { Tooltip } from '../../common/Tooltip/Tooltip'; export const CurrentTask = observer(({ store }) => { const [initialCommentLength, setInitialCommentLength] = useState(0); @@ -57,11 +56,9 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && showCounter && ( - - - {store.queuePosition} of {store.queueTotal} - - + + {store.queuePosition} of {store.queueTotal} + )} {historyEnabled && ( diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 21a60a1e4a..81efc6f5ae 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -535,8 +535,8 @@ export default types }) .then(() => self.setFlags({ isSubmitting: false })); } - function incrementQueuePosition() { - self.queuePosition++; + function incrementQueuePosition(number = 1) { + self.queuePosition += number; } function submitAnnotation() { @@ -578,6 +578,7 @@ export default types if (self.isSubmitting) return; handleSubmittingFlag(() => { getEnv(self).events.invoke('skipTask', self, extraData); + self.incrementQueuePosition(); }, 'Error during skip, try again'); } @@ -618,6 +619,8 @@ export default types entity.dropDraft(); await getEnv(self).events.invoke('rejectAnnotation', self, { isDirty, entity, comment }); + self.incrementQueuePosition(-1); + }, 'Error during reject, try again'); } @@ -766,6 +769,8 @@ export default types // or annotation created from prediction await annotation.saveDraft({ was_postponed: true }); await getEnv(self).events.invoke('nextTask'); + self.incrementQueuePosition(); + } function nextTask() { @@ -774,6 +779,8 @@ export default types const { taskId, annotationId } = self.taskHistory[self.taskHistory.findIndex((x) => x.taskId === self.task.id) + 1]; getEnv(self).events.invoke('nextTask', taskId, annotationId); + self.incrementQueuePosition(); + } } @@ -785,6 +792,8 @@ export default types const { taskId, annotationId } = self.taskHistory[length]; getEnv(self).events.invoke('prevTask', taskId, annotationId); + self.incrementQueuePosition(-1); + } } From 8800493c6d241687382cca77fb2f0cbacc5a325c Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Tue, 19 Sep 2023 10:20:23 -0500 Subject: [PATCH 5/7] add feature flag --- src/components/BottomBar/CurrentTask.js | 14 +++++++++++--- src/components/TopBar/CurrentTask.js | 19 +++++++++++++++---- src/utils/feature-flags.ts | 6 ++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/components/BottomBar/CurrentTask.js b/src/components/BottomBar/CurrentTask.js index f8589e3391..328be3baa6 100644 --- a/src/components/BottomBar/CurrentTask.js +++ b/src/components/BottomBar/CurrentTask.js @@ -1,13 +1,17 @@ +import React, { useMemo } from 'react'; import { observer } from 'mobx-react'; import { Button } from '../../common/Button/Button'; import { Block, Elem } from '../../utils/bem'; import { guidGenerator } from '../../utils/unique'; import { isDefined } from '../../utils/utilities'; -import { Tooltip } from '../../common/Tooltip/Tooltip'; +import { FF_TASK_COUNT_FIX, isFF } from '../../common/Tooltip/Tooltip'; import './CurrentTask.styl'; export const CurrentTask = observer(({ store }) => { + const currentIndex = useMemo(() => { + return store.taskHistory.findIndex((x) => x.taskId === store.task.id) + 1; + }, [store.taskHistory]); const historyEnabled = store.hasInterface('topbar:prevnext'); // @todo some interface? @@ -22,11 +26,15 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && ( - + isFF(FF_TASK_COUNT_FIX) ? ( {store.queuePosition} of {store.queueTotal} - + ) : ( + + {currentIndex} of {store.taskHistory.length} + + ) )} {historyEnabled && ( diff --git a/src/components/TopBar/CurrentTask.js b/src/components/TopBar/CurrentTask.js index b03c907831..b3016b9413 100644 --- a/src/components/TopBar/CurrentTask.js +++ b/src/components/TopBar/CurrentTask.js @@ -1,14 +1,19 @@ +import React, { useMemo } from 'react'; import { observer } from 'mobx-react'; import { useEffect, useState } from 'react'; import { Button } from '../../common/Button/Button'; import { Block, Elem } from '../../utils/bem'; -import { FF_DEV_3873, FF_DEV_4174, isFF } from '../../utils/feature-flags'; +import { FF_DEV_3873, FF_DEV_4174, FF_TASK_COUNT_FIX, isFF } from '../../utils/feature-flags'; import { guidGenerator } from '../../utils/unique'; import { isDefined } from '../../utils/utilities'; import './CurrentTask.styl'; import { reaction } from 'mobx'; export const CurrentTask = observer(({ store }) => { + const currentIndex = useMemo(() => { + return store.taskHistory.findIndex((x) => x.taskId === store.task.id) + 1; + }, [store.taskHistory]); + const [initialCommentLength, setInitialCommentLength] = useState(0); const [visibleComments, setVisibleComments] = useState(0); @@ -56,9 +61,15 @@ export const CurrentTask = observer(({ store }) => { {store.task.id ?? guidGenerator()} {historyEnabled && showCounter && ( - - {store.queuePosition} of {store.queueTotal} - + isFF(FF_TASK_COUNT_FIX) ? ( + + {store.queuePosition} of {store.queueTotal} + + ) : ( + + {currentIndex} of {store.taskHistory.length} + + ) )} {historyEnabled && ( diff --git a/src/utils/feature-flags.ts b/src/utils/feature-flags.ts index 1de865bd82..d1cffc56c8 100644 --- a/src/utils/feature-flags.ts +++ b/src/utils/feature-flags.ts @@ -317,6 +317,12 @@ export const FF_TAXONOMY_ASYNC = 'fflag_feat_front_lsdv_5451_async_taxonomy_1108 */ export const FF_TAXONOMY_LABELING = 'fflag_feat_front_lsdv_5452_taxonomy_labeling_110823_short'; +/** + * Fix task count on projects with over 100 tasks (switch from task history to queue count) + * @link https://app.launchdarkly.com/default/production/features/fflag_fix_all_optic_79_task_count_is_wrong_short/targeting + */ +export const FF_TASK_COUNT_FIX = 'fflag_fix_all_optic_79_task_count_is_wrong_short'; + Object.assign(window, { APP_SETTINGS: { ...(window.APP_SETTINGS ?? {}), From 82bc40ce0bb4371a40c2edbf09bb95c2106e8932 Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Wed, 20 Sep 2023 09:29:00 -0500 Subject: [PATCH 6/7] clamp queue position value --- src/stores/AppStore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 81efc6f5ae..351a374ed0 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -17,7 +17,7 @@ import { Hotkey } from '../core/Hotkey'; import ToolsManager from '../tools/Manager'; import Utils from '../utils'; import { guidGenerator } from '../utils/unique'; -import { delay, isDefined } from '../utils/utilities'; +import { clamp, delay, isDefined } from '../utils/utilities'; import AnnotationStore from './Annotation/store'; import Project from './ProjectStore'; import Settings from './SettingsStore'; @@ -536,7 +536,7 @@ export default types .then(() => self.setFlags({ isSubmitting: false })); } function incrementQueuePosition(number = 1) { - self.queuePosition += number; + self.queuePosition = clamp(self.queuePosition + number, 1, self.queueTotal); } function submitAnnotation() { From 7b8fd9b962a1d2a5ec175725d5542754280dbc11 Mon Sep 17 00:00:00 2001 From: Travis1282 Date: Wed, 20 Sep 2023 09:32:47 -0500 Subject: [PATCH 7/7] fix spacing --- src/utils/feature-flags.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/feature-flags.ts b/src/utils/feature-flags.ts index 08f9fc3b26..50d3220ceb 100644 --- a/src/utils/feature-flags.ts +++ b/src/utils/feature-flags.ts @@ -321,8 +321,8 @@ export const FF_TAXONOMY_LABELING = 'fflag_feat_front_lsdv_5452_taxonomy_labelin * Fix task count on projects with over 100 tasks (switch from task history to queue count) * @link https://app.launchdarkly.com/default/production/features/fflag_fix_all_optic_79_task_count_is_wrong_short/targeting */ -export const FF_TASK_COUNT_FIX = 'fflag_fix_all_optic_79_task_count_is_wrong_short'; +export const FF_TASK_COUNT_FIX = 'fflag_fix_all_optic_79_task_count_is_wrong_short'; /** * Annotator workflow control for lead time calculation */