Index: privatemsg.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.pages.inc,v
retrieving revision 1.1.2.32
diff -u -p -r1.1.2.32 privatemsg.pages.inc
--- privatemsg.pages.inc	21 Oct 2010 09:12:37 -0000	1.1.2.32
+++ privatemsg.pages.inc	7 Nov 2010 17:01:37 -0000
@@ -690,6 +690,10 @@ function privatemsg_autocomplete($string
 function  privatemsg_view($thread) {
   drupal_set_title($thread['subject']);
 
+  $content = array(
+    '#thread' => $thread,
+  );
+
   if ($thread['to'] != $thread['message_count'] || !empty($thread['start'])) {
     // Generate paging links.
     $older = '';
Index: privatemsg_filter/privatemsg_filter.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.css,v
retrieving revision 1.1
diff -u -p -r1.1 privatemsg_filter.css
--- privatemsg_filter/privatemsg_filter.css	12 Dec 2008 21:28:04 -0000	1.1
+++ privatemsg_filter/privatemsg_filter.css	7 Nov 2010 17:01:38 -0000
@@ -6,4 +6,13 @@ form#privatemsg-filter-dropdown #edit-au
 
 form#privatemsg-filter-dropdown #privatemsg-filter-buttons {
   clear: left;
+}
+
+form#privatemsg-filter-form div.form-item {
+    float: left;
+    margin-right: 5px;
+}
+
+form#privatemsg-filter-form {
+    clear: both;
 }
\ No newline at end of file
Index: privatemsg_filter/privatemsg_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg_filter/privatemsg_filter.module,v
retrieving revision 1.1.2.17.2.30
diff -u -p -r1.1.2.17.2.30 privatemsg_filter.module
--- privatemsg_filter/privatemsg_filter.module	6 Oct 2010 19:46:35 -0000	1.1.2.17.2.30
+++ privatemsg_filter/privatemsg_filter.module	7 Nov 2010 17:01:38 -0000
@@ -252,9 +252,6 @@ function privatemsg_filter_remove_tags($
   if (!is_array($threads)) {
     $threads = array($threads);
   }
-  if (!is_array($tag_ids)) {
-    $tag_ids = array($tag_ids);
-  }
   if (empty($account)) {
     global $user;
     $account = $user;
@@ -269,6 +266,10 @@ function privatemsg_filter_remove_tags($
       ->execute();
   }
   else {
+    if (!is_array($tag_ids)) {
+      $tag_ids = array($tag_ids);
+    }
+
     //Delete tag mapping for the specified tag.
     db_delete('pm_tags_index')
       ->condition('uid', $account->uid)
@@ -731,53 +732,100 @@ function privatemsg_filter_query_private
 }
 
 /**
- * Hook into the view messages page to add a form for tagging purposes.
+ * Hook into the view messages page to add a form for tagging pumessagesrposes.
  */
 function privatemsg_filter_page_alter(&$page) {
-  if (isset($page['content']['system_main']['messages']) && count($page['content']['system_main']['messages']) && isset($page['content']['system_main']['participants']) && privatemsg_user_access('tag private messages')) {
-    $page['content']['system_main']['tags'] = drupal_get_form('privatemsg_filter_form');
-    $page['content']['system_main']['tags']['#weight'] = variable_get('privatemsg_filter_tagfield_weight', 10);
+  if (isset($page['content']['system_main']['#thread']) && count($page['content']['system_main']['messages']) && privatemsg_user_access('tag private messages')) {
+    $thread_id = $page['content']['system_main']['#thread']['thread_id'];
+    $page['content']['system_main']['tags'] = privatemsg_filter_show_tags($thread_id, !empty($_GET['show_tags_form']));
   }
 }
 
+function privatemsg_filter_show_tags($thread_id, $show_form) {
+  global $user;
+  if (!$show_form) {
+      $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $user, array($thread_id));
+      $tags = array();
+      foreach ($query->execute()->fetchCol(1) as $tag_id => $tag) {
+        $tags[] = l($tag, 'messages', array(
+          'attributes' => array('title' => $tag),
+          'query' => array('tags' => $tag)
+        ));
+      }
+
+      if (empty($tags)) {
+        $text = t('No tags.');
+      }
+      else {
+        $text = t('Tags: !tags.', array('!tags' => implode(', ', $tags)));
+      }
+
+      $tags = array(
+        '#prefix' => '<div id="privatemsg-filter-tags">',
+        '#suffix' => '</div>',
+        'text' => array(
+          '#markup' => $text,
+        ),
+        'space' => array(
+          '#markup' => ' ',
+        ),
+        'link' => array(
+          '#type' => 'link',
+          '#href' => $_GET['q'],
+          '#options' => array('query' => array('show_tags_form' => TRUE)),
+          '#title' => t('Change'),
+          /*'#ajax' => array(
+            '#wrapper' => 'privatemsg-filter-tags',
+            '#effect' => 'fade',
+            '#callback' => 'privatemsg_filter_thread_tags_js',
+          )*/
+        ),
+        '#weight' => -10,
+      );
+      return $tags;
+    }
+    else {
+      $form = drupal_get_form('privatemsg_filter_form', $thread_id);
+      $form['#weight'] = -10;
+      return $form;
+    }
+}
+
 /**
  * Form to show and allow modification of tagging information for a conversation.
  */
-function privatemsg_filter_form($form, &$form_state) {
+function privatemsg_filter_form($form, &$form_state, $thread_id) {
   global $user;
-  $thread_id = arg(2);
+
+  drupal_add_css(drupal_get_path('module', 'privatemsg_filter') . '/privatemsg_filter.css');
 
   // Get a list of current tags for this thread
   $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $user, array($thread_id));
   $count = $query->countQuery()->execute()->fetchField();
   $tags = implode(', ', $query->execute()->fetchCol(1));
 
-  $form['tags'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Tags'),
+  $form = array(
     '#access' => privatemsg_user_access('tag private messages'),
-    '#collapsible' => TRUE,
-    '#collapsed' => empty($count) ? TRUE : FALSE,
   );
-  $form['tags']['user_id'] = array(
+  $form['user_id'] = array(
     '#type' => 'value',
     '#value' => $user->uid,
   );
-  $form['tags']['thread_id'] = array(
+  $form['thread_id'] = array(
     '#type' => 'value',
     '#value' => $thread_id,
   );
 
-  $form['tags']['tags'] = array(
+  $form['tags'] = array(
     '#type'               => 'textfield',
     '#title'              => t('Tags for this conversation'),
-    '#description'        => t('Separate multiple tags with commas.'),
-    '#size'               => 50,
+    '#title_display'      => 'invisible',
+    '#size'               => 30,
     '#default_value'      => $tags,
     '#autocomplete_path'  => 'messages/filter/tag-autocomplete',
   );
 
-  $form['tags']['submit'] = array(
+  $form['submit'] = array(
     '#type'     => 'submit',
     '#value'    => t('Tag this conversation'),
     '#submit'   => array('privatemsg_filter_form_submit'),
@@ -790,7 +838,7 @@ function privatemsg_filter_form_submit($
   if (isset($form_state['values']['submit'])) {
     $tags = explode(',', $form_state['values']['tags']);
 
-    // Step 1 - Delete all tag mapping. I cannot think of a better way to remove tags that are no longer in the textfield, so ideas welcome.
+    // Step 1 - Delete all tag mapping.
     privatemsg_filter_remove_tags($form_state['values']['thread_id']);
 
     // Step 2 - Get the id for each of the tags.
