Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f2a265c
Add prototype of prompt
rafeca Apr 3, 2019
714bb7a
Modify the user settings when enabling fast mode
rafeca Apr 3, 2019
305d11c
Dismiss notification when clicking on the No button
rafeca Apr 3, 2019
3bd827b
Do not show the prompt when there are other messages
rafeca Apr 3, 2019
3dc84f3
Fix linter errors
rafeca Apr 3, 2019
52b3352
Merge branch 'master' into fast-mode-prompt
rafeca Apr 3, 2019
08625de
Only show the prompt on projects with more than 10K files
rafeca Apr 3, 2019
2048dae
Move prompt logic to its own file
rafeca Apr 3, 2019
5befecd
Add logic to remove the new label after some time
rafeca Apr 3, 2019
dae12e4
Unify logic to show the prompt
rafeca Apr 4, 2019
beeb222
Add prompt to allow users to disable fast mode
rafeca Apr 4, 2019
6482736
Fix lint errors
rafeca Apr 4, 2019
ff7d866
Add metrics reporting to prompt
rafeca Apr 4, 2019
1584d69
Update docs about metrics being logged
rafeca Apr 4, 2019
3c7036e
Small tweaks to the prompt
rafeca Apr 4, 2019
9e86fe0
:memo: Tweak description of counters
jasonrudolph Apr 9, 2019
0f73936
:art: Rename constant to communicate unit of measure
jasonrudolph Apr 9, 2019
13f1ac0
Change experiement icon from microscope to beaker
jasonrudolph Apr 9, 2019
f4fd05c
Evenly distribute spacing between UI elements in prompt
jasonrudolph Apr 9, 2019
db82e8f
Tweak copy for prompt to disable fast mode
jasonrudolph Apr 9, 2019
3441b85
Right-align the fast-mode prompts
jasonrudolph Apr 9, 2019
2c4939e
:shirt:
jasonrudolph Apr 9, 2019
1e53467
Tweak copy and formatting for notification messages
jasonrudolph Apr 9, 2019
3bc0884
Prompt users to provide feedback when disabling fast mode
jasonrudolph Apr 9, 2019
c3e5b52
Show confirmations after enabling/disabling fast mode
jasonrudolph Apr 9, 2019
800d00c
Move check to show the prompt to the prompt module
rafeca Apr 10, 2019
249cbd4
Always show the prompt if the fast mode is enabled
rafeca Apr 10, 2019
e5711bc
Disable the prompt when using the nucleus-dark-ui theme
rafeca Apr 10, 2019
653b5b7
Use a single "feedback" issue to gather feedback on fast mode
jasonrudolph Apr 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ This document specifies all the data (along with the format) which gets sent fro

## Counters

Currently the Fuzzy finder does not log any counter events.
| counter name | description |
|-------|-------|
| `show-enable-prompt` | Number of times the prompt to enable fast mode is shown |
| `click-enable-prompt` | Number of clicks on the "enable fast mode" prompt |
| `confirm-enable-prompt` | Number of confirmations on the "enable fast mode" notification |
| `cancel-enable-prompt` | Number of cancels on the "enable fast mode" notification |
| `show-disable-prompt` | Number of times the prompt to disable fast mode is shown |
| `click-disable-prompt` | Number of clicks on the "disable fast mode" prompt |
| `confirm-disable-prompt` | Number of confirmations on the "disable fast mode" notification |
| `cancel-disable-prompt` | Number of cancels on the "disable fast mode" notification |

## Timing events

Expand Down
150 changes: 150 additions & 0 deletions lib/experiment-prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
const etch = require('etch')
const $ = etch.dom
const SCORING_SYSTEMS = require('./scoring-systems')

/**
* Minimum number of files in the project needed to show the fast mode prompt.
*/
const ThresholdForShowingPrompt = 10000

/**
* For how long to show the "NEW" badge in the prompt since the first time
* it was seen (24h).
*/
const TimeToShowNewBadgeInMilliseconds = 24 * 60 * 60 * 1000
const FirstTimeShownKey = 'fuzzy-finder:prompt-first-time-shown'

function shouldShowPrompt (numItems) {
// The nucleus-dark-ui does not display the prompt correctly.
if (atom.themes.getActiveThemeNames().includes('nucleus-dark-ui')) {
return false
}

return isFastModeEnabled() || numItems > ThresholdForShowingPrompt
}

function shouldShowBadge () {
const firstTimeShown = localStorage.getItem(FirstTimeShownKey)
const now = new Date().getTime()

if (!firstTimeShown) {
localStorage.setItem(FirstTimeShownKey, now)

return true
}

return now - firstTimeShown <= TimeToShowNewBadgeInMilliseconds
}

function showNotification (message, {description, confirmBtn, cancelBtn, confirmFn, cancelFn}) {
const notification = atom.notifications.addInfo(
message,
{
description,
dismissable: true,
buttons: [
{
text: confirmBtn,
onDidClick: () => {
confirmFn && confirmFn()
notification.dismiss()
},
className: 'btn btn-info btn-primary'
},
{
text: cancelBtn,
onDidClick: () => {
cancelFn && cancelFn()
notification.dismiss()
}
}
],
icon: 'rocket'
}
)
}

function enableExperimentalFuzzyFinder (metricsReporter) {
metricsReporter.incrementCounter('click-enable-prompt')

showNotification(
'Introducing experimental fast mode',
{
description: "The fuzzy finder has a new experimental _fast mode_. It dramatically speeds up the experience of finding files, especially in large projects. Would you like to try it?\n\n(You can always switch back to the fuzzy finder's _normal mode_ later.)",
confirmBtn: 'Enable fast mode',
confirmFn: () => {
metricsReporter.incrementCounter('confirm-enable-prompt')

atom.config.set('fuzzy-finder.useRipGrep', true)
atom.config.set('fuzzy-finder.scoringSystem', SCORING_SYSTEMS.FAST)
atom.notifications.addSuccess('Fasten your seatbelt! Here comes a faster fuzzy finder.', {icon: 'rocket'})
},
cancelBtn: 'Not right now',
cancelFn: () => {
metricsReporter.incrementCounter('cancel-enable-prompt')
}
}
)
}

function disableExperimentalFuzzyFinder (metricsReporter) {
metricsReporter.incrementCounter('click-disable-prompt')

showNotification(
'Do you want to disable the new experimental fast mode for the fuzzy finder?',
{
description: 'If the experimental fast mode is negatively impacting your experience, please leave a comment to [**let us know**](https://github.com/atom/fuzzy-finder/issues/379).\n\n(You can reenable fast mode later from the fuzzy finder.)',
confirmBtn: 'Disable experimental fast mode',
confirmFn: () => {
metricsReporter.incrementCounter('confirm-disable-prompt')

atom.config.set('fuzzy-finder.useRipGrep', false)
atom.config.set('fuzzy-finder.scoringSystem', SCORING_SYSTEMS.ALTERNATE)
atom.notifications.addSuccess('OK. Experimental fast mode is disabled.')
},
cancelBtn: 'No, thanks',
cancelFn: () => {
metricsReporter.incrementCounter('cancel-disable-prompt')
}
}
)
}

function isFastModeEnabled () {
return (
atom.config.get('fuzzy-finder.scoringSystem') === SCORING_SYSTEMS.FAST &&
atom.config.get('fuzzy-finder.useRipGrep') === true
)
}

function renderExperimentPrompt (metricsReporter) {
if (isFastModeEnabled()) {
metricsReporter.incrementCounter('show-disable-prompt')

return (
$.span({className: 'experiment-prompt'}, [
$.a({onmousedown: disableExperimentalFuzzyFinder.bind(null, metricsReporter)}, [
$.span({className: 'icon icon-rocket'}, ''),
$.span({className: ''}, 'Using experimental fast mode. Opt out?')
])
])
)
}

metricsReporter.incrementCounter('show-enable-prompt')

return (
$.span({className: 'experiment-prompt'}, [
$.a({onmousedown: enableExperimentalFuzzyFinder.bind(null, metricsReporter)}, [
shouldShowBadge() ? $.span({className: 'badge badge-info'}, 'NEW') : null,
$.span({className: 'icon icon-beaker'}, ''),
$.span({className: ''}, 'Try experimental fast mode?')
])
])
)
}

module.exports = {
renderExperimentPrompt,
shouldShowPrompt
}
47 changes: 35 additions & 12 deletions lib/fuzzy-finder-view.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
const {Point, CompositeDisposable} = require('atom')
const {renderExperimentPrompt, shouldShowPrompt} = require('./experiment-prompt')
const fs = require('fs-plus')
const fuzzaldrin = require('fuzzaldrin')
const fuzzaldrinPlus = require('fuzzaldrin-plus')
const NativeFuzzy = require('@atom/fuzzy-native')
const SCORING_SYSTEMS = require('./scoring-systems')

const path = require('path')
const SelectListView = require('atom-select-list')

const {repositoryForPath} = require('./helpers')
const getIconServices = require('./get-icon-services')

/**
* These scoring systems should be synchronized with the enum values
* on the scoringSystem config option defined in package.json
**/
const SCORING_SYSTEMS = {
STANDARD: 'standard',
ALTERNATE: 'alternate',
FAST: 'fast'
}

const MAX_RESULTS = 10

module.exports = class FuzzyFinderView {
Expand Down Expand Up @@ -87,6 +79,8 @@ module.exports = class FuzzyFinderView {
errorMessage: null
})
}

return this.updateExperimentPrompt()
},
elementForItem: ({filePath, label, ownerGitHubUsername}) => {
const filterQuery = this.selectListView.getFilterQuery()
Expand Down Expand Up @@ -170,6 +164,8 @@ module.exports = class FuzzyFinderView {
} else {
this.selectListView.update({ filter: this.filterFn })
}

this.updateExperimentPrompt()
})
)
}
Expand Down Expand Up @@ -337,9 +333,36 @@ module.exports = class FuzzyFinderView {
}

if (this.isQueryALineJump()) {
return this.selectListView.update({items: [], loadingMessage: null, loadingBadge: null})
this.selectListView.update({
items: [],
infoMessage: null,
loadingMessage: null,
loadingBadge: null
})
} else {
return this.selectListView.update({items: this.items, loadingMessage: null, loadingBadge: null})
this.selectListView.update({
items: this.items,
infoMessage: null,
loadingMessage: null,
loadingBadge: null
})
}

return this.updateExperimentPrompt()
}

updateExperimentPrompt () {
if (
this.selectListView.getQuery().length ||
!shouldShowPrompt(this.items.length)
) {
return this.selectListView.update({
infoMessage: null
})
} else {
return this.selectListView.update({
infoMessage: renderExperimentPrompt(this.metricsReporter)
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/project-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ class ProjectView extends FuzzyFinderView {
}

if (this.paths) {
await this.selectListView.update({loadingMessage: 'Reindexing project\u2026'})
await this.selectListView.update({loadingMessage: 'Reindexing project\u2026', infoMessage: null})
} else {
await this.selectListView.update({loadingMessage: 'Indexing project\u2026', loadingBadge: '0'})
await this.selectListView.update({loadingMessage: 'Indexing project\u2026', infoMessage: null, loadingBadge: '0'})
if (task) {
let pathsFound = 0
task.on('load-paths:paths-found', (paths) => {
pathsFound += paths.length
this.selectListView.update({loadingMessage: 'Indexing project\u2026', loadingBadge: humanize.intComma(pathsFound)})
this.selectListView.update({loadingMessage: 'Indexing project\u2026', infoMessage: null, loadingBadge: humanize.intComma(pathsFound)})
})
}
}
Expand Down
14 changes: 14 additions & 0 deletions lib/reporter-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = class ReporterProxy {
constructor () {
this.reporter = null
this.timingsQueue = []
this.countersQueue = []

this.eventType = 'fuzzy-finder-v1'

Expand All @@ -13,10 +14,15 @@ module.exports = class ReporterProxy {
setReporter (reporter) {
this.reporter = reporter
let timingsEvent
let counterName

while ((timingsEvent = this.timingsQueue.shift())) {
this.reporter.addTiming(this.eventType, timingsEvent[0], timingsEvent[1])
}

while ((counterName = this.countersQueue.shift())) {
this.reporter.incrementCounter(counterName)
}
}

unsetReporter () {
Expand Down Expand Up @@ -45,6 +51,14 @@ module.exports = class ReporterProxy {
this._addTimingThrottled(duration, metadata)
}

incrementCounter (counterName) {
if (this.reporter) {
this.reporter.incrementCounter(counterName)
} else {
this.countersQueue.push(counterName)
}
}

_addTiming (duration, metadata) {
if (this.reporter) {
this.reporter.addTiming(this.eventType, duration, metadata)
Expand Down
9 changes: 9 additions & 0 deletions lib/scoring-systems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* These scoring systems should be synchronized with the enum values
* on the scoringSystem config option defined in package.json
**/
module.exports = {
STANDARD: 'standard',
ALTERNATE: 'alternate',
FAST: 'fast'
}
9 changes: 9 additions & 0 deletions styles/fuzzy-finder.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@
right: @component-padding;
}
}

.fuzzy-finder .experiment-prompt {
display: flex;
justify-content: flex-end;

.badge {
margin-right: (@component-padding / 2);
}
}