render code has to handle service or service reference
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/commands.js b/bundles/org.eclipse.orion.client.core/web/orion/commands.js
index 56de5c4..631b5b1 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/commands.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/commands.js
@@ -500,7 +500,8 @@
 
 		/**
 		 * Render the commands that are appropriate for the given scope.
-		 * @param {DOMElement} parent The element in which commands should be rendered.
+		 * @param {DOMElement} parent The element in which commands should be rendered.  If commands have been
+		 *  previously rendered into this element, it is up to the caller to empty any previously generated content.
 		 * @param {String} scope The scope to which the command applies.  "dom" level 
 		 *  commands apply only when a specified dom element is rendering commands.
 		 *  "object" scope applies to particular objects/items displayed in widgets
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/globalCommands.js b/bundles/org.eclipse.orion.client.core/web/orion/globalCommands.js
index a64e48f..b4ccc44 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/globalCommands.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/globalCommands.js
@@ -433,9 +433,14 @@
 		}
 		if (toolbar) {	
 			dojo.empty(toolbar);
-			commandService.renderCommands(toolbar, "dom", handler, handler, "tool", !useImage).then(function() {
+			// The render call may be synch (when called by page glue code that created the service)
+			// or asynch (when called after getting a service reference).
+			var retn = commandService.renderCommands(toolbar, "dom", handler, handler, "tool", !useImage);
+			if (retn && retn.then) {
+				retn.then(function() {commandService.processURL(window.location.href);});
+			} else {
 				commandService.processURL(window.location.href);
-			});  
+			} 
 		}
 		// now page navigation actions
 		toolbar = dojo.byId("pageNavigationActions");