viz: Show a different amount of paper-autocomplete items

* Limits the # of namespace items to 5.
* Limits the # of recommended invocations to 4, but now predicts an
  unlimited number that pass the threshold score.

Change-Id: I7f1a724ef3937dc3caab7748ecff777d23072569
diff --git a/src/components/browse/index.js b/src/components/browse/index.js
index 8b9d7bc..0cc4a1a 100644
--- a/src/components/browse/index.js
+++ b/src/components/browse/index.js
@@ -29,6 +29,10 @@
 module.exports.render = render;
 module.exports.renderHeader = renderHeader;
 
+// While there could be any number of children at the current namespace, only
+// show up to 5 suggestions at a time. Rely on the filter to find the rest.
+var NAMESPACE_AUTOCOMPLETE_MAX_ITEMS = 5;
+
 /*
  * Browse component provides user interfaces for browsing the Veyron namespace
  */
@@ -186,7 +190,7 @@
     'learner-method-input',
     smartService.constants.LEARNER_METHOD_INPUT, {
       minThreshold: 0.2,
-      maxValues: 5
+      maxValues: -1
     }
   ).catch(function(err) {
     log.error(err);
@@ -374,11 +378,12 @@
         }),
         h('paper-autocomplete', {
           attributes: {
-            'flex': 'true'
+            'name': 'namespace',
+            'value': browseState.namespace,
+            'delimiter': '/',
+            'flex': 'true',
+            'maxItems': NAMESPACE_AUTOCOMPLETE_MAX_ITEMS
           },
-          'name': 'namespace',
-          'value': browseState.namespace,
-          'delimiter': '/',
           'ev-focus': focusEvent,
           'ev-input': inputEvent,
           'ev-change': changeEvent
diff --git a/src/components/browse/item-details/method-form/index.js b/src/components/browse/item-details/method-form/index.js
index 70fce09..007bb14 100644
--- a/src/components/browse/item-details/method-form/index.js
+++ b/src/components/browse/item-details/method-form/index.js
@@ -26,6 +26,10 @@
 module.exports = create;
 module.exports.render = render;
 
+// While an unlimited # of items are predicted per input, it's a bad idea to
+// show them all. Limit to 4 at a time, and rely on filtering to find the rest.
+var METHOD_INPUT_MAX_ITEMS = 4;
+
 /*
  * Create the base state and events necessary to render a method form.
  * Call the displayMethodForm event to fill this state with more data.
@@ -510,8 +514,11 @@
   // That means spurious 'change' and 'input' events may appear occasionally.
   var elem = h('paper-autocomplete.method-input-item.autocomplete', {
     'key': state.itemName, // Enforce element refresh when switching items
-    'label': argName + ' (' + argTypeStr + ')',
-    'value': args[index],
+    attributes: {
+      'label': argName + ' (' + argTypeStr + ')',
+      'value': args[index],
+      'maxItems': METHOD_INPUT_MAX_ITEMS
+    },
     'ev-change': changeEvent
   }, children);
 
diff --git a/src/services/smart/service-implementation.js b/src/services/smart/service-implementation.js
index d351ea6..6d2421b 100644
--- a/src/services/smart/service-implementation.js
+++ b/src/services/smart/service-implementation.js
@@ -382,7 +382,7 @@
 
   // Rank the scored items and return the top values (limit to maxValues)
   var maxValues = this.params.maxValues;
-  if (maxValues === undefined) {
+  if (maxValues === undefined || maxValues < 0) {
     maxValues = scoredItems.length;
   }
   var bestK = rank.getBestKItems(scoredItems, maxValues);